-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Open
Description
RT-Thread Version
5.3.0
Hardware Type/Architectures
qemu aarch64
Develop Toolchain
GCC
Describe the bug
- 准备一个while(1)的用户态程序 test.elf。
- 进入ash。先后台运行此程序, ./test.elf &
- 再启动另一个程序,例如 ls 。 就会触发异常。
异常发生在arch_set_thread_context 函数获取判断 thread(ash)->user_ctx.ctx 是否为空时。
错误发生的流程如下:
-
在启动新程序 "ls"时,通过系统调用fork进入内核准备启动新进程,current进程是“ash”
-
在内核启动新进程的过程中上下文被切到后台进程“test.elf”中执行,current进程是“test.elf”
-
在执行“test.elf”时进入os counter中断,此时“test.elf”时间片使用完,内核将current进程切回“ash”,此时在中断返回时会执行RESTORE_USER_CTX,由于此中断是从“test.elf”这个用户模式进来的,所以会执行user_ctx的restore,在lwp_uthread_ctx_restore函数中将“ash”的user_ctx.ctx清空。然后切回之前的“fork”
-
系统回到之前的fork中继续创建新进程,在执行到arch_set_thread_context时发现user_ctx.ctx的值为空。
Other additional context

Metadata
Metadata
Assignees
Labels
No labels