Bug 1395856 - add warning and assertion to detect intermittent failure; r=bagder
authorLiang-Heng Chen <xeonchen@gmail.com>
Mon, 04 Sep 2017 17:17:44 +0800
changeset 378843 cc5f0a6017a13554e441b1a5002aa4191e7c9de1
parent 378842 079ab757385041449d680ead8127a6efd6febdbb
child 378844 1811ea2c78ccd5c4d382b4af02b7083aa74f37a2
push id50406
push usergachen@mozilla.com
push dateTue, 05 Sep 2017 05:51:35 +0000
treeherderautoland@cc5f0a6017a1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbagder
bugs1395856
milestone57.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 1395856 - add warning and assertion to detect intermittent failure; r=bagder MozReview-Commit-ID: 1lZVLdHF2tC
netwerk/base/ProxyAutoConfig.cpp
netwerk/base/nsPACMan.cpp
--- a/netwerk/base/ProxyAutoConfig.cpp
+++ b/netwerk/base/ProxyAutoConfig.cpp
@@ -867,28 +867,30 @@ ProxyAutoConfig::GC()
 
   JSAutoCompartment ac(mJSContext->Context(), mJSContext->Global());
   JS_MaybeGC(mJSContext->Context());
 }
 
 ProxyAutoConfig::~ProxyAutoConfig()
 {
   MOZ_COUNT_DTOR(ProxyAutoConfig);
+  MOZ_ASSERT(mShutdown, "Shutdown must be called before dtor.");
   NS_ASSERTION(!mJSContext,
                "~ProxyAutoConfig leaking JS context that "
                "should have been deleted on pac thread");
 }
 
 void
 ProxyAutoConfig::Shutdown()
 {
   MOZ_ASSERT(!NS_IsMainThread(), "wrong thread for shutdown");
 
-  if (GetRunning() || mShutdown)
+  if (NS_WARN_IF(GetRunning()) || mShutdown) {
     return;
+  }
 
   mShutdown = true;
   delete mJSContext;
   mJSContext = nullptr;
 }
 
 bool
 ProxyAutoConfig::SrcAddress(const NetAddr *remoteAddress, nsCString &localAddress)
--- a/netwerk/base/nsPACMan.cpp
+++ b/netwerk/base/nsPACMan.cpp
@@ -343,16 +343,18 @@ nsPACMan::nsPACMan(nsIEventTarget *mainT
     PR_NewThreadPrivateIndex(&sThreadLocalIndex, nullptr);
   }
   mPAC.SetThreadLocalIndex(sThreadLocalIndex);
   mIncludePath = Preferences::GetBool(kPACIncludePath, false);
 }
 
 nsPACMan::~nsPACMan()
 {
+  MOZ_ASSERT(mShutdown, "Shutdown must be called before dtor.");
+
   if (mPACThread) {
     if (NS_IsMainThread()) {
       mPACThread->Shutdown();
     }
     else {
       RefPtr<ShutdownThread> runnable = new ShutdownThread(mPACThread);
       Dispatch(runnable.forget());
     }
@@ -366,16 +368,18 @@ void
 nsPACMan::Shutdown()
 {
   MOZ_ASSERT(NS_IsMainThread(), "pacman must be shutdown on main thread");
   if (mShutdown) {
     return;
   }
   mShutdown = true;
   CancelExistingLoad();
+
+  MOZ_ASSERT(mPACThread, "mPAC requires mPACThread to shutdown");
   PostCancelPendingQ(NS_ERROR_ABORT);
 
   RefPtr<WaitForThreadShutdown> runnable = new WaitForThreadShutdown(this);
   Dispatch(runnable.forget());
 }
 
 nsresult
 nsPACMan::AsyncGetProxyForURI(nsIURI *uri,