rcore-os / rcore-os/rCore-Tutorial-v3
ch8 exit实现存在bug
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 2.1k
- Forks
- 560
- PR merge metrics
- No merged PRs in 30d
Description
https://rcore-os.github.io/rCore-Tutorial-Book-v3/chapter8/1thread-kernel.html 中说
如果进程/主线程先调用了 exit 系统调用来退出,那么整个进程(包括所属的所有线程)都会退出
但示例代码显然不能做到终止其他线程的运行,不用运行任何测试就能直接读出来。
当然这也可以用测试来验证。基于commit 9ad3bb43124648b92e2f95673db4a49c56871de2 ,运行如下测试:
#![no_std]
#![no_main]
#[macro_use]
extern crate user_lib;
extern crate alloc;
use user_lib::{thread_create, exit};
use alloc::vec::Vec;
pub fn thread_a() -> ! {
for i in 0..1000 { print!("{}", i); }
exit(1)
}
#[no_mangle]
pub fn main() -> i32 {
thread_create(thread_a as usize, 0);
println!("main thread exited.");
exit(0)
}
可能的输出为:
>> exit_test
main thread exited.
[kernel] Panicked at src/sync/up.rs:27 already borrowed: BorrowMutError
[kernel] Panicked at src/task/processor.rs:94 called `Option::unwrap()` on a `None` value
[kernel] Panicked at src/task/processor.rs:94 called `Option::unwrap()` on a `None` value
[kernel] Panicked at src/task/processor.rs:94 called `Option::unwrap()` on a `None` value
...
虽然这段代码不太符合通常的正确代码的模式,但它也不应该让内核crash。
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the issue from commit 9ad3bb43124648b92e2f95673db4a49c56871de2 using the provided exit_test program. Inspect the panic locations in src/sync/up.rs and src/task/processor.rs, then trace the thread and process exit paths. Done means a main-thread exit terminates the process's other threads without crashing the kernel.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- operating-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100