Bug 1357218 - Call SetJitExceptionHandler in child processes too. r=ted, a=gchang
authorDavid Major <dmajor@mozilla.com>
Fri, 21 Apr 2017 20:25:19 -0400
changeset 396052 bc5340535ce2645cb7a4f8bd0b5f576e2cd2406a
parent 396051 b5526172339c2a68e1f9395b4aae7fe250bd6b33
child 396053 64901233ef75b97857c049e6193c06d4cf03de9e
push id1468
push userasasaki@mozilla.com
push dateMon, 05 Jun 2017 19:31:07 +0000
treeherdermozilla-release@0641fc6ee9d1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersted, gchang
bugs1357218
milestone54.0
Bug 1357218 - Call SetJitExceptionHandler in child processes too. r=ted, a=gchang
toolkit/crashreporter/nsExceptionHandler.cpp
--- a/toolkit/crashreporter/nsExceptionHandler.cpp
+++ b/toolkit/crashreporter/nsExceptionHandler.cpp
@@ -367,28 +367,38 @@ patched_SetUnhandledExceptionFilter (LPT
       stub_SetUnhandledExceptionFilter(lpTopLevelExceptionFilter);
     return previousUnhandledExceptionFilter;
   }
 
   // intercept attempts to change the filter
   return nullptr;
 }
 
+#ifdef _WIN64
 static LPTOP_LEVEL_EXCEPTION_FILTER sUnhandledExceptionFilter = nullptr;
 
 static long
 JitExceptionHandler(void *exceptionRecord, void *context)
 {
     EXCEPTION_POINTERS pointers = {
         (PEXCEPTION_RECORD)exceptionRecord,
         (PCONTEXT)context
     };
     return sUnhandledExceptionFilter(&pointers);
 }
 
+static void
+SetJitExceptionHandler()
+{
+  sUnhandledExceptionFilter = GetUnhandledExceptionFilter();
+  if (sUnhandledExceptionFilter)
+      js::SetJitExceptionHandler(JitExceptionHandler);
+}
+#endif
+
 /**
  * Reserve some VM space. In the event that we crash because VM space is
  * being leaked without leaking memory, freeing this space before taking
  * the minidump will allow us to collect a minidump.
  *
  * This size is bigger than xul.dll plus some extra for MinidumpWriteDump
  * allocations.
  */
@@ -1784,19 +1794,17 @@ nsresult SetExceptionHandler(nsIFile* aX
   if (!gExceptionHandler)
     return NS_ERROR_OUT_OF_MEMORY;
 
 #ifdef XP_WIN
   gExceptionHandler->set_handle_debug_exceptions(true);
 
 #ifdef _WIN64
   // Tell JS about the new filter before we disable SetUnhandledExceptionFilter
-  sUnhandledExceptionFilter = GetUnhandledExceptionFilter();
-  if (sUnhandledExceptionFilter)
-      js::SetJitExceptionHandler(JitExceptionHandler);
+  SetJitExceptionHandler();
 #endif
 
   // protect the crash reporter from being unloaded
   gBlockUnhandledExceptionFilter = true;
   gKernel32Intercept.Init("kernel32.dll");
   bool ok = gKernel32Intercept.AddHook("SetUnhandledExceptionFilter",
           reinterpret_cast<intptr_t>(patched_SetUnhandledExceptionFilter),
           (void**) &stub_SetUnhandledExceptionFilter);
@@ -3763,16 +3771,20 @@ SetRemoteExceptionHandler(const nsACStri
                      nullptr,    // no minidump callback
                      nullptr,    // no callback context
                      google_breakpad::ExceptionHandler::HANDLER_ALL,
                      GetMinidumpType(),
                      NS_ConvertASCIItoUTF16(crashPipe).get(),
                      nullptr);
   gExceptionHandler->set_handle_debug_exceptions(true);
 
+#ifdef _WIN64
+  SetJitExceptionHandler();
+#endif
+
   mozalloc_set_oom_abort_handler(AnnotateOOMAllocationSize);
 
   oldTerminateHandler = std::set_terminate(&TerminateHandler);
 
   // we either do remote or nothing, no fallback to regular crash reporting
   return gExceptionHandler->IsOutOfProcess();
 }