Commit dfc58833 authored by Mike Hommey's avatar Mike Hommey
Browse files

Bug 1496503 - Install the rust panic hook early. r=froydnj

Previously, our panic hook was only really useful when the crash
reporter is used, because all it did apart from calling rust's default
panic handler was to keep a pointer to the panic message for the crash
reporter.

Now that it just redirects to the Gecko crash code, it doesn't need to
be tied to the crash reporter. In fact, to ensure it's consistently used
in all cases, we ought to install it early on. Use a static initializer
for that.

Depends on D11720

Differential Revision: https://phabricator.services.mozilla.com/D11721

--HG--
extra : moz-landing-system : lando
parent 38dc94b5
Loading
Loading
Loading
Loading
+0 −8
Original line number Diff line number Diff line
@@ -120,7 +120,6 @@ using mozilla::ipc::CrashReporterClient;

// From toolkit/library/rust/shared/lib.rs
extern "C" {
  void install_rust_panic_hook();
  void install_rust_oom_hook();
}

@@ -1737,7 +1736,6 @@ nsresult SetExceptionHandler(nsIFile* aXREDirectory,

  oldTerminateHandler = std::set_terminate(&TerminateHandler);

  install_rust_panic_hook();
  install_rust_oom_hook();

  InitThreadAnnotation();
@@ -3602,8 +3600,6 @@ SetRemoteExceptionHandler(const nsACString& crashPipe,

  oldTerminateHandler = std::set_terminate(&TerminateHandler);

  install_rust_panic_hook();

  // we either do remote or nothing, no fallback to regular crash reporting
  return gExceptionHandler->IsOutOfProcess();
}
@@ -3650,8 +3646,6 @@ SetRemoteExceptionHandler()

  oldTerminateHandler = std::set_terminate(&TerminateHandler);

  install_rust_panic_hook();

  // we either do remote or nothing, no fallback to regular crash reporting
  return gExceptionHandler->IsOutOfProcess();
}
@@ -3680,8 +3674,6 @@ SetRemoteExceptionHandler(const nsACString& crashPipe)

  oldTerminateHandler = std::set_terminate(&TerminateHandler);

  install_rust_panic_hook();

  // we either do remote or nothing, no fallback to regular crash reporting
  return gExceptionHandler->IsOutOfProcess();
}
+11 −0
Original line number Diff line number Diff line
@@ -5338,6 +5338,17 @@ GeckoCrashOOL(const char* aFilename, int aLine, const char* aReason) {
  MOZ_CrashOOL(aFilename, aLine, aReason);
}

// From toolkit/library/rust/shared/lib.rs
extern "C" void install_rust_panic_hook();

struct InstallRustPanicHook {
  InstallRustPanicHook() {
    install_rust_panic_hook();
  }
};

InstallRustPanicHook sInstallRustPanicHook;

#ifdef MOZ_ASAN_REPORTER
void setASanReporterPath(nsIFile* aDir) {
  nsCOMPtr<nsIFile> dir;