Title: [211673] trunk/Source/WebCore
Revision
211673
Author
y...@yoav.ws
Date
2017-02-04 13:40:33 -0800 (Sat, 04 Feb 2017)

Log Message

Fix memory issues related to preload eviction.
https://bugs.webkit.org/show_bug.cgi?id=167838

Reviewed by Andreas Kling.

This avoids removing resources from m_preloads during the iteration
by creating a second HashSetList containing the remaining link preloads.

No new tests but this will fix crashes on the leak bots.

* loader/cache/CachedResourceLoader.cpp:
(WebCore::CachedResourceLoader::clearPreloads):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (211672 => 211673)


--- trunk/Source/WebCore/ChangeLog	2017-02-04 19:34:14 UTC (rev 211672)
+++ trunk/Source/WebCore/ChangeLog	2017-02-04 21:40:33 UTC (rev 211673)
@@ -1,3 +1,18 @@
+2017-02-04  Yoav Weiss  <y...@yoav.ws>
+
+        Fix memory issues related to preload eviction.
+        https://bugs.webkit.org/show_bug.cgi?id=167838
+
+        Reviewed by Andreas Kling.
+
+        This avoids removing resources from m_preloads during the iteration
+        by creating a second HashSetList containing the remaining link preloads.
+
+        No new tests but this will fix crashes on the leak bots.
+
+        * loader/cache/CachedResourceLoader.cpp:
+        (WebCore::CachedResourceLoader::clearPreloads):
+
 2017-02-04  Zalan Bujtas  <za...@apple.com>
 
         Simple line layout: Skip 16bit specific checks on 8bit content.

Modified: trunk/Source/WebCore/loader/cache/CachedResourceLoader.cpp (211672 => 211673)


--- trunk/Source/WebCore/loader/cache/CachedResourceLoader.cpp	2017-02-04 19:34:14 UTC (rev 211672)
+++ trunk/Source/WebCore/loader/cache/CachedResourceLoader.cpp	2017-02-04 21:40:33 UTC (rev 211673)
@@ -1254,17 +1254,21 @@
     if (!m_preloads)
         return;
 
+    std::unique_ptr<ListHashSet<CachedResource*>> remainingLinkPreloads;
     for (auto* resource : *m_preloads) {
-        if (mode == ClearPreloadsMode::ClearSpeculativePreloads && resource->isLinkPreload())
+        ASSERT(resource);
+        if (mode == ClearPreloadsMode::ClearSpeculativePreloads && resource->isLinkPreload()) {
+            if (!remainingLinkPreloads)
+                remainingLinkPreloads = std::make_unique<ListHashSet<CachedResource*>>();
+            remainingLinkPreloads->add(resource);
             continue;
+        }
         resource->decreasePreloadCount();
         bool deleted = resource->deleteIfPossible();
         if (!deleted && resource->preloadResult() == CachedResource::PreloadNotReferenced)
             MemoryCache::singleton().remove(*resource);
-        m_preloads->remove(resource);
     }
-    if (!m_preloads->size())
-        m_preloads = nullptr;
+    m_preloads = WTFMove(remainingLinkPreloads);
 }
 
 #if PRELOAD_DEBUG
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to