mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-28 20:03:22 +00:00
Catch panics in threads as oops
This commit is contained in:
committed by
Tate, Hongliang Tian
parent
709e99d75a
commit
4823b82e41
@ -45,8 +45,8 @@ impl KernelThreadExt for Thread {
|
||||
pub fn create_new_kernel_task(mut thread_options: ThreadOptions) -> Arc<Task> {
|
||||
let task_fn = thread_options.take_func();
|
||||
let thread_fn = move || {
|
||||
task_fn();
|
||||
// Ensures the thread is exit
|
||||
let _ = crate::oops::catch_panics_as_oops(task_fn);
|
||||
// Ensure that the thread exits.
|
||||
current_thread!().exit();
|
||||
};
|
||||
|
||||
|
@ -89,9 +89,13 @@ pub fn create_new_user_task(user_space: Arc<UserSpace>, thread_ref: Arc<Thread>)
|
||||
debug!("exit user loop");
|
||||
}
|
||||
|
||||
TaskOptions::new(user_task_entry)
|
||||
.data(thread_ref)
|
||||
.user_space(Some(user_space))
|
||||
.build()
|
||||
.expect("spawn task failed")
|
||||
TaskOptions::new(|| {
|
||||
// TODO: If a kernel "oops" is caught, we should kill the entire
|
||||
// process rather than just ending the thread.
|
||||
let _ = crate::oops::catch_panics_as_oops(user_task_entry);
|
||||
})
|
||||
.data(thread_ref)
|
||||
.user_space(Some(user_space))
|
||||
.build()
|
||||
.expect("spawn task failed")
|
||||
}
|
||||
|
Reference in New Issue
Block a user