mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 12:37:44 +00:00
Kernel: Don't crash in page_fault_handler if current_thread is null
If we are attempting to emit debugging information about an unhandleable page fault, don't crash trying to kill threads or dump processes if the current_thread isn't set in TLS. Attempt to keep proceeding in order to dump as much useful information as possible. Related: #6948
This commit is contained in:
parent
00498e0405
commit
db78331741
1 changed files with 13 additions and 11 deletions
|
@ -276,7 +276,7 @@ void page_fault_handler(TrapFrame* trap)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (response != PageFaultResponse::OutOfMemory) {
|
if (response != PageFaultResponse::OutOfMemory && current_thread) {
|
||||||
if (current_thread->has_signal_handler(SIGSEGV)) {
|
if (current_thread->has_signal_handler(SIGSEGV)) {
|
||||||
current_thread->send_urgent_signal_to_self(SIGSEGV);
|
current_thread->send_urgent_signal_to_self(SIGSEGV);
|
||||||
return;
|
return;
|
||||||
|
@ -310,6 +310,7 @@ void page_fault_handler(TrapFrame* trap)
|
||||||
dbgln("Note: Address {} looks like a possible nullptr dereference", VirtualAddress(fault_address));
|
dbgln("Note: Address {} looks like a possible nullptr dereference", VirtualAddress(fault_address));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (current_thread) {
|
||||||
auto& current_process = current_thread->process();
|
auto& current_process = current_thread->process();
|
||||||
if (current_process.is_user_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_address", String::formatted("{:p}", fault_address));
|
||||||
|
@ -321,6 +322,7 @@ void page_fault_handler(TrapFrame* trap)
|
||||||
fault_access = fault.access() == PageFault::Access::Read ? "Read" : "Write";
|
fault_access = fault.access() == PageFault::Access::Read ? "Read" : "Write";
|
||||||
current_process.set_coredump_metadata("fault_access", fault_access);
|
current_process.set_coredump_metadata("fault_access", fault_access);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
handle_crash(regs, "Page Fault", SIGSEGV, response == PageFaultResponse::OutOfMemory);
|
handle_crash(regs, "Page Fault", SIGSEGV, response == PageFaultResponse::OutOfMemory);
|
||||||
} else if (response == PageFaultResponse::Continue) {
|
} else if (response == PageFaultResponse::Continue) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue