-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Regression(266170@main) Crash under CachedRawResource::switchClientsT…
…oRevalidatedResource() https://bugs.webkit.org/show_bug.cgi?id=259401 rdar://112663008 Reviewed by Brent Fulgham. In 266170@main, I updated MemoryCache::revalidationSucceeded() to deal with the fact that there may already be a resource in the MemoryCache with the same URL when the resource revalidation finishes. I dealt with this by assuming that the resource already in the cache was good enough and I ignored the revalidated resource, and then transferred the clients of the revalidation resource to the resource that is already in the cache. However, it turns out that this isn't safe to do because the resource already in the cache may have a different type (even though it has the same URL). In the included test, for example, the same URL is loaded both as a RawResource and a FontResource. This would lead to crashes later on in switchClientsToRevalidatedResource(). To address the issue, I am reverting 266170@main and dealing with the original issue in a simpler way. Upon successful revalidation, if there is already a resource in the memory cache with the same URL, we now remove it from the cache before proceeding. This is much safer and matches what would happen if you tried to load URL1 as a RawResource and then load URL2 as a FontResource. Our MemoryCache logic would remove the existing RawResource in the cache and create a new CachedResource of FontResource type. * LayoutTests/http/tests/workers/memory-cache-crash2.html: Added. * LayoutTests/http/tests/workers/memory-cache-crash2-expected.txt: Added. * Source/WebCore/loader/cache/CachedResource.cpp: (WebCore::CachedResource::replaceResourceToRevalidate): Deleted. * Source/WebCore/loader/cache/CachedResource.h: * Source/WebCore/loader/cache/MemoryCache.cpp: (WebCore::MemoryCache::revalidationSucceeded): Canonical link: https://commits.webkit.org/266216@main
- Loading branch information
Showing
5 changed files
with
45 additions
and
35 deletions.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
LayoutTests/http/tests/workers/memory-cache-crash2-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
This test passes if it doesn't crash. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<p>This test passes if it doesn't crash.</p> | ||
<script> | ||
if (window.testRunner) { | ||
testRunner.dumpAsText(); | ||
testRunner.waitUntilDone(); | ||
} | ||
|
||
onload = async () => { | ||
document.createElement('audio').src = 'data:'; | ||
for (let i = 0; i < 5; i++) { | ||
new Worker(''); | ||
await navigator.storage.persist(); | ||
} | ||
new FontFace('a', 'url()'); | ||
setTimeout(() => { | ||
if (window.testRunner) | ||
testRunner.notifyDone(); | ||
}, 50); | ||
}; | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters