Skip to content

Commit d5daa15

Browse files
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): git-svn-id: http://svn.webkit.org/repository/webkit/trunk@211673 268f45cc-cd09-0410-ab3c-d52691b4dbfc
1 parent 670d8e9 commit d5daa15

File tree

2 files changed

+23
-4
lines changed

2 files changed

+23
-4
lines changed

Source/WebCore/ChangeLog

+15
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
2017-02-04 Yoav Weiss <[email protected]>
2+
3+
Fix memory issues related to preload eviction.
4+
https://bugs.webkit.org/show_bug.cgi?id=167838
5+
6+
Reviewed by Andreas Kling.
7+
8+
This avoids removing resources from m_preloads during the iteration
9+
by creating a second HashSetList containing the remaining link preloads.
10+
11+
No new tests but this will fix crashes on the leak bots.
12+
13+
* loader/cache/CachedResourceLoader.cpp:
14+
(WebCore::CachedResourceLoader::clearPreloads):
15+
116
2017-02-04 Zalan Bujtas <[email protected]>
217

318
Simple line layout: Skip 16bit specific checks on 8bit content.

Source/WebCore/loader/cache/CachedResourceLoader.cpp

+8-4
Original file line numberDiff line numberDiff line change
@@ -1254,17 +1254,21 @@ void CachedResourceLoader::clearPreloads(ClearPreloadsMode mode)
12541254
if (!m_preloads)
12551255
return;
12561256

1257+
std::unique_ptr<ListHashSet<CachedResource*>> remainingLinkPreloads;
12571258
for (auto* resource : *m_preloads) {
1258-
if (mode == ClearPreloadsMode::ClearSpeculativePreloads && resource->isLinkPreload())
1259+
ASSERT(resource);
1260+
if (mode == ClearPreloadsMode::ClearSpeculativePreloads && resource->isLinkPreload()) {
1261+
if (!remainingLinkPreloads)
1262+
remainingLinkPreloads = std::make_unique<ListHashSet<CachedResource*>>();
1263+
remainingLinkPreloads->add(resource);
12591264
continue;
1265+
}
12601266
resource->decreasePreloadCount();
12611267
bool deleted = resource->deleteIfPossible();
12621268
if (!deleted && resource->preloadResult() == CachedResource::PreloadNotReferenced)
12631269
MemoryCache::singleton().remove(*resource);
1264-
m_preloads->remove(resource);
12651270
}
1266-
if (!m_preloads->size())
1267-
m_preloads = nullptr;
1271+
m_preloads = WTFMove(remainingLinkPreloads);
12681272
}
12691273

12701274
#if PRELOAD_DEBUG

0 commit comments

Comments
 (0)