Bug 1596244 - Report a fake leak instead of crashing if NSS fails to shut down. r=froydnj,keeler
authorAndrew McCreight <continuation@gmail.com>
Thu, 14 Nov 2019 14:51:53 +0000
changeset 501941 23293a56f4790a29a30f35739c4ad72c60d74ff2
parent 501940 8b7a0fc358f3fc42fc639baff2aa43a60797be66
child 501942 14095bfec9dfb56a7e51983b196ce554e0c3eedf
push id114172
push userdluca@mozilla.com
push dateTue, 19 Nov 2019 11:31:10 +0000
treeherdermozilla-inbound@b5c5ba07d3db [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj, keeler
bugs1596244
milestone72.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1596244 - Report a fake leak instead of crashing if NSS fails to shut down. r=froydnj,keeler Some kinds of leaks prevent NSS to not shut down properly, and right now if that happens we crash. This interferes with our existing leak checking code, so in this patch I make it not crash if we are already leak checking. The failure is reported as a fake leak, so the test should still fail when testing. Differential Revision: https://phabricator.services.mozilla.com/D52914
xpcom/build/XPCOMInit.cpp
--- a/xpcom/build/XPCOMInit.cpp
+++ b/xpcom/build/XPCOMInit.cpp
@@ -738,25 +738,32 @@ nsresult ShutdownXPCOM(nsIServiceManager
   // down, any remaining objects that could be holding NSS resources (should)
   // have been released, so we can safely shut down NSS.
   if (NSS_IsInitialized()) {
     SSL_ClearSessionCache();
     if (NSS_Shutdown() != SECSuccess) {
       // If you're seeing this crash and/or warning, some NSS resources are
       // still in use (see bugs 1417680 and 1230312). Set the environment
       // variable 'MOZ_IGNORE_NSS_SHUTDOWN_LEAKS' to some value to ignore this.
+      // Also, if leak checking is enabled, report this as a fake leak instead
+      // of crashing.
 #if defined(DEBUG) && !defined(ANDROID)
-      if (!getenv("MOZ_IGNORE_NSS_SHUTDOWN_LEAKS")) {
+      if (!getenv("MOZ_IGNORE_NSS_SHUTDOWN_LEAKS") &&
+          !getenv("XPCOM_MEM_BLOAT_LOG")) {
         MOZ_CRASH("NSS_Shutdown failed");
       } else {
+#  ifdef NS_BUILD_REFCNT_LOGGING
+        // Create a fake leak.
+        NS_LogCtor((void*)0x100, "NSSShutdownFailed", 100);
+#  endif  // NS_BUILD_REFCNT_LOGGING
         NS_WARNING("NSS_Shutdown failed");
       }
 #else
       NS_WARNING("NSS_Shutdown failed");
-#endif
+#endif  // defined(DEBUG) && !defined(ANDROID)
     }
   }
 
   // Finally, release the component manager last because it unloads the
   // libraries:
   if (nsComponentManagerImpl::gComponentManager) {
     nsrefcnt cnt;
     NS_RELEASE2(nsComponentManagerImpl::gComponentManager, cnt);