Bug 1342564 - Don't crash the process when we fail to open the bloat log draft
authorAlex Gaynor <agaynor@mozilla.com>
Thu, 30 Nov 2017 14:41:00 -0500
changeset 705839 d60bebc469de940ac55807f048a3ecf867750e42
parent 705606 ba283baf4e98aa3a5f45a17981077b98697aa73a
child 742494 e13e9d6522c5b37e103048f57807e7b03e146ffe
push id91619
push userbmo:agaynor@mozilla.com
push dateThu, 30 Nov 2017 20:10:52 +0000
bugs1342564
milestone59.0a1
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
xpcom/base/IntentionalCrash.h
--- 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