Commit 04c213c0 authored by Andrew McCreight's avatar Andrew McCreight
Browse files

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

--HG--
extra : moz-landing-system : lando
parent 028699d2
Loading
Loading
Loading
Loading
+9 −2
Original line number Diff line number Diff line
@@ -743,15 +743,22 @@ nsresult ShutdownXPCOM(nsIServiceManager* aServMgr) {
      // 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)
    }
  }