mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 14:28:12 +00:00
Kernel: Unwind kernel stacks before dying
While executing in the kernel, a thread can acquire various resources that need cleanup, such as locks and references to RefCounted objects. This cleanup normally happens on the exit path, such as in destructors for various RAII guards. But we weren't calling those exit paths when killing threads that have been executing in the kernel, such as threads blocked on reading or sleeping, thus causing leaks. This commit changes how killing threads works. Now, instead of killing a thread directly, one is supposed to call thread->set_should_die(), which will unblock it and make it unwind the stack if it is blocked in the kernel. Then, just before returning to the userspace, the thread will automatically die.
This commit is contained in:
parent
00e56cda0c
commit
1e1ddce9d8
4 changed files with 58 additions and 7 deletions
|
@ -100,4 +100,7 @@ void syscall_trap_entry(RegisterDump regs)
|
|||
if (auto* tracer = process.tracer())
|
||||
tracer->did_syscall(function, arg1, arg2, arg3, regs.eax);
|
||||
process.big_lock().unlock();
|
||||
|
||||
// Check if we're supposed to return to userspace or just die.
|
||||
current->die_if_needed();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue