Bug 1336529 - Handle ServiceWorkerInfo destruction while released KeepAliveToken. r=asuth a=gchang
authorBen Kelly <ben@wanderview.com>
Fri, 03 Feb 2017 14:36:27 -0500
changeset 378220 2885c756fcf8bff6846cdb7d78fdccf799eb7820
parent 378219 2fd7a81771a7dd8c4dc47ee6199adac8500cd01f
child 378221 4f8f9621e75b23ba8f2546cc081df6981f46b13d
push id1419
push userjlund@mozilla.com
push dateMon, 10 Apr 2017 20:44:07 +0000
treeherdermozilla-release@5e6801b73ef6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersasuth, gchang
bugs1336529
milestone53.0a2
Bug 1336529 - Handle ServiceWorkerInfo destruction while released KeepAliveToken. r=asuth a=gchang
dom/workers/ServiceWorkerManager.cpp
dom/workers/ServiceWorkerPrivate.cpp
--- a/dom/workers/ServiceWorkerManager.cpp
+++ b/dom/workers/ServiceWorkerManager.cpp
@@ -1369,17 +1369,17 @@ ServiceWorkerManager::NotifyUnregister(n
   queue->ScheduleJob(job);
   return NS_OK;
 }
 
 void
 ServiceWorkerManager::WorkerIsIdle(ServiceWorkerInfo* aWorker)
 {
   AssertIsOnMainThread();
-  MOZ_ASSERT(aWorker);
+  MOZ_DIAGNOSTIC_ASSERT(aWorker);
 
   RefPtr<ServiceWorkerRegistrationInfo> reg =
     GetRegistration(aWorker->GetPrincipal(), aWorker->Scope());
   if (!reg) {
     return;
   }
 
   if (reg->GetActive() != aWorker) {
--- a/dom/workers/ServiceWorkerPrivate.cpp
+++ b/dom/workers/ServiceWorkerPrivate.cpp
@@ -2113,17 +2113,21 @@ void
 ServiceWorkerPrivate::ReleaseToken()
 {
   AssertIsOnMainThread();
 
   MOZ_ASSERT(mTokenCount > 0);
   --mTokenCount;
   if (!mTokenCount) {
     TerminateWorker();
-  } else if (IsIdle()) {
+  }
+
+  // mInfo can be nullptr here if NoteDeadServiceWorkerInfo() is called while
+  // the KeepAliveToken is being proxy released as a runnable.
+  else if (mInfo && IsIdle()) {
     RefPtr<ServiceWorkerManager> swm = ServiceWorkerManager::GetInstance();
     if (swm) {
       swm->WorkerIsIdle(mInfo);
     }
   }
 }
 
 already_AddRefed<KeepAliveToken>