Commit 4dbb557b authored by David Parks's avatar David Parks
Browse files

Bug 1770721: Clear Windows exception handler later in shutdown r=gsvelto a=pascalc

We want to clear this as late as possible to get the most accurate crash reporting.  In particular, we should clear it after ProcessRuntime is destroyed as its destructor does a lot of work and could lead to hangs that may still be processed by the Shutdown Hang Terminator.

Differential Revision: https://phabricator.services.mozilla.com/D147524
parent 62ee2d3d
Loading
Loading
Loading
Loading
+9 −3
Original line number Diff line number Diff line
@@ -5876,6 +5876,15 @@ int XREMain::XRE_main(int argc, char* argv[], const BootstrapConfig& aConfig) {
  mAppData->sandboxPermissionsService = aConfig.sandboxPermissionsService;
#endif

  // Once we unset the exception handler, we lose the ability to properly
  // detect hangs -- they show up as crashes.  We do this as late as possible.
  // In particular, after ProcessRuntime is destroyed on Windows.
  auto unsetExceptionHandler = MakeScopeExit([&] {
    if (mAppData->flags & NS_XRE_ENABLE_CRASH_REPORTER)
      return CrashReporter::UnsetExceptionHandler();
    return NS_OK;
  });

  mozilla::IOInterposerInit ioInterposerGuard;

#if defined(XP_WIN)
@@ -5964,9 +5973,6 @@ int XREMain::XRE_main(int argc, char* argv[], const BootstrapConfig& aConfig) {
  }
#endif

  if (mAppData->flags & NS_XRE_ENABLE_CRASH_REPORTER)
    CrashReporter::UnsetExceptionHandler();

  XRE_DeinitCommandLine();

  if (NS_FAILED(rv)) {