From 0c0043d8ccb4309e20ad9ca006abd6968d583cdf Mon Sep 17 00:00:00 2001 From: Lokesh Gidra Date: Thu, 15 Feb 2024 23:10:17 +0000 Subject: Implement noinline SIGBUS hook for debuggers Like in case of SIGSEGV, SIGBUS also needs a noinline hook that debuggers can cling on to if ART doesn't handler the signal. Bug: 324326504 Test: manual Change-Id: Ida6a82095b8a2531c189462a6e51c54598202d50 --- runtime/fault_handler.cc | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'runtime/fault_handler.cc') diff --git a/runtime/fault_handler.cc b/runtime/fault_handler.cc index ccf6fbd288..635de2af69 100644 --- a/runtime/fault_handler.cc +++ b/runtime/fault_handler.cc @@ -42,12 +42,16 @@ namespace art HIDDEN { // Static fault manger object accessed by signal handler. FaultManager fault_manager; -// This needs to be NO_INLINE since some debuggers do not read the inline-info to set a breakpoint -// if it isn't. +// These need to be NO_INLINE since some debuggers do not read the inline-info to set a breakpoint +// if they aren't. extern "C" NO_INLINE __attribute__((visibility("default"))) void art_sigsegv_fault() { // Set a breakpoint here to be informed when a SIGSEGV is unhandled by ART. VLOG(signals)<< "Caught unknown SIGSEGV in ART fault handler - chaining to next handler."; } +extern "C" NO_INLINE __attribute__((visibility("default"))) void art_sigbus_fault() { + // Set a breakpoint here to be informed when a SIGBUS is unhandled by ART. + VLOG(signals) << "Caught unknown SIGBUS in ART fault handler - chaining to next handler."; +} // Signal handler called on SIGSEGV. static bool art_sigsegv_handler(int sig, siginfo_t* info, void* context) { @@ -232,7 +236,13 @@ bool FaultManager::HandleSigbusFault(int sig, siginfo_t* info, [[maybe_unused]] // Simulate a crash in a handler. raise(SIGBUS); #endif - return Runtime::Current()->GetHeap()->MarkCompactCollector()->SigbusHandler(info); + if (Runtime::Current()->GetHeap()->MarkCompactCollector()->SigbusHandler(info)) { + return true; + } + + // Set a breakpoint in this function to catch unhandled signals. + art_sigbus_fault(); + return false; } inline void FaultManager::CheckForUnrecognizedImplicitSuspendCheckInBootImage( -- cgit v1.2.3-59-g8ed1b