Title: [288289] releases/WebKitGTK/webkit-2.34/Source/WebCore
Revision
288289
Author
[email protected]
Date
2022-01-20 07:49:18 -0800 (Thu, 20 Jan 2022)

Log Message

Merge r287667 - [ Monterey Debug arm64 ] ASSERTION FAILED: result == &worker ./workers/service/server/SWServer.cpp(837) : void WebCore::SWServer::workerContextTerminated(WebCore::SWServerWorker &)
https://bugs.webkit.org/show_bug.cgi?id=233219
<rdar://problem/85478756>

Reviewed by Darin Adler.

The crash would occur when we get notified by the service worker process that a given service worker
was terminated right after we've determined that we no longer needed a given service worker process
and called markAllWorkersForRegistrableDomainAsTerminated(). This race would cause
SWServer::workerContextTerminated() to get called twice for the same worker. During the second call,
we would retrieve a null worker from the HashMap and hit the assertion. I updated the call to ignore
the call to workerContextTerminated() if the worker was already removed from the HashMap and added
an assertion to make sure we've already marked the service worker as "not running" in this case.

No new tests, covered by existing API test that is flakily crashing in debug.

* workers/service/server/SWServer.cpp:
(WebCore::SWServer::workerContextTerminated):

Modified Paths

Diff

Modified: releases/WebKitGTK/webkit-2.34/Source/WebCore/ChangeLog (288288 => 288289)


--- releases/WebKitGTK/webkit-2.34/Source/WebCore/ChangeLog	2022-01-20 15:46:28 UTC (rev 288288)
+++ releases/WebKitGTK/webkit-2.34/Source/WebCore/ChangeLog	2022-01-20 15:49:18 UTC (rev 288289)
@@ -1,3 +1,24 @@
+2022-01-05  Chris Dumez  <[email protected]>
+
+        [ Monterey Debug arm64 ] ASSERTION FAILED: result == &worker ./workers/service/server/SWServer.cpp(837) : void WebCore::SWServer::workerContextTerminated(WebCore::SWServerWorker &)
+        https://bugs.webkit.org/show_bug.cgi?id=233219
+        <rdar://problem/85478756>
+
+        Reviewed by Darin Adler.
+
+        The crash would occur when we get notified by the service worker process that a given service worker
+        was terminated right after we've determined that we no longer needed a given service worker process
+        and called markAllWorkersForRegistrableDomainAsTerminated(). This race would cause
+        SWServer::workerContextTerminated() to get called twice for the same worker. During the second call,
+        we would retrieve a null worker from the HashMap and hit the assertion. I updated the call to ignore
+        the call to workerContextTerminated() if the worker was already removed from the HashMap and added
+        an assertion to make sure we've already marked the service worker as "not running" in this case.
+
+        No new tests, covered by existing API test that is flakily crashing in debug.
+
+        * workers/service/server/SWServer.cpp:
+        (WebCore::SWServer::workerContextTerminated):
+
 2021-12-24  Frederic Wang  <[email protected]>
 
         Simplify test for startOfLastParagraph in InsertListCommand::doApply

Modified: releases/WebKitGTK/webkit-2.34/Source/WebCore/workers/service/server/SWServer.cpp (288288 => 288289)


--- releases/WebKitGTK/webkit-2.34/Source/WebCore/workers/service/server/SWServer.cpp	2022-01-20 15:46:28 UTC (rev 288288)
+++ releases/WebKitGTK/webkit-2.34/Source/WebCore/workers/service/server/SWServer.cpp	2022-01-20 15:49:18 UTC (rev 288289)
@@ -819,6 +819,11 @@
     // At this point if no registrations are referencing the worker then it will be destroyed,
     // removing itself from the m_workersByID map.
     auto result = m_runningOrTerminatingWorkers.take(worker.identifier());
+    if (!result) {
+        ASSERT(worker.isNotRunning());
+        return;
+    }
+
     ASSERT_UNUSED(result, result == &worker);
 
     worker.setState(SWServerWorker::State::NotRunning);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to