diff options
author | 2019-06-12 12:34:26 -0700 | |
---|---|---|
committer | 2019-06-14 18:18:53 +0000 | |
commit | 8764860dcd6e80512885e41717af9d45c574054a (patch) | |
tree | 4bae7374e5b216fa95600d9ba7f8e251fe269d4c | |
parent | 3e2446bbe9326786a970c88bbfac80b8ed8e5cdd (diff) |
ART: Flag Runtime::Abort to the UnexpectedSignal handler
Do not trigger unexpected signal handling for runtime aborts.
Bug: 135056249
Test: m test-art-host
Test: manual
Change-Id: I062c862eb11bb6465c33215a98a74874be0bbf59
-rw-r--r-- | runtime/runtime.cc | 4 | ||||
-rw-r--r-- | runtime/runtime_common.cc | 11 | ||||
-rw-r--r-- | runtime/runtime_common.h | 2 |
3 files changed, 17 insertions, 0 deletions
diff --git a/runtime/runtime.cc b/runtime/runtime.cc index 3ad0504405..cda1fd9d5b 100644 --- a/runtime/runtime.cc +++ b/runtime/runtime.cc @@ -150,6 +150,7 @@ #include "quick/quick_method_frame_info.h" #include "reflection.h" #include "runtime_callbacks.h" +#include "runtime_common.h" #include "runtime_intrinsics.h" #include "runtime_options.h" #include "scoped_thread_state_change-inl.h" @@ -614,6 +615,7 @@ void Runtime::Abort(const char* msg) { if (Thread::Current() == nullptr) { Runtime* current = Runtime::Current(); if (current != nullptr && current->IsStarted() && !current->IsShuttingDown(nullptr)) { + // We do not flag this to the unexpected-signal handler so that that may dump the stack. abort(); UNREACHABLE(); } @@ -648,6 +650,8 @@ void Runtime::Abort(const char* msg) { LOG(FATAL_WITHOUT_ABORT) << msg; } + FlagRuntimeAbort(); + // Call the abort hook if we have one. if (Runtime::Current() != nullptr && Runtime::Current()->abort_ != nullptr) { LOG(FATAL_WITHOUT_ABORT) << "Calling abort hook..."; diff --git a/runtime/runtime_common.cc b/runtime/runtime_common.cc index 5676577696..e5a61c2dc0 100644 --- a/runtime/runtime_common.cc +++ b/runtime/runtime_common.cc @@ -376,6 +376,12 @@ std::string GetFaultMessageForAbortLogging() { return (runtime != nullptr) ? runtime->GetFaultMessage() : ""; } +static std::atomic<bool> gIsRuntimeAbort = false; + +void FlagRuntimeAbort() { + gIsRuntimeAbort = true; +} + static void HandleUnexpectedSignalCommonDump(int signal_number, siginfo_t* info, void* raw_context, @@ -444,6 +450,11 @@ void HandleUnexpectedSignalCommon(int signal_number, void* raw_context, bool handle_timeout_signal, bool dump_on_stderr) { + bool runtime_abort = gIsRuntimeAbort.exchange(false); + if (runtime_abort) { + return; + } + // Local _static_ storing the currently handled signal (or -1). static int handling_unexpected_signal = -1; diff --git a/runtime/runtime_common.h b/runtime/runtime_common.h index 698d0603ee..925594ef29 100644 --- a/runtime/runtime_common.h +++ b/runtime/runtime_common.h @@ -77,6 +77,8 @@ void InitPlatformSignalHandlersCommon(void (*newact)(int, siginfo_t*, void*), struct sigaction* oldact, bool handle_timeout_signal); +void FlagRuntimeAbort(); + } // namespace art #endif // ART_RUNTIME_RUNTIME_COMMON_H_ |