Catch unexpected exits in DumpRenderTree
authorap@apple.com <ap@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 27 Apr 2015 23:34:06 +0000 (23:34 +0000)
committerap@apple.com <ap@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 27 Apr 2015 23:34:06 +0000 (23:34 +0000)
https://bugs.webkit.org/show_bug.cgi?id=144288

Reviewed by Tim Horton.

* DumpRenderTree/mac/DumpRenderTree.mm:
(atexitFunction):
(DumpRenderTreeMain):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@183435 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Tools/ChangeLog
Tools/DumpRenderTree/mac/DumpRenderTree.mm

index eb27a5d..ac07b43 100644 (file)
@@ -1,5 +1,16 @@
 2015-04-27  Alexey Proskuryakov  <ap@apple.com>
 
+        Catch unexpected exits in DumpRenderTree
+        https://bugs.webkit.org/show_bug.cgi?id=144288
+
+        Reviewed by Tim Horton.
+
+        * DumpRenderTree/mac/DumpRenderTree.mm:
+        (atexitFunction):
+        (DumpRenderTreeMain):
+
+2015-04-27  Alexey Proskuryakov  <ap@apple.com>
+
         Build fix
 
         * DumpRenderTree/mac/AccessibilityNotificationHandler.mm:
index 6c6d78b..e553c9c 100644 (file)
@@ -1343,8 +1343,21 @@ static const char **_argv;
 @end
 #endif
 
+static bool returningFromMain = false;
+
+void atexitFunction()
+{
+    if (returningFromMain)
+        return;
+
+    NSLog(@"DumpRenderTree is exiting unexpectedly. Generating a crash log.");
+    __builtin_trap();
+}
+
 int DumpRenderTreeMain(int argc, const char *argv[])
 {
+    atexit(atexitFunction);
+
 #if PLATFORM(IOS)
     _UIApplicationLoadWebKit();
 #endif
@@ -1366,6 +1379,7 @@ int DumpRenderTreeMain(int argc, const char *argv[])
     if (JSC::Options::logHeapStatisticsAtExit())
         JSC::HeapStatistics::reportSuccess();
     [pool release];
+    returningFromMain = true;
     return 0;
 }