diff options
author | Adam Harrison <adamharrison@google.com> | 2018-02-02 11:14:00 -0800 |
---|---|---|
committer | Mark Mentovai <mark@chromium.org> | 2018-02-02 20:18:46 +0000 |
commit | 6bb6c9b26afd9844b9e35fcaa39fb24893e7abb5 (patch) | |
tree | 0d5abb76e392a6b1d2210a40f0b07cc135973e08 /src/client | |
parent | Extend ifdef to include helper functions (diff) | |
download | breakpad-6bb6c9b26afd9844b9e35fcaa39fb24893e7abb5.tar.xz |
Fix crash when an NSException is thrown.
old_handlers is zeroish whenever an NSException is thrown. This caused PROT_WRITE to never be set and resulted in an EXC_BAD_ACCESS when trying to set the handler to NULL.
Change-Id: Ibb7da448204431c7602b1001f3a5216303c4c9d1
Reviewed-on: https://chromium-review.googlesource.com/899907
Reviewed-by: Mark Mentovai <mark@chromium.org>
Diffstat (limited to 'src/client')
-rw-r--r-- | src/client/ios/Breakpad.mm | 2 | ||||
-rw-r--r-- | src/client/ios/exception_handler_no_mach.cc | 19 |
2 files changed, 10 insertions, 11 deletions
diff --git a/src/client/ios/Breakpad.mm b/src/client/ios/Breakpad.mm index 3dd44a24..c2a4202a 100644 --- a/src/client/ios/Breakpad.mm +++ b/src/client/ios/Breakpad.mm @@ -50,7 +50,7 @@ #if !TARGET_OS_TV && !TARGET_OS_WATCH #import "client/mac/handler/exception_handler.h" #else -#import "client/ios/handler/exception_handler_no_mach.h" +#import "client/ios/exception_handler_no_mach.h" #endif // !TARGET_OS_TV && !TARGET_OS_WATCH #if !defined(__EXCEPTIONS) || (__clang__ && !__has_feature(cxx_exceptions)) diff --git a/src/client/ios/exception_handler_no_mach.cc b/src/client/ios/exception_handler_no_mach.cc index 23f246e9..aa8489d7 100644 --- a/src/client/ios/exception_handler_no_mach.cc +++ b/src/client/ios/exception_handler_no_mach.cc @@ -31,7 +31,7 @@ #include <TargetConditionals.h> #include "client/mac/handler/minidump_generator.h" -#include "client/ios/handler/exception_handler_no_mach.h" +#include "client/ios/exception_handler_no_mach.h" #ifndef USE_PROTECTED_ALLOCATIONS #if TARGET_OS_TV @@ -200,8 +200,6 @@ bool ExceptionHandler::InstallHandlers() { // If a handler is already installed, something is really wrong. if (gProtectedData.handler != NULL) { return false; - } - gProtectedData.handler = this; for (int i = 0; i < kNumHandledSignals; ++i) { struct sigaction sa; memset(&sa, 0, sizeof(sa)); @@ -213,11 +211,12 @@ bool ExceptionHandler::InstallHandlers() { if (sigaction(kExceptionSignals[i], &sa, old_handlers[i].get()) == -1) { return false; } + } + gProtectedData.handler = this; #if USE_PROTECTED_ALLOCATIONS - assert(((size_t)(gProtectedData.protected_buffer) & PAGE_MASK) == 0); - mprotect(gProtectedData.protected_buffer, PAGE_SIZE, PROT_READ); + assert(((size_t)(gProtectedData.protected_buffer) & PAGE_MASK) == 0); + mprotect(gProtectedData.protected_buffer, PAGE_SIZE, PROT_READ); #endif // USE_PROTECTED_ALLOCATIONS - } installed_exception_handler_ = true; return true; } @@ -226,13 +225,13 @@ bool ExceptionHandler::UninstallHandlers() { for (int i = 0; i < kNumHandledSignals; ++i) { if (old_handlers[i].get()) { sigaction(kExceptionSignals[i], old_handlers[i].get(), NULL); -#if USE_PROTECTED_ALLOCATIONS - mprotect(gProtectedData.protected_buffer, PAGE_SIZE, PROT_READ | PROT_WRITE); -#endif // USE_PROTECTED_ALLOCATIONS old_handlers[i].reset(); } - gProtectedData.handler = NULL; } +#if USE_PROTECTED_ALLOCATIONS + mprotect(gProtectedData.protected_buffer, PAGE_SIZE, PROT_READ | PROT_WRITE); +#endif // USE_PROTECTED_ALLOCATIONS + gProtectedData.handler = NULL; installed_exception_handler_ = false; return true; } |