Title: [292442] branches/safari-614.1.9-branch/Source/WebKit
Revision
292442
Author
repst...@apple.com
Date
2022-04-05 17:08:38 -0700 (Tue, 05 Apr 2022)

Log Message

Cherry-pick r292426. rdar://problem/90808910

    Verify generalStorageDirectory is not in use when creating WebsiteDataStore
    https://bugs.webkit.org/show_bug.cgi?id=238686
    rdar://90808910

    Reviewed by Chris Dumez.

    In r290739, we added assertion to verify that no two sessions share the same general storage directory. The
    assertion is hit on macOS as shown in rdar://90808910. However, because we checked the directories when
    launching new network process, not when creating WebsiteDataStore, the backtraces do not give much information
    about when the problematic WebsiteDataStore (using the generalStorageDirectory that's already used by another
    WebsiteDataStore) is created. To help debug the issue, let's move the assertion to the constructor of
    WebsiteDataStore.

    * UIProcess/Network/NetworkProcessProxy.cpp:
    (WebKit::NetworkProcessProxy::sendCreationParametersToNewProcess):
    * UIProcess/WebsiteData/WebsiteDataStore.cpp:
    (WebKit::activeGeneralStorageDirectories):
    (WebKit::WebsiteDataStore::WebsiteDataStore):
    (WebKit::WebsiteDataStore::~WebsiteDataStore):

    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@292426 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Modified Paths

Diff

Modified: branches/safari-614.1.9-branch/Source/WebKit/ChangeLog (292441 => 292442)


--- branches/safari-614.1.9-branch/Source/WebKit/ChangeLog	2022-04-05 23:52:51 UTC (rev 292441)
+++ branches/safari-614.1.9-branch/Source/WebKit/ChangeLog	2022-04-06 00:08:38 UTC (rev 292442)
@@ -1,3 +1,52 @@
+2022-04-05  Alan Coon  <alanc...@apple.com>
+
+        Cherry-pick r292426. rdar://problem/90808910
+
+    Verify generalStorageDirectory is not in use when creating WebsiteDataStore
+    https://bugs.webkit.org/show_bug.cgi?id=238686
+    rdar://90808910
+    
+    Reviewed by Chris Dumez.
+    
+    In r290739, we added assertion to verify that no two sessions share the same general storage directory. The
+    assertion is hit on macOS as shown in rdar://90808910. However, because we checked the directories when
+    launching new network process, not when creating WebsiteDataStore, the backtraces do not give much information
+    about when the problematic WebsiteDataStore (using the generalStorageDirectory that's already used by another
+    WebsiteDataStore) is created. To help debug the issue, let's move the assertion to the constructor of
+    WebsiteDataStore.
+    
+    * UIProcess/Network/NetworkProcessProxy.cpp:
+    (WebKit::NetworkProcessProxy::sendCreationParametersToNewProcess):
+    * UIProcess/WebsiteData/WebsiteDataStore.cpp:
+    (WebKit::activeGeneralStorageDirectories):
+    (WebKit::WebsiteDataStore::WebsiteDataStore):
+    (WebKit::WebsiteDataStore::~WebsiteDataStore):
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@292426 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2022-04-05  Sihui Liu  <sihui_...@apple.com>
+
+            Verify generalStorageDirectory is not in use when creating WebsiteDataStore
+            https://bugs.webkit.org/show_bug.cgi?id=238686
+            rdar://90808910
+
+            Reviewed by Chris Dumez.
+
+            In r290739, we added assertion to verify that no two sessions share the same general storage directory. The
+            assertion is hit on macOS as shown in rdar://90808910. However, because we checked the directories when
+            launching new network process, not when creating WebsiteDataStore, the backtraces do not give much information
+            about when the problematic WebsiteDataStore (using the generalStorageDirectory that's already used by another
+            WebsiteDataStore) is created. To help debug the issue, let's move the assertion to the constructor of
+            WebsiteDataStore.
+
+            * UIProcess/Network/NetworkProcessProxy.cpp:
+            (WebKit::NetworkProcessProxy::sendCreationParametersToNewProcess):
+            * UIProcess/WebsiteData/WebsiteDataStore.cpp:
+            (WebKit::activeGeneralStorageDirectories):
+            (WebKit::WebsiteDataStore::WebsiteDataStore):
+            (WebKit::WebsiteDataStore::~WebsiteDataStore):
+
 2022-04-03  Tim Horton  <timothy_hor...@apple.com>
 
         _WKDataTask doesn't work in macCatalyst

Modified: branches/safari-614.1.9-branch/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp (292441 => 292442)


--- branches/safari-614.1.9-branch/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp	2022-04-05 23:52:51 UTC (rev 292441)
+++ branches/safari-614.1.9-branch/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp	2022-04-06 00:08:38 UTC (rev 292442)
@@ -196,16 +196,7 @@
 
 #if !PLATFORM(GTK) && !PLATFORM(WPE) // GTK and WPE don't use defaultNetworkProcess
     parameters.websiteDataStoreParameters = WebsiteDataStore::parametersFromEachWebsiteDataStore();
-    HashMap<String, PAL::SessionID> sessionForDirectory;
     WebsiteDataStore::forEachWebsiteDataStore([&](auto& websiteDataStore) {
-        if (websiteDataStore.isPersistent()) {
-            if (auto directory = websiteDataStore.resolvedGeneralStorageDirectory(); !directory.isEmpty()) {
-                auto sessionID = websiteDataStore.sessionID();
-                // Persistent sessions sharing same storage directory may cause corruption.
-                // If the assertion is hit, check if you have multiple WebsiteDataStores with the same generalStorageDirectory.
-                RELEASE_ASSERT_WITH_MESSAGE(sessionForDirectory.add(directory, sessionID).isNewEntry, "GeneralStorageDirectory for session %" PRIu64 " is already in use by session %" PRIu64, sessionForDirectory.get(directory).toUInt64(), sessionID.toUInt64());
-            }
-        }
         addSession(websiteDataStore, SendParametersToNetworkProcess::No);
     });
 #endif

Modified: branches/safari-614.1.9-branch/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp (292441 => 292442)


--- branches/safari-614.1.9-branch/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp	2022-04-05 23:52:51 UTC (rev 292441)
+++ branches/safari-614.1.9-branch/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp	2022-04-06 00:08:38 UTC (rev 292442)
@@ -96,6 +96,12 @@
     allowsWebsiteDataRecordsForAllOrigins = true;
 }
 
+static HashMap<String, PAL::SessionID>& activeGeneralStorageDirectories()
+{
+    static MainThreadNeverDestroyed<HashMap<String, PAL::SessionID>> directoryToSessionMap;
+    return directoryToSessionMap;
+}
+
 static HashMap<PAL::SessionID, WebsiteDataStore*>& allDataStores()
 {
     RELEASE_ASSERT(isUIThread());
@@ -139,6 +145,11 @@
     platformInitialize();
 
     ASSERT(RunLoop::isMain());
+
+    if (auto directory = m_configuration->generalStorageDirectory(); isPersistent() && !directory.isEmpty()) {
+        if (!activeGeneralStorageDirectories().add(directory, m_sessionID).isNewEntry)
+            RELEASE_LOG_FAULT(Storage, "GeneralStorageDirectory for session %" PRIu64 " is already in use by session %" PRIu64, m_sessionID.toUInt64(), activeGeneralStorageDirectories().get(directory).toUInt64());
+    }
 }
 
 WebsiteDataStore::~WebsiteDataStore()
@@ -149,6 +160,8 @@
     platformDestroy();
 
     ASSERT(allDataStores().get(m_sessionID) == this);
+    if (auto generalStorageDirectory = m_configuration->generalStorageDirectory(); isPersistent() && !generalStorageDirectory.isEmpty())
+        activeGeneralStorageDirectories().remove(generalStorageDirectory);
     allDataStores().remove(m_sessionID);
     networkProcess().removeSession(*this);
 #if ENABLE(GPU_PROCESS)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to