diff options
author | Mathieu Chartier <mathieuc@google.com> | 2014-10-15 16:59:47 -0700 |
---|---|---|
committer | Mathieu Chartier <mathieuc@google.com> | 2014-10-16 19:16:41 -0700 |
commit | d000480134b7b00895fbfd142f1d1e18d9cfa6e9 (patch) | |
tree | a9fab808555310308aecda2a59a7c90727ede0ff /runtime/fault_handler.cc | |
parent | d866c7616cb3426c431b635ae69964ce69c2ecb5 (diff) | |
download | art-d000480134b7b00895fbfd142f1d1e18d9cfa6e9.zip art-d000480134b7b00895fbfd142f1d1e18d9cfa6e9.tar.gz art-d000480134b7b00895fbfd142f1d1e18d9cfa6e9.tar.bz2 |
Add way to ensure we are at the front of the sigaction chain
Calling this after jni_on_load fixes the unity apps. This is
not exactly correct since we may already have the following chain.
Start up:
Us -> debuggerd
After app goes in front:
App -> us -> debuggerd
After we put ourself back at the front:
Us -> app -> us -> app -> .... stack overflow.
Bug: 17620677
Change-Id: I9183997e3d5ebd51c320b5d51425be5142e938f3
(cherry picked from commit 1f24296c7c8a6501ee2388c0d20b48f471b48660)
Diffstat (limited to 'runtime/fault_handler.cc')
-rw-r--r-- | runtime/fault_handler.cc | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/runtime/fault_handler.cc b/runtime/fault_handler.cc index fede2f8..62e0609 100644 --- a/runtime/fault_handler.cc +++ b/runtime/fault_handler.cc @@ -95,16 +95,29 @@ FaultManager::FaultManager() : initialized_(false) { FaultManager::~FaultManager() { } +static void SetUpArtAction(struct sigaction* action) { + action->sa_sigaction = art_fault_handler; + sigemptyset(&action->sa_mask); + action->sa_flags = SA_SIGINFO | SA_ONSTACK; +#if !defined(__APPLE__) && !defined(__mips__) + action->sa_restorer = nullptr; +#endif +} + +void FaultManager::EnsureArtActionInFrontOfSignalChain() { + if (initialized_) { + struct sigaction action; + SetUpArtAction(&action); + EnsureFrontOfChain(SIGSEGV, &action); + } else { + LOG(WARNING) << "Can't call " << __FUNCTION__ << " due to unitialized fault manager"; + } +} void FaultManager::Init() { CHECK(!initialized_); struct sigaction action; - action.sa_sigaction = art_fault_handler; - sigemptyset(&action.sa_mask); - action.sa_flags = SA_SIGINFO | SA_ONSTACK; -#if !defined(__APPLE__) && !defined(__mips__) - action.sa_restorer = nullptr; -#endif + SetUpArtAction(&action); // Set our signal handler now. int e = sigaction(SIGSEGV, &action, &oldaction_); @@ -138,7 +151,6 @@ void FaultManager::HandleFault(int sig, siginfo_t* info, void* context) { // // If malloc calls abort, it will be holding its lock. // If the handler tries to call malloc, it will deadlock. - VLOG(signals) << "Handling fault"; if (IsInGeneratedCode(info, context, true)) { VLOG(signals) << "in generated code, looking for handler"; |