Title: [241674] releases/WebKitGTK/webkit-2.24/Source/WebKit
Revision
241674
Author
carlo...@webkit.org
Date
2019-02-18 08:12:55 -0800 (Mon, 18 Feb 2019)

Log Message

Merge r241565 - ASSERTION FAILED: m_caches.isEmpty() || !m_pendingInitializationCallbacks.isEmpty() in WebKit::CacheStorage::Caches::clearMemoryRepresentation()
https://bugs.webkit.org/show_bug.cgi?id=188393
<rdar://problem/43025665>

Reviewed by Alex Christensen.

In case Caches::dispose is called, clearMemoryRepresentation might be called if there is no active cache.
We also ensure to not clear the memory representation if there is any remaining removed cache.
Update the clearMemoryRepresentation assertion to take that into account.

In case a Caches is cleared twice, the clearMemoryRepresentation assertion will assert while it should not.
In that case m_storage is null the second time. Update the assertion accordingly.

* NetworkProcess/cache/CacheStorageEngineCaches.cpp:
(WebKit::CacheStorage::Caches::hasActiveCache const):
(WebKit::CacheStorage::Caches::dispose):
(WebKit::CacheStorage::Caches::clearMemoryRepresentation):
* NetworkProcess/cache/CacheStorageEngineCaches.h:

Modified Paths

Diff

Modified: releases/WebKitGTK/webkit-2.24/Source/WebKit/ChangeLog (241673 => 241674)


--- releases/WebKitGTK/webkit-2.24/Source/WebKit/ChangeLog	2019-02-18 16:12:50 UTC (rev 241673)
+++ releases/WebKitGTK/webkit-2.24/Source/WebKit/ChangeLog	2019-02-18 16:12:55 UTC (rev 241674)
@@ -1,3 +1,24 @@
+2019-02-14  Youenn Fablet  <you...@apple.com>
+
+        ASSERTION FAILED: m_caches.isEmpty() || !m_pendingInitializationCallbacks.isEmpty() in WebKit::CacheStorage::Caches::clearMemoryRepresentation()
+        https://bugs.webkit.org/show_bug.cgi?id=188393
+        <rdar://problem/43025665>
+
+        Reviewed by Alex Christensen.
+
+        In case Caches::dispose is called, clearMemoryRepresentation might be called if there is no active cache.
+        We also ensure to not clear the memory representation if there is any remaining removed cache.
+        Update the clearMemoryRepresentation assertion to take that into account.
+
+        In case a Caches is cleared twice, the clearMemoryRepresentation assertion will assert while it should not.
+        In that case m_storage is null the second time. Update the assertion accordingly.
+
+        * NetworkProcess/cache/CacheStorageEngineCaches.cpp:
+        (WebKit::CacheStorage::Caches::hasActiveCache const):
+        (WebKit::CacheStorage::Caches::dispose):
+        (WebKit::CacheStorage::Caches::clearMemoryRepresentation):
+        * NetworkProcess/cache/CacheStorageEngineCaches.h:
+
 2019-02-14  Michael Catanzaro  <mcatanz...@igalia.com>
 
         [GTK] WebKitGTK+ -> WebKitGTK

Modified: releases/WebKitGTK/webkit-2.24/Source/WebKit/NetworkProcess/cache/CacheStorageEngineCaches.cpp (241673 => 241674)


--- releases/WebKitGTK/webkit-2.24/Source/WebKit/NetworkProcess/cache/CacheStorageEngineCaches.cpp	2019-02-18 16:12:50 UTC (rev 241673)
+++ releases/WebKitGTK/webkit-2.24/Source/WebKit/NetworkProcess/cache/CacheStorageEngineCaches.cpp	2019-02-18 16:12:55 UTC (rev 241674)
@@ -343,6 +343,13 @@
     });
 }
 
+bool Caches::hasActiveCache() const
+{
+    if (m_removedCaches.size())
+        return true;
+    return m_caches.findMatching([](const auto& item) { return item.isActive(); }) != notFound;
+}
+
 void Caches::dispose(Cache& cache)
 {
     auto position = m_removedCaches.findMatching([&](const auto& item) { return item.identifier() == cache.identifier(); });
@@ -356,7 +363,7 @@
     ASSERT(m_caches.findMatching([&](const auto& item) { return item.identifier() == cache.identifier(); }) != notFound);
     cache.clearMemoryRepresentation();
 
-    if (m_caches.findMatching([](const auto& item) { return item.isActive(); }) == notFound)
+    if (!hasActiveCache())
         clearMemoryRepresentation();
 }
 
@@ -594,7 +601,7 @@
 void Caches::clearMemoryRepresentation()
 {
     if (!m_isInitialized) {
-        ASSERT(m_caches.isEmpty() || !m_pendingInitializationCallbacks.isEmpty());
+        ASSERT(!m_storage || !hasActiveCache() || !m_pendingInitializationCallbacks.isEmpty());
         // m_storage might not be null in case Caches is being initialized. This is fine as nullify it below is a memory optimization.
         m_caches.clear();
         return;

Modified: releases/WebKitGTK/webkit-2.24/Source/WebKit/NetworkProcess/cache/CacheStorageEngineCaches.h (241673 => 241674)


--- releases/WebKitGTK/webkit-2.24/Source/WebKit/NetworkProcess/cache/CacheStorageEngineCaches.h	2019-02-18 16:12:50 UTC (rev 241673)
+++ releases/WebKitGTK/webkit-2.24/Source/WebKit/NetworkProcess/cache/CacheStorageEngineCaches.h	2019-02-18 16:12:55 UTC (rev 241674)
@@ -96,6 +96,8 @@
 
     void notifyCachesOfRequestSpaceEnd();
 
+    bool hasActiveCache() const;
+
     bool m_isInitialized { false };
     bool m_isRequestingSpace { false };
     Engine* m_engine { nullptr };
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to