mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-11 01:06:01 +03:00
Kernel: Fix possible context switch within first context switch of a thread
We were enabling interrupts too early, before the first context switch to a thread was complete. This could then trigger another context switch within the context switch, which lead to a crash.
This commit is contained in:
parent
bd73102513
commit
b580c005f1
Notes:
sideshowbarker
2024-07-18 22:51:14 +09:00
Author: https://github.com/tomuta Commit: https://github.com/SerenityOS/serenity/commit/b580c005f17 Pull-request: https://github.com/SerenityOS/serenity/pull/5117
@ -1366,8 +1366,10 @@ extern "C" void context_first_init([[maybe_unused]] Thread* from_thread, [[maybe
|
||||
// Since we got here and don't have Scheduler::context_switch in the
|
||||
// call stack (because this is the first time we switched into this
|
||||
// context), we need to notify the scheduler so that it can release
|
||||
// the scheduler lock.
|
||||
Scheduler::leave_on_first_switch(trap->regs->eflags);
|
||||
// the scheduler lock. We don't want to enable interrupts at this point
|
||||
// as we're still in the middle of a context switch. Doing so could
|
||||
// trigger a context switch within a context switch, leading to a crash.
|
||||
Scheduler::leave_on_first_switch(trap->regs->eflags & ~0x200);
|
||||
}
|
||||
|
||||
extern "C" void thread_context_first_enter(void);
|
||||
|
Loading…
Reference in New Issue
Block a user