Commit c15b15fc authored by Eden Chuang's avatar Eden Chuang
Browse files

Bug 1849269 - Add SharedWorkerManager::mRemoteWorkerController nullptr...

Bug 1849269 - Add SharedWorkerManager::mRemoteWorkerController nullptr checking in SharedWorkerManager::Terminate(). r=dom-worker-reviewers,smaug,asuth a=pascalc

Here comes a possible might cause the crash stack.

    RemoteWorkerController creation fails. If it is Shutdown phase or OOM. The point is ServiceWorkerManager::mRemoteWorkerController is kept as nullptr.

    WorkerManagerCreatedRunnable::mManagerWrapper is the only holder of the ServiceWorkerManager. And it would be released once the runnable finished.

    When releasing WorkerManagerCreatedRunnable::mManagerWrapper, ServiceWorkerManager::UnregisterHolder() is called. In the end SharedWorkerManager::Terminate() is triggered to release the SharedWorker by calling SharedWorkerManager::mRemoteWorkerController::Terminate. However, SharedWorkerManager::mRemoteWorkerController is reasonably a nullptr here, then we meet a de-reference on nullptr.

Differential Revision: https://phabricator.services.mozilla.com/D187269
parent e93feede
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -159,6 +159,12 @@ void SharedWorkerManager::Terminate() {
  MOZ_ASSERT(mActors.IsEmpty());
  MOZ_ASSERT(mHolders.IsEmpty());

  // mRemoteWorkerController creation can fail. If the creation fails
  // mRemoteWorkerController is nullptr and we should stop termination here.
  if (!mRemoteWorkerController) {
    return;
  }

  mRemoteWorkerController->Terminate();
  mRemoteWorkerController = nullptr;
}