1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 14:37:46 +00:00

Kernel: Make Process::current() return a Process& instead of Process*

This has several benefits:
1) We no longer just blindly derefence a null pointer in various places
2) We will get nicer runtime error messages if the current process does
turn out to be null in the call location
3) GCC no longer complains about possible nullptr dereferences when
compiling without KUBSAN
This commit is contained in:
Idan Horowitz 2021-08-19 22:45:07 +03:00 committed by Andreas Kling
parent 1259dc3623
commit cf271183b4
26 changed files with 142 additions and 141 deletions

View file

@ -214,14 +214,14 @@ static void dump(const RegisterState& regs)
void handle_crash(RegisterState const& regs, char const* description, int signal, bool out_of_memory)
{
auto process = Process::current();
if (!process) {
if (!Process::has_current())
PANIC("{} with !current", description);
}
auto& process = Process::current();
// If a process crashed while inspecting another process,
// make sure we switch back to the right page tables.
MM.enter_process_paging_scope(*process);
MM.enter_process_paging_scope(process);
dmesgln("CRASH: CPU #{} {} in ring {}", Processor::id(), description, (regs.cs & 3));
dump(regs);
@ -230,7 +230,7 @@ void handle_crash(RegisterState const& regs, char const* description, int signal
PANIC("Crash in ring 0");
}
process->crash(signal, regs.ip(), out_of_memory);
process.crash(signal, regs.ip(), out_of_memory);
}
EH_ENTRY_NO_CODE(6, illegal_instruction);