Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(41)

Unified Diff: chrome/app/breakpad_mac.mm

Issue 11645055: [Mac] Override abort() to crash into breakpad. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: tweak comment and signal mask. Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/app/breakpad_mac.mm
diff --git a/chrome/app/breakpad_mac.mm b/chrome/app/breakpad_mac.mm
index 3838f6337389333de6e0df339341097b35878a6d..dff0e33c26b87ded1558bfd5d1a74846e8a2bcec 100644
--- a/chrome/app/breakpad_mac.mm
+++ b/chrome/app/breakpad_mac.mm
@@ -138,6 +138,24 @@ class DumpHelper : public base::PlatformThread::Delegate {
DISALLOW_COPY_AND_ASSIGN(DumpHelper);
};
+void SIGABRTHandler(int signal) {
+ // The OSX abort() (link below) masks all signals for the process,
+ // and all except SIGABRT for the thread. SIGABRT will be masked
+ // when the SIGABRT is sent, which means at this point only SIGKILL
+ // and SIGSTOP can be delivered. Unmask others so that the code
+ // below crashes as desired.
+ //
+ // http://www.opensource.apple.com/source/Libc/Libc-825.26/stdlib/FreeBSD/abort.c
+ sigset_t mask;
+ sigemptyset(&mask);
+ sigaddset(&mask, signal);
+ pthread_sigmask(SIG_SETMASK, &mask, NULL);
+
+ // Most interesting operations are not safe in a signal handler, just crash.
+ char* volatile death_ptr = NULL;
+ *death_ptr = '!';
+}
+
} // namespace
bool IsCrashReporterEnabled() {
@@ -274,6 +292,14 @@ void InitCrashReporter() {
logging::SetLogMessageHandler(&FatalMessageHandler);
logging::SetDumpWithoutCrashingFunction(&DumpHelper::DumpWithoutCrashing);
+
+ // abort() sends SIGABRT, which breakpad does not intercept.
+ // Register a signal handler to crash in a way breakpad will
+ // intercept.
Nico 2013/05/23 21:27:50 Why doesn't breakpad do that?
Scott Hess - ex-Googler 2013/05/23 21:32:59 One day on the bug, Mark said "Mac Breakpad doesn’
+ struct sigaction sigact;
+ memset(&sigact, 0, sizeof(sigact));
+ sigact.sa_handler = SIGABRTHandler;
+ CHECK(0 == sigaction(SIGABRT, &sigact, NULL));
}
void InitCrashProcessInfo() {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698