mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-30 00:01:50 +00:00
Bug 1278325 - Hook exit to catch early 3rd party exits in crash reports. r=ted
MozReview-Commit-ID: 6x6DLcqqkAe --HG-- extra : rebase_source : 658ec6d15a23aa731a5a89d805dc38b2c9075c04
This commit is contained in:
parent
7e5c0a3c0d
commit
28e74a12c1
@ -12,12 +12,13 @@
|
||||
#include "mozilla/ChaosMode.h"
|
||||
#include "mozilla/IOInterposer.h"
|
||||
#include "mozilla/Likely.h"
|
||||
#include "mozilla/MemoryChecking.h"
|
||||
#include "mozilla/Poison.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "mozilla/ScopeExit.h"
|
||||
#include "mozilla/Services.h"
|
||||
#include "mozilla/ServoBindings.h"
|
||||
#include "mozilla/Telemetry.h"
|
||||
#include "mozilla/MemoryChecking.h"
|
||||
|
||||
#include "nsAppRunner.h"
|
||||
#include "mozilla/AppData.h"
|
||||
@ -378,6 +379,25 @@ strimatch(const char* lowerstr, const char* mixedstr)
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool gIsExpectedExit = false;
|
||||
|
||||
void MozExpectedExit() {
|
||||
gIsExpectedExit = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs atexit() to catch unexpected exit from 3rd party libraries like the
|
||||
* Intel graphics driver calling exit in an error condition. When they
|
||||
* call exit() to report an error we won't shutdown correctly and wont catch
|
||||
* the issue with our crash reporter.
|
||||
*/
|
||||
static void UnexpectedExit() {
|
||||
if (!gIsExpectedExit) {
|
||||
gIsExpectedExit = true; // Don't risk re-entrency issues when crashing.
|
||||
MOZ_CRASH("Exit called by third party code.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Output a string to the user. This method is really only meant to be used to
|
||||
* output last-ditch error messages designed for developers NOT END USERS.
|
||||
@ -3018,6 +3038,11 @@ XREMain::XRE_mainInit(bool* aExitFlag)
|
||||
return 1;
|
||||
*aExitFlag = false;
|
||||
|
||||
atexit(UnexpectedExit);
|
||||
auto expectedShutdown = mozilla::MakeScopeExit([&] {
|
||||
MozExpectedExit();
|
||||
});
|
||||
|
||||
StartupTimeline::Record(StartupTimeline::MAIN);
|
||||
|
||||
if (PR_GetEnv("MOZ_CHAOSMODE")) {
|
||||
|
@ -97,6 +97,13 @@ WriteConsoleLog();
|
||||
void
|
||||
OverrideDefaultLocaleIfNeeded();
|
||||
|
||||
/**
|
||||
* Allow exit() calls to complete. This should be done from a proper Gecko
|
||||
* shutdown path. Otherwise we aim to catch improper shutdowns.
|
||||
*/
|
||||
void
|
||||
MozExpectedExit();
|
||||
|
||||
#ifdef XP_WIN
|
||||
void
|
||||
UseParentConsole();
|
||||
|
@ -472,6 +472,7 @@ nsNativeAppSupportUnix::Start(bool *aRetVal)
|
||||
MIN_GTK_MINOR_VERSION);
|
||||
gtk_dialog_run(GTK_DIALOG(versionErrDialog));
|
||||
gtk_widget_destroy(versionErrDialog);
|
||||
MozExpectedExit();
|
||||
exit(0);
|
||||
}
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user