From 9607b4205a6b4beb8f0f7c63fa466020e8d30489 Mon Sep 17 00:00:00 2001 From: Bananymous Date: Mon, 18 Mar 2024 16:05:47 +0200 Subject: [PATCH] Kernel: Fix kernel panic on signal Signals are now added/handled without Scheduler's lock --- kernel/kernel/Process.cpp | 2 +- kernel/kernel/Scheduler.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/kernel/Process.cpp b/kernel/kernel/Process.cpp index 722f95d823..73a85bdba5 100644 --- a/kernel/kernel/Process.cpp +++ b/kernel/kernel/Process.cpp @@ -247,7 +247,6 @@ namespace Kernel void Process::exit(int status, int signal) { - LockGuard _(m_process_lock); m_exit_status.exit_code = __WGENEXITCODE(status, signal); for (auto* thread : m_threads) if (thread != &Thread::current()) @@ -330,6 +329,7 @@ namespace Kernel BAN::ErrorOr Process::sys_exit(int status) { ASSERT(this == &Process::current()); + LockGuard _(m_process_lock); exit(status, 0); ASSERT_NOT_REACHED(); } diff --git a/kernel/kernel/Scheduler.cpp b/kernel/kernel/Scheduler.cpp index 73f9d86f59..2b892ae2d3 100644 --- a/kernel/kernel/Scheduler.cpp +++ b/kernel/kernel/Scheduler.cpp @@ -247,9 +247,9 @@ namespace Kernel m_lock.unlock(InterruptState::Disabled); start_thread(current->rsp(), current->rip()); case Thread::State::Executing: + m_lock.unlock(InterruptState::Disabled); while (current->can_add_signal_to_execute()) current->handle_signal(); - m_lock.unlock(InterruptState::Disabled); continue_thread(current->rsp(), current->rip()); case Thread::State::Terminated: ASSERT_NOT_REACHED();