diff options
author | Christopher Ferris <cferris@google.com> | 2022-05-24 17:08:33 -0700 |
---|---|---|
committer | Christopher Ferris <cferris@google.com> | 2022-05-24 21:31:03 -0700 |
commit | 2d5d46ca85889743055e748a9545f7009b92bb4a (patch) | |
tree | 1a2f30dc86eacb98df4233e71caca251638a8c9f | |
parent | b8620599722589d5c9a898dff909804295c4097f (diff) | |
download | core-2d5d46ca85889743055e748a9545f7009b92bb4a.tar.gz |
Fix check for thread unwind.
If a process requires executing fallback unwinder and the thread
crashing is not the main thread, the wrong unwinder is used.
Fix this case, and add a new unit test that causes an abort in
the non main thread.
Bug: 233721755
Test: New unit test passes with fix and fails without.
Test: Ran debuggerd on swcodec process and it still dumps all threads.
Change-Id: I70fffc5d680256ce867e7a1d427593b584259160
-rw-r--r-- | debuggerd/debuggerd_test.cpp | 23 | ||||
-rw-r--r-- | debuggerd/libdebuggerd/tombstone_proto.cpp | 2 |
2 files changed, 24 insertions, 1 deletions
diff --git a/debuggerd/debuggerd_test.cpp b/debuggerd/debuggerd_test.cpp index f4ba34790..e11330819 100644 --- a/debuggerd/debuggerd_test.cpp +++ b/debuggerd/debuggerd_test.cpp @@ -1463,6 +1463,29 @@ TEST_F(CrasherTest, seccomp_tombstone) { ASSERT_BACKTRACE_FRAME(result, "bar"); } +TEST_F(CrasherTest, seccomp_tombstone_thread_abort) { + int intercept_result; + unique_fd output_fd; + + static const auto dump_type = kDebuggerdTombstone; + StartProcess( + []() { + std::thread abort_thread([] { abort(); }); + abort_thread.join(); + }, + &seccomp_fork); + + StartIntercept(&output_fd, dump_type); + FinishCrasher(); + AssertDeath(SIGABRT); + FinishIntercept(&intercept_result); + ASSERT_EQ(1, intercept_result) << "tombstoned reported failure"; + + std::string result; + ConsumeFd(std::move(output_fd), &result); + ASSERT_BACKTRACE_FRAME(result, "abort"); +} + TEST_F(CrasherTest, seccomp_backtrace) { int intercept_result; unique_fd output_fd; diff --git a/debuggerd/libdebuggerd/tombstone_proto.cpp b/debuggerd/libdebuggerd/tombstone_proto.cpp index bee4a67c9..bd05837a5 100644 --- a/debuggerd/libdebuggerd/tombstone_proto.cpp +++ b/debuggerd/libdebuggerd/tombstone_proto.cpp @@ -455,7 +455,7 @@ static void dump_thread(Tombstone* tombstone, unwindstack::Unwinder* unwinder, thread.set_tagged_addr_ctrl(thread_info.tagged_addr_ctrl); thread.set_pac_enabled_keys(thread_info.pac_enabled_keys); - if (thread_info.pid == getpid() && thread_info.pid != thread_info.tid) { + if (thread_info.registers == nullptr) { // Fallback path for non-main thread, doing unwind from running process. unwindstack::ThreadUnwinder thread_unwinder(kMaxFrames, unwinder->GetMaps()); if (!thread_unwinder.Init()) { |