mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 15:47:44 +00:00
Kernel: Send more specific signals when crashing due to CPU exceptions.
- For division by zero, send SIGFPE. - For illegal instruction, send SIGILL. - For the rest, default to SIGSEGV.
This commit is contained in:
parent
0fa098845f
commit
6ffcee9176
3 changed files with 17 additions and 9 deletions
|
@ -720,14 +720,14 @@ void Process::sys$sigreturn()
|
||||||
ASSERT_NOT_REACHED();
|
ASSERT_NOT_REACHED();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Process::crash()
|
void Process::crash(int signal)
|
||||||
{
|
{
|
||||||
ASSERT_INTERRUPTS_DISABLED();
|
ASSERT_INTERRUPTS_DISABLED();
|
||||||
ASSERT(!is_dead());
|
ASSERT(!is_dead());
|
||||||
|
|
||||||
dump_backtrace();
|
dump_backtrace();
|
||||||
|
|
||||||
m_termination_signal = SIGSEGV;
|
m_termination_signal = signal;
|
||||||
dump_regions();
|
dump_regions();
|
||||||
ASSERT(is_ring3());
|
ASSERT(is_ring3());
|
||||||
die();
|
die();
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
#include <Kernel/UnixTypes.h>
|
#include <Kernel/UnixTypes.h>
|
||||||
#include <Kernel/Thread.h>
|
#include <Kernel/Thread.h>
|
||||||
#include <Kernel/Lock.h>
|
#include <Kernel/Lock.h>
|
||||||
|
#include <LibC/signal_numbers.h>
|
||||||
|
|
||||||
class ELFLoader;
|
class ELFLoader;
|
||||||
class FileDescriptor;
|
class FileDescriptor;
|
||||||
|
@ -191,7 +192,7 @@ public:
|
||||||
|
|
||||||
static void initialize();
|
static void initialize();
|
||||||
|
|
||||||
[[noreturn]] void crash();
|
[[noreturn]] void crash(int signal = SIGSEGV);
|
||||||
[[nodiscard]] static int reap(Process&);
|
[[nodiscard]] static int reap(Process&);
|
||||||
|
|
||||||
const TTY* tty() const { return m_tty; }
|
const TTY* tty() const { return m_tty; }
|
||||||
|
|
|
@ -167,19 +167,22 @@ void exception_6_handler(RegisterDump& regs)
|
||||||
kprintf("#UD with !current\n");
|
kprintf("#UD with !current\n");
|
||||||
hang();
|
hang();
|
||||||
}
|
}
|
||||||
kprintf("%s invalid opcode: %u(%s)\n", current->process().is_ring0() ? "Kernel" : "Process", current->pid(), current->process().name().characters());
|
|
||||||
|
kprintf("%s Illegal instruction: %s(%u)\n",
|
||||||
|
current->process().is_ring0() ? "Kernel" : "Process",
|
||||||
|
current->process().name().characters(),
|
||||||
|
current->pid()
|
||||||
|
);
|
||||||
|
|
||||||
dump(regs);
|
dump(regs);
|
||||||
|
|
||||||
dump_backtrace();
|
dump_backtrace();
|
||||||
|
|
||||||
if (current->process().is_ring0()) {
|
if (current->process().is_ring0()) {
|
||||||
kprintf("Oh shit, we've crashed in ring 0 :(\n");
|
kprintf("Oh shit, we've crashed in ring 0 :(\n");
|
||||||
hang();
|
hang();
|
||||||
}
|
}
|
||||||
hang();
|
|
||||||
|
|
||||||
current->process().crash();
|
current->process().crash(SIGILL);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 7: FPU not available exception
|
// 7: FPU not available exception
|
||||||
|
@ -216,7 +219,11 @@ void exception_7_handler(RegisterDump& regs)
|
||||||
EH_ENTRY_NO_CODE(0);
|
EH_ENTRY_NO_CODE(0);
|
||||||
void exception_0_handler(RegisterDump& regs)
|
void exception_0_handler(RegisterDump& regs)
|
||||||
{
|
{
|
||||||
kprintf("%s DIVIDE ERROR: %u(%s)\n", current->process().is_ring0() ? "Kernel" : "User", current->pid(), current->process().name().characters());
|
kprintf("%s Division by zero: %s(%u)\n",
|
||||||
|
current->process().is_ring0() ? "Kernel" : "User",
|
||||||
|
current->process().name().characters(),
|
||||||
|
current->pid()
|
||||||
|
);
|
||||||
|
|
||||||
dump(regs);
|
dump(regs);
|
||||||
|
|
||||||
|
@ -225,7 +232,7 @@ void exception_0_handler(RegisterDump& regs)
|
||||||
hang();
|
hang();
|
||||||
}
|
}
|
||||||
|
|
||||||
current->process().crash();
|
current->process().crash(SIGFPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue