diff options
author | Linus Groh <mail@linusgroh.de> | 2021-01-15 20:29:13 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-01-15 23:26:47 +0100 |
commit | 057ae36e32da6d0d6b4ba5afdf90a31dd6e950fc (patch) | |
tree | 5cf8aa172f0336dd533f457e8979bd70fb2ae009 /Kernel | |
parent | 3718a16f5903ebacaa5043c9dd477251a17f35b6 (diff) | |
download | serenity-057ae36e32da6d0d6b4ba5afdf90a31dd6e950fc.zip |
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.
Diffstat (limited to 'Kernel')
-rw-r--r-- | Kernel/Process.cpp | 7 | ||||
-rw-r--r-- | Kernel/Process.h | 2 |
2 files changed, 9 insertions, 0 deletions
diff --git a/Kernel/Process.cpp b/Kernel/Process.cpp index 3f93912f1a..edc448fb02 100644 --- a/Kernel/Process.cpp +++ b/Kernel/Process.cpp @@ -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(); } diff --git a/Kernel/Process.h b/Kernel/Process.h index d504224ddd..fbc669bd2d 100644 --- a/Kernel/Process.h +++ b/Kernel/Process.h @@ -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; |