Title: [270685] trunk/Source/WebKit
Revision
270685
Author
[email protected]
Date
2020-12-11 10:31:05 -0800 (Fri, 11 Dec 2020)

Log Message

Protect the WebProcessPool earlier in WebProcessCache::addProcessIfPossible
https://bugs.webkit.org/show_bug.cgi?id=219777

Patch by Carlos Garcia Campos <[email protected]> on 2020-12-11
Reviewed by Adrian Perez de Castro.

We are taking a reference of the WebProcessPool in the isResponsive() completion handler lambda, but the
WebProcessPool can be destroyed earlier when CachedProcess is created if the WebProcessProxy contains the last
strong reference.

* UIProcess/WebProcessCache.cpp:
(WebKit::WebProcessCache::addProcessIfPossible):

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (270684 => 270685)


--- trunk/Source/WebKit/ChangeLog	2020-12-11 18:23:51 UTC (rev 270684)
+++ trunk/Source/WebKit/ChangeLog	2020-12-11 18:31:05 UTC (rev 270685)
@@ -1,3 +1,17 @@
+2020-12-11  Carlos Garcia Campos  <[email protected]>
+
+        Protect the WebProcessPool earlier in WebProcessCache::addProcessIfPossible
+        https://bugs.webkit.org/show_bug.cgi?id=219777
+
+        Reviewed by Adrian Perez de Castro.
+
+        We are taking a reference of the WebProcessPool in the isResponsive() completion handler lambda, but the
+        WebProcessPool can be destroyed earlier when CachedProcess is created if the WebProcessProxy contains the last
+        strong reference.
+
+        * UIProcess/WebProcessCache.cpp:
+        (WebKit::WebProcessCache::addProcessIfPossible):
+
 2020-12-11  Brent Fulgham  <[email protected]>
 
         [macOS] Only extend access to the RootDomainUserClient IOKit class if the GPU Process is not used

Modified: trunk/Source/WebKit/UIProcess/WebProcessCache.cpp (270684 => 270685)


--- trunk/Source/WebKit/UIProcess/WebProcessCache.cpp	2020-12-11 18:23:51 UTC (rev 270684)
+++ trunk/Source/WebKit/UIProcess/WebProcessCache.cpp	2020-12-11 18:31:05 UTC (rev 270685)
@@ -89,11 +89,13 @@
     if (!canCacheProcess(process))
         return false;
 
+    // CachedProcess can destroy the process pool (which owns the WebProcessCache), by making its reference weak in WebProcessProxy::setIsInProcessCache.
+    auto protectedProcessPool = makeRef(process->processPool());
     uint64_t requestIdentifier = generateAddRequestIdentifier();
     m_pendingAddRequests.add(requestIdentifier, makeUnique<CachedProcess>(process.copyRef()));
 
     WEBPROCESSCACHE_RELEASE_LOG("addProcessIfPossible: Checking if process is responsive before caching it", process->processIdentifier());
-    process->isResponsive([this, processPool = makeRef(process->processPool()), process, requestIdentifier](bool isResponsive) {
+    process->isResponsive([this, processPool = WTFMove(protectedProcessPool), process, requestIdentifier](bool isResponsive) {
         auto cachedProcess = m_pendingAddRequests.take(requestIdentifier);
         if (!cachedProcess)
             return;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to