Bug 1342564 - Don't crash the process when we fail to open the bloat log
NoteIntentionalCrash is supposed to leave a marker that a process has crashed
intentionally, but if it can't open the target file it will crash the process
itself. This can cause difficulty debugging and false-positive results for
tests expecting crashes.
MozReview-Commit-ID: CgLauJIEAKD
--- a/xpcom/base/IntentionalCrash.h
+++ b/xpcom/base/IntentionalCrash.h
@@ -44,15 +44,17 @@ NoteIntentionalCrash(const char* aProces
bloatName << bloatLog << "_" << aProcessType << "_pid" << getpid();
if (hasExt) {
bloatName << ".log";
}
fprintf(stderr, "Writing to log: %s\n", bloatName.str().c_str());
FILE* processfd = fopen(bloatName.str().c_str(), "a");
- fprintf(processfd, "==> process %d will purposefully crash\n", getpid());
- fclose(processfd);
+ if (processfd) {
+ fprintf(processfd, "==> process %d will purposefully crash\n", getpid());
+ fclose(processfd);
+ }
}
} // namespace mozilla
#endif // mozilla_IntentionalCrash_h