Kernel: Prevent threads from being destructed between die() and finalize()

Killing remaining threads already happens in Process::die(), but
coredumps are only written in Process::finalize(). We need to keep a
reference to each of those threads to prevent them from being destructed
between those two functions, otherwise coredumps will only ever contain
information about the last remaining thread.

Fixes the underlying problem of #4778, though the UI will need
refinements to not show every thread's backtrace mashed together.
This commit is contained in:
Linus Groh 2021-01-15 20:29:13 +01:00 committed by Andreas Kling
parent 3718a16f59
commit 057ae36e32
Notes: sideshowbarker 2024-07-18 23:47:38 +09:00
2 changed files with 9 additions and 0 deletions

View File

@ -631,6 +631,8 @@ void Process::finalize()
dump_perfcore();
}
m_threads_for_coredump.clear();
if (m_alarm_timer)
TimerQueue::the().cancel_timer(m_alarm_timer.release_nonnull());
m_fds.clear();
@ -695,6 +697,11 @@ void Process::die()
// slave owner, we have to allow the PTY pair to be torn down.
m_tty = nullptr;
for_each_thread([&](auto& thread) {
m_threads_for_coredump.append(&thread);
return IterationDecision::Continue;
});
kill_all_threads();
}

View File

@ -663,6 +663,8 @@ private:
Thread::WaitBlockCondition m_wait_block_condition;
HashMap<String, String> m_coredump_metadata;
Vector<RefPtr<Thread>> m_threads_for_coredump;
};
extern InlineLinkedList<Process>* g_processes;