bug 1437128 - enforce that NSS_Shutdown succeeds on debug, non-android platforms (to prevent NSS resource leaks) r=erahm
authorDavid Keeler <dkeeler@mozilla.com>
Fri, 09 Feb 2018 12:11:15 -0800
changeset 409132 faa9d965f89eca4a2fe8727149e6fa8d7a699604
parent 409131 fd8f5976ecbb4b9ed119540bd95bed5824848074
child 409133 f8ea3e37c3ef7d3a5345ec2152ba671f66f39010
push id33676
push usertoros@mozilla.com
push dateWed, 21 Mar 2018 10:03:44 +0000
treeherdermozilla-central@e636edf00e6f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerserahm
bugs1437128
milestone61.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 1437128 - enforce that NSS_Shutdown succeeds on debug, non-android platforms (to prevent NSS resource leaks) r=erahm
xpcom/build/XPCOMInit.cpp
--- a/xpcom/build/XPCOMInit.cpp
+++ b/xpcom/build/XPCOMInit.cpp
@@ -1003,25 +1003,24 @@ ShutdownXPCOM(nsIServiceManager* aServMg
     JS_ShutDown();
     sInitializedJS = false;
   }
 
   // After all threads have been joined and the component manager has been shut
   // down, any remaining objects that could be holding NSS resources (should)
   // have been released, so we can safely shut down NSS.
   if (NSS_IsInitialized()) {
-    // It would be nice to enforce that this succeeds, at least on debug builds.
-    // This would alert us to NSS resource leaks. Unfortunately there are some
-    // architectural roadblocks in the way. Some tests (e.g. pkix gtests) need
-    // to be re-worked to release their NSS resources when they're done. In the
-    // meantime, just emit a warning. Chasing down these leaks is tracked in
-    // bug 1230312.
     if (NSS_Shutdown() != SECSuccess) {
-      NS_WARNING("NSS_Shutdown failed - some NSS resources are still in use "
-                 "(see bugs 1417680 and 1230312)");
+      // If you're seeing this crash and/or warning, some NSS resources are
+      // still in use (see bugs 1417680 and 1230312).
+#if defined(DEBUG) && !defined(ANDROID)
+      MOZ_CRASH("NSS_Shutdown failed");
+#else
+      NS_WARNING("NSS_Shutdown failed");
+#endif
     }
   }
 
   // Release our own singletons
   // Do this _after_ shutting down the component manager, because the
   // JS component loader will use XPConnect to call nsIModule::canUnload,
   // and that will spin up the InterfaceInfoManager again -- bad mojo
   XPTInterfaceInfoManager::FreeInterfaceInfoManager();