1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 05:48:12 +00:00

Kernel: For signal-killed threads, dump backtrace from finalizer thread

Instead of dumping the dying thread's backtrace in the signal handling
code, wait until we're finalizing the thread. Since signalling happens
during scheduling, the less work we do there the better.

Basically the less that happens during a scheduler pass the better. :^)
This commit is contained in:
Andreas Kling 2019-08-06 19:43:07 +02:00
parent 73c998dbfc
commit 83fdad25ed
2 changed files with 17 additions and 5 deletions

View file

@ -171,6 +171,9 @@ void Thread::finalize()
dbgprintf("Finalizing Thread %u in %s(%u)\n", tid(), m_process.name().characters(), pid());
set_state(Thread::State::Dead);
if (m_dump_backtrace_on_finalization)
dbg() << backtrace_impl();
if (this == &m_process.main_thread()) {
m_process.finalize();
return;
@ -337,11 +340,11 @@ ShouldUnblockThread Thread::dispatch_signal(u8 signal)
case DefaultSignalAction::Stop:
set_state(Stopped);
return ShouldUnblockThread::No;
case DefaultSignalAction::DumpCore: {
ProcessInspectionHandle handle(process());
dbg() << "Dumping \"Core\" for " << process();
dbg() << process().backtrace(handle);
}
case DefaultSignalAction::DumpCore:
process().for_each_thread([](auto& thread) {
thread.set_dump_backtrace_on_finalization();
return IterationDecision::Continue;
});
[[fallthrough]];
case DefaultSignalAction::Terminate:
m_process.terminate_due_to_signal(signal);
@ -568,6 +571,11 @@ void Thread::set_state(State new_state)
}
String Thread::backtrace(ProcessInspectionHandle&) const
{
return backtrace_impl();
}
String Thread::backtrace_impl() const
{
auto& process = const_cast<Process&>(this->process());
ProcessPagingScope paging_scope(process);