mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-11 01:06:01 +03:00
Kernel: Always switch to own page tables when crashing/asserting
I noticed this while debugging a crash in backtrace generation. If a process would crash while temporarily inspecting another process's address space, the crashing thread would still use the other process's page tables while handling the crash, causing all kinds of confusion when trying to walk the stack of the crashing thread.
This commit is contained in:
parent
f7b394e9a1
commit
38fc31ff11
Notes:
sideshowbarker
2024-07-19 09:57:51 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/38fc31ff11f
@ -208,6 +208,10 @@ void handle_crash(RegisterDump& regs, const char* description, int signal)
|
||||
hang();
|
||||
}
|
||||
|
||||
// If a process crashed while inspecting another process,
|
||||
// make sure we switch back to the right page tables.
|
||||
MM.enter_process_paging_scope(current->process());
|
||||
|
||||
kprintf("\033[31;1mCRASH: %s. %s: %s(%u)\033[0m\n",
|
||||
description,
|
||||
current->process().is_ring0() ? "Kernel" : "Process",
|
||||
@ -547,6 +551,12 @@ void __assertion_failed(const char* msg, const char* file, unsigned line, const
|
||||
{
|
||||
asm volatile("cli");
|
||||
kprintf("ASSERTION FAILED: %s\n%s:%u in %s\n", msg, file, line, func);
|
||||
|
||||
// Switch back to the current process's page tables if there are any.
|
||||
// Otherwise stack walking will be a disaster.
|
||||
if (current)
|
||||
MM.enter_process_paging_scope(current->process());
|
||||
|
||||
dump_backtrace();
|
||||
asm volatile("hlt");
|
||||
for (;;)
|
||||
|
Loading…
Reference in New Issue
Block a user