Title: [229338] trunk/Source/WTF
Revision
229338
Author
commit-qu...@webkit.org
Date
2018-03-06 12:53:52 -0800 (Tue, 06 Mar 2018)

Log Message

Unreviewed, rolling out r229330.
https://bugs.webkit.org/show_bug.cgi?id=183379

Broke some Apple internal code (Requested by ap on #webkit).

Reverted changeset:

"Remove unused crash hook functionality"
https://bugs.webkit.org/show_bug.cgi?id=183369
https://trac.webkit.org/changeset/229330

Modified Paths

Diff

Modified: trunk/Source/WTF/ChangeLog (229337 => 229338)


--- trunk/Source/WTF/ChangeLog	2018-03-06 20:47:36 UTC (rev 229337)
+++ trunk/Source/WTF/ChangeLog	2018-03-06 20:53:52 UTC (rev 229338)
@@ -1,3 +1,16 @@
+2018-03-06  Commit Queue  <commit-qu...@webkit.org>
+
+        Unreviewed, rolling out r229330.
+        https://bugs.webkit.org/show_bug.cgi?id=183379
+
+        Broke some Apple internal code (Requested by ap on #webkit).
+
+        Reverted changeset:
+
+        "Remove unused crash hook functionality"
+        https://bugs.webkit.org/show_bug.cgi?id=183369
+        https://trac.webkit.org/changeset/229330
+
 2018-03-06  Michael Catanzaro  <mcatanz...@igalia.com>
 
         Remove unused crash hook functionality

Modified: trunk/Source/WTF/wtf/Assertions.cpp (229337 => 229338)


--- trunk/Source/WTF/wtf/Assertions.cpp	2018-03-06 20:47:36 UTC (rev 229337)
+++ trunk/Source/WTF/wtf/Assertions.cpp	2018-03-06 20:53:52 UTC (rev 229338)
@@ -251,9 +251,19 @@
     out.print(stackTrace);
 }
 
+static WTFCrashHookFunction globalHook = 0;
+
+void WTFSetCrashHook(WTFCrashHookFunction function)
+{
+    globalHook = function;
+}
+
 #if !defined(NDEBUG) || !OS(DARWIN)
 void WTFCrash()
 {
+    if (globalHook)
+        globalHook();
+
     WTFReportBacktrace();
 #if ASAN_ENABLED
     __builtin_trap();
@@ -282,6 +292,42 @@
     CRASH();
 }
 
+#if HAVE(SIGNAL_H)
+static NO_RETURN void dumpBacktraceSignalHandler(int sig)
+{
+    WTFReportBacktrace();
+    exit(128 + sig);
+}
+
+static void installSignalHandlersForFatalErrors(void (*handler)(int))
+{
+    signal(SIGILL, handler); //    4: illegal instruction (not reset when caught).
+    signal(SIGTRAP, handler); //   5: trace trap (not reset when caught).
+    signal(SIGFPE, handler); //    8: floating point exception.
+    signal(SIGBUS, handler); //   10: bus error.
+    signal(SIGSEGV, handler); //  11: segmentation violation.
+    signal(SIGSYS, handler); //   12: bad argument to system call.
+    signal(SIGPIPE, handler); //  13: write on a pipe with no reader.
+    signal(SIGXCPU, handler); //  24: exceeded CPU time limit.
+    signal(SIGXFSZ, handler); //  25: exceeded file size limit.
+}
+
+static void resetSignalHandlersForFatalErrors()
+{
+    installSignalHandlersForFatalErrors(SIG_DFL);
+}
+#endif
+
+void WTFInstallReportBacktraceOnCrashHook()
+{
+#if HAVE(SIGNAL_H)
+    // Needed otherwise we are going to dump the stack trace twice
+    // in case we hit an assertion.
+    WTFSetCrashHook(&resetSignalHandlersForFatalErrors);
+    installSignalHandlersForFatalErrors(&dumpBacktraceSignalHandler);
+#endif
+}
+
 bool WTFIsDebuggerAttached()
 {
 #if OS(DARWIN)

Modified: trunk/Source/WTF/wtf/Assertions.h (229337 => 229338)


--- trunk/Source/WTF/wtf/Assertions.h	2018-03-06 20:47:36 UTC (rev 229337)
+++ trunk/Source/WTF/wtf/Assertions.h	2018-03-06 20:53:52 UTC (rev 229338)
@@ -200,6 +200,10 @@
 WTF_EXPORT_PRIVATE void WTFReportBacktrace(void);
 WTF_EXPORT_PRIVATE void WTFPrintBacktrace(void** stack, int size);
 
+typedef void (*WTFCrashHookFunction)(void);
+WTF_EXPORT_PRIVATE void WTFSetCrashHook(WTFCrashHookFunction);
+WTF_EXPORT_PRIVATE void WTFInstallReportBacktraceOnCrashHook(void);
+
 WTF_EXPORT_PRIVATE bool WTFIsDebuggerAttached(void);
 
 #if ASAN_ENABLED
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to