Various crash diagnostic improvements.
Register dumps, restore backtraces on Mac OS where possible, Mac demangling,
more comments, logging when using an abort hook, and more selective use of
abort hooks.
Linux:
*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR) fault addr 0xdeadd00d
Registers:
eax: 0x00000000 ebx: 0x5598eff4 ecx: 0x56300000 edx: 0x55992de0
edi: 0x5597e478 esi: 0xfff1f3c8 ebp: 0xfff1f3e8 esp: 0xfff1f390
eip: 0x558a82ff eflags: 0x00010246
cs: 0x00000023 ds: 0x0000002b es: 0x0000002b fs: 0x00000007
gs: 0x00000063 ss: 0x0000002b
Backtrace:
#00 art::Backtrace::Dump(std::ostream&)+0x4c [0x559357ac] (libartd.so)
#01 ??+0x3b73b0 [0x559343b0] (libartd.so)
#02 [0x55573410] (???)
#03 art::LogMessage::~LogMessage()+0x3bd [0x557e2e6d] (libartd.so)
#04 ?? [0x8088941] (dex2oatd)
#05 ?? [0x80898f7] (dex2oatd)
#06 __libc_start_main+0xe6 [0x55b06bd6] (libc.so.6)
#07 ?? [0x8085b31] (dex2oatd)
Mac OS:
*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
Fatal signal 6 (SIGABRT), code 0 (?)
Registers:
eax: 0x00000000 ebx: 0xc008bce0 ecx: 0xc008bc5c edx: 0x906559c6
edi: 0xac0f52c0 esi: 0x00000006 ebp: 0xc008bc78 esp: 0xc008bc5c
eip: 0x906559c6 eflags: 0x00000246
cs: 0x0000000b ds: 0x00000023 es: 0x00000023 fs: 0x0000001f
gs: 0x0000000f ss: 0x00000023
Backtrace:
#00 art::Backtrace::Dump(std::ostream&) + 40 [0x001ce25a] (libartd.dylib)
#01 _ZN3artL22HandleUnexpectedSignalEiP9__siginfoPv + 1051 [0x001cdacb] (libartd.dylib)
#02 _sigtramp + 43 [0x90a4559b] (libsystem_c.dylib)
#03 0x0 + 4294967295 [0xffffffff] (???)
#04 abort + 167 [0x909e0bdd] (libsystem_c.dylib)
#05 art::Runtime::Abort() + 322 [0x00192312] (libartd.dylib)
#06 art::LogMessage::~LogMessage() + 413 [0x00135a6d] (libartd.dylib)
#07 art::dex2oat(int, char**) + 6183 [0x00091927] (dex2oatd)
#08 start + 53 [0x0008fb75] (dex2oatd)
Change-Id: I68d215f09723f236889242cfe8aa8819afea4a60
diff --git a/src/runtime.cc b/src/runtime.cc
index 3f80260..8fe760e 100644
--- a/src/runtime.cc
+++ b/src/runtime.cc
@@ -161,11 +161,15 @@
// Call the abort hook if we have one.
if (Runtime::Current() != NULL && Runtime::Current()->abort_ != NULL) {
+ LOG(INTERNAL_FATAL) << "Calling abort hook...";
Runtime::Current()->abort_();
// notreached
+ LOG(INTERNAL_FATAL) << "Unexpectedly returned from abort hook!";
}
- // If we call abort(3) on a device, all threads in the process
+ // TODO: finish merging patches to fix abort(3) in bionic, then lose this!
+ // Bionic doesn't implement POSIX semantics for abort(3) in a multi-threaded
+ // process, so if we call abort(3) on a device, all threads in the process
// receive SIGABRT. debuggerd dumps the stack trace of the main
// thread, whether or not that was the thread that failed. By
// stuffing a value into a bogus address, we cause a segmentation
@@ -301,7 +305,10 @@
parsed->hook_vfprintf_ = vfprintf;
parsed->hook_exit_ = exit;
- parsed->hook_abort_ = abort;
+ parsed->hook_abort_ = NULL; // We don't call abort(3) by default; see Runtime::Abort.
+#if defined(__APPLE__)
+ parsed->hook_abort_ = abort; // On the Mac, abort(3) gives better results; see Runtime::InitPlatformSignalHandlers.
+#endif
// gLogVerbosity.class_linker = true; // TODO: don't check this in!
// gLogVerbosity.compiler = true; // TODO: don't check this in!