Title: [241565] trunk/Source/WebKit
Revision
241565
Author
you...@apple.com
Date
2019-02-14 14:55:24 -0800 (Thu, 14 Feb 2019)

Log Message

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: trunk/Source/WebKit/ChangeLog (241564 => 241565)


--- trunk/Source/WebKit/ChangeLog	2019-02-14 22:32:21 UTC (rev 241564)
+++ trunk/Source/WebKit/ChangeLog	2019-02-14 22:55:24 UTC (rev 241565)
@@ -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  Brian Burg  <bb...@apple.com>
 
         [Mac] WebInspectorUI.framework does not need to be soft-linked anymore

Modified: trunk/Source/WebKit/NetworkProcess/cache/CacheStorageEngineCaches.cpp (241564 => 241565)


--- trunk/Source/WebKit/NetworkProcess/cache/CacheStorageEngineCaches.cpp	2019-02-14 22:32:21 UTC (rev 241564)
+++ trunk/Source/WebKit/NetworkProcess/cache/CacheStorageEngineCaches.cpp	2019-02-14 22:55:24 UTC (rev 241565)
@@ -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: trunk/Source/WebKit/NetworkProcess/cache/CacheStorageEngineCaches.h (241564 => 241565)


--- trunk/Source/WebKit/NetworkProcess/cache/CacheStorageEngineCaches.h	2019-02-14 22:32:21 UTC (rev 241564)
+++ trunk/Source/WebKit/NetworkProcess/cache/CacheStorageEngineCaches.h	2019-02-14 22:55:24 UTC (rev 241565)
@@ -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