From a7d7eb6d2ae98e1147af678cf7e78ce4ff83e529 Mon Sep 17 00:00:00 2001 From: Josh Gao Date: Tue, 7 Feb 2017 13:13:48 -0800 Subject: [PATCH 1/3] debuggerd_test: fix crasher path. https://android-review.googlesource.com/#/c/331200 moved crasher to using soong, which changed its location from /system/xbin/crasher to /system/bin/crasher. Bug: http://b/35100742 Test: /data/nativetest/debuggerd_test/debuggerd_test32 Test: /data/nativetest64/debuggerd_test/debuggerd_test64 Change-Id: I16a2050b257277023773cc0c960b5ab36e0c7cd4 --- debuggerd/debuggerd_test.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/debuggerd/debuggerd_test.cpp b/debuggerd/debuggerd_test.cpp index e7503e97e..8e38d0dc2 100644 --- a/debuggerd/debuggerd_test.cpp +++ b/debuggerd/debuggerd_test.cpp @@ -40,10 +40,10 @@ using namespace std::chrono_literals; using android::base::unique_fd; #if defined(__LP64__) -#define CRASHER_PATH "/system/xbin/crasher64" +#define CRASHER_PATH "/system/bin/crasher64" #define ARCH_SUFFIX "64" #else -#define CRASHER_PATH "/system/xbin/crasher" +#define CRASHER_PATH "/system/bin/crasher" #define ARCH_SUFFIX "" #endif From 7a0ee64f9df226012d19cd50ed93117d03cbb01d Mon Sep 17 00:00:00 2001 From: Josh Gao Date: Tue, 7 Feb 2017 13:31:25 -0800 Subject: [PATCH 2/3] debuggerd_test: improve error when crasher fails to exec. Bug: http://b/35100742 Test: rm /system/bin/crasher && /data/nativetest/debugerd_test/debuggerd_test32 Change-Id: I02faec3b7f7ef62bb8a2ac2af730506e3d28e03e --- debuggerd/debuggerd_test.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/debuggerd/debuggerd_test.cpp b/debuggerd/debuggerd_test.cpp index 8e38d0dc2..002e940d9 100644 --- a/debuggerd/debuggerd_test.cpp +++ b/debuggerd/debuggerd_test.cpp @@ -192,7 +192,7 @@ void CrasherTest::StartCrasher(const std::string& crash_type) { std::string type = "wait-" + crash_type; StartProcess([type]() { execl(CRASHER_PATH, CRASHER_PATH, type.c_str(), nullptr); - err(1, "exec failed"); + exit(errno); }); } @@ -216,7 +216,9 @@ void CrasherTest::AssertDeath(int signo) { FAIL() << "failed to wait for crasher: " << strerror(errno); } - if (!WIFSIGNALED(status)) { + if (WIFEXITED(status)) { + FAIL() << "crasher failed to exec: " << strerror(WEXITSTATUS(status)); + } else if (!WIFSIGNALED(status)) { FAIL() << "crasher didn't terminate via a signal"; } ASSERT_EQ(signo, WTERMSIG(status)); From c24cc8a9e51d53aa7a2a7c0af3189abe2364dcc7 Mon Sep 17 00:00:00 2001 From: Josh Gao Date: Tue, 7 Feb 2017 13:28:36 -0800 Subject: [PATCH 3/3] crash_dump: collect open files before dropping caps. /proc//fd is also limited by ptrace_may_access. Test: manual inspection of "debuggerd -b `pidof zygote`" Change-Id: I1a28c21c0438fe8729bd8e041c6b418d6a84c586 --- debuggerd/crash_dump.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/debuggerd/crash_dump.cpp b/debuggerd/crash_dump.cpp index 4e083aec0..288935611 100644 --- a/debuggerd/crash_dump.cpp +++ b/debuggerd/crash_dump.cpp @@ -363,6 +363,12 @@ int main(int argc, char** argv) { LOG(FATAL) << "failed to create backtrace map"; } + // Collect the list of open files. + OpenFilesList open_files; + if (!backtrace) { + populate_open_files_list(target, &open_files); + } + // Drop our capabilities now that we've attached to the threads we care about. drop_capabilities(); @@ -375,10 +381,6 @@ int main(int argc, char** argv) { if (backtrace) { dump_backtrace(output_fd.get(), backtrace_map.get(), target, main_tid, attached_siblings, 0); } else { - // Collect the list of open files. - OpenFilesList open_files; - populate_open_files_list(target, &open_files); - engrave_tombstone(output_fd.get(), backtrace_map.get(), open_files, target, main_tid, attached_siblings, abort_address, fatal_signal ? &amfd_data : nullptr); }