diff --git a/Kernel/Arch/i386/CPU.cpp b/Kernel/Arch/i386/CPU.cpp index 0a302b750e..b33e48f659 100644 --- a/Kernel/Arch/i386/CPU.cpp +++ b/Kernel/Arch/i386/CPU.cpp @@ -276,7 +276,7 @@ void page_fault_handler(TrapFrame* trap) return; } - if (response != PageFaultResponse::OutOfMemory) { + if (response != PageFaultResponse::OutOfMemory && current_thread) { if (current_thread->has_signal_handler(SIGSEGV)) { current_thread->send_urgent_signal_to_self(SIGSEGV); return; @@ -310,16 +310,18 @@ void page_fault_handler(TrapFrame* trap) dbgln("Note: Address {} looks like a possible nullptr dereference", VirtualAddress(fault_address)); } - auto& current_process = current_thread->process(); - if (current_process.is_user_process()) { - current_process.set_coredump_metadata("fault_address", String::formatted("{:p}", fault_address)); - current_process.set_coredump_metadata("fault_type", fault.type() == PageFault::Type::PageNotPresent ? "NotPresent" : "ProtectionViolation"); - String fault_access; - if (fault.is_instruction_fetch()) - fault_access = "Execute"; - else - fault_access = fault.access() == PageFault::Access::Read ? "Read" : "Write"; - current_process.set_coredump_metadata("fault_access", fault_access); + if (current_thread) { + auto& current_process = current_thread->process(); + if (current_process.is_user_process()) { + current_process.set_coredump_metadata("fault_address", String::formatted("{:p}", fault_address)); + current_process.set_coredump_metadata("fault_type", fault.type() == PageFault::Type::PageNotPresent ? "NotPresent" : "ProtectionViolation"); + String fault_access; + if (fault.is_instruction_fetch()) + fault_access = "Execute"; + else + fault_access = fault.access() == PageFault::Access::Read ? "Read" : "Write"; + current_process.set_coredump_metadata("fault_access", fault_access); + } } handle_crash(regs, "Page Fault", SIGSEGV, response == PageFaultResponse::OutOfMemory);