Title: [246606] trunk/Source/WebKit
Revision
246606
Author
[email protected]
Date
2019-06-19 12:44:10 -0700 (Wed, 19 Jun 2019)

Log Message

Crash at com.apple.WebKit: WebKit::WebsiteDataStore::processPools const
https://bugs.webkit.org/show_bug.cgi?id=198935
<rdar://problem/51549308>

Reviewed by Geoffrey Garen.

When WebProcessProxy is in WebProcessCache or is pre-warmed, it does not hold a strong reference of
WebProcessPool. In this case, we should not store the raw pointer of WebProcessPool and perform websiteDataStore
operations with it.
This patch should fix the crash at dereferencing null pointer of WebProcessPool in
WebsiteDataStore::processPools, but it is unclear why websiteDataStore comes to observe cached or prewarmed web
process that should not have web page. The release log may help us find the cause.

* UIProcess/WebProcessProxy.cpp:
(WebKit::WebProcessProxy::processPoolIfExists const):
* UIProcess/WebProcessProxy.h:
* UIProcess/WebsiteData/WebsiteDataStore.cpp:
(WebKit::WebsiteDataStore::processPools const):

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (246605 => 246606)


--- trunk/Source/WebKit/ChangeLog	2019-06-19 19:28:56 UTC (rev 246605)
+++ trunk/Source/WebKit/ChangeLog	2019-06-19 19:44:10 UTC (rev 246606)
@@ -1,3 +1,24 @@
+2019-06-19  Sihui Liu  <[email protected]>
+
+        Crash at com.apple.WebKit: WebKit::WebsiteDataStore::processPools const
+        https://bugs.webkit.org/show_bug.cgi?id=198935
+        <rdar://problem/51549308>
+
+        Reviewed by Geoffrey Garen.
+
+        When WebProcessProxy is in WebProcessCache or is pre-warmed, it does not hold a strong reference of 
+        WebProcessPool. In this case, we should not store the raw pointer of WebProcessPool and perform websiteDataStore
+        operations with it.
+        This patch should fix the crash at dereferencing null pointer of WebProcessPool in 
+        WebsiteDataStore::processPools, but it is unclear why websiteDataStore comes to observe cached or prewarmed web 
+        process that should not have web page. The release log may help us find the cause.
+
+        * UIProcess/WebProcessProxy.cpp:
+        (WebKit::WebProcessProxy::processPoolIfExists const):
+        * UIProcess/WebProcessProxy.h:
+        * UIProcess/WebsiteData/WebsiteDataStore.cpp:
+        (WebKit::WebsiteDataStore::processPools const):
+
 2019-06-19  Alex Christensen  <[email protected]>
 
         Add a unit test for client certificate authentication

Modified: trunk/Source/WebKit/UIProcess/WebProcessProxy.cpp (246605 => 246606)


--- trunk/Source/WebKit/UIProcess/WebProcessProxy.cpp	2019-06-19 19:28:56 UTC (rev 246605)
+++ trunk/Source/WebKit/UIProcess/WebProcessProxy.cpp	2019-06-19 19:44:10 UTC (rev 246606)
@@ -1516,6 +1516,15 @@
         send(Messages::WebProcess::SetHasSuspendedPageProxy(false), 0);
 }
 
+WebProcessPool* WebProcessProxy::processPoolIfExists() const
+{
+    if (m_isPrewarmed || m_isInProcessCache)
+        RELEASE_LOG_ERROR(Process, "%p - WebProcessProxy::processPoolIfExists: trying to get WebProcessPool from an inactive WebProcessProxy %i", this, processIdentifier());
+    else
+        ASSERT(m_processPool);
+    return m_processPool.get();
+}
+
 WebProcessPool& WebProcessProxy::processPool() const
 {
     ASSERT(m_processPool);

Modified: trunk/Source/WebKit/UIProcess/WebProcessProxy.h (246605 => 246606)


--- trunk/Source/WebKit/UIProcess/WebProcessProxy.h	2019-06-19 19:28:56 UTC (rev 246605)
+++ trunk/Source/WebKit/UIProcess/WebProcessProxy.h	2019-06-19 19:44:10 UTC (rev 246606)
@@ -119,6 +119,7 @@
     void incrementSuspendedPageCount();
     void decrementSuspendedPageCount();
 
+    WebProcessPool* processPoolIfExists() const;
     WebProcessPool& processPool() const;
 
     WebCore::RegistrableDomain registrableDomain() const { return m_registrableDomain.valueOr(WebCore::RegistrableDomain { }); }

Modified: trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp (246605 => 246606)


--- trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp	2019-06-19 19:28:56 UTC (rev 246605)
+++ trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp	2019-06-19 19:44:10 UTC (rev 246606)
@@ -1717,8 +1717,10 @@
 HashSet<RefPtr<WebProcessPool>> WebsiteDataStore::processPools(size_t count, bool ensureAPoolExists) const
 {
     HashSet<RefPtr<WebProcessPool>> processPools;
-    for (auto& process : processes())
-        processPools.add(&process->processPool());
+    for (auto& process : processes()) {
+        if (auto* processPool = process->processPoolIfExists())
+            processPools.add(processPool);
+    }
 
     if (processPools.isEmpty()) {
         // Check if we're one of the legacy data stores.
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to