[BUG REPORT] busybox下运行跟进程相关的程序就会出现Segmentation fault
描述错误 busybox下运行跟进程相关的程序就会出现Segmentation fault,例如waitpid,test-processgroup,test-session
waitpid的内容如下
#include "stdio.h"
#include "stdlib.h"
#include "unistd.h"
#include <sched.h>
#include <sys/wait.h>
#include <assert.h>
int i = 1000;
void test_waitpid(void){
int cpid, wstatus;
cpid = fork();
assert(cpid != -1);
if(cpid == 0){
while(i--);
sched_yield();
printf("This is child process\n");
exit(3);
}else{
pid_t ret = waitpid(cpid, &wstatus, 0);
assert(ret != -1);
if(ret == cpid && WEXITSTATUS(wstatus) == 3)
printf("waitpid successfully.\nwstatus: %x\n", WEXITSTATUS(wstatus));
else
printf("waitpid error.\n");
}
}
int main(void){
test_waitpid();
return 0;
}
请填写您的电脑的信息:
- DragonOS版本:b322121
重现步骤 重现行为的步骤:
- 在busybox下运行进程相关的程序
期望行为
waitpid的正常结果
屏幕截图
其他上下文 waitpid是测例中的部分,参见basic
wait的运行也会出现上面的问题
@sparkzky linux下面strace一下看看行为。然后再在dragonos打一下syscall的日志看看。可能是mmap & pagecache相关的
cc @MemoryShore
好像是子进程没有正确退出 下面的SYS_RT_SIGTIMEDWAIT好像是因为busybox一直在等子进程退出才调用,但是由于没实现就会一直调用
https://github.com/DragonOS-Community/DragonOS/pull/1229
这里也能复现。 可能跟进程fork&退出的时候unmap页面/pagecache有关 只要我不让子进程退出就不会出现segment fault,以及No mapped VMA的报错。
解决了,见 https://github.com/DragonOS-Community/DragonOS/issues/1231