Title: [185070] trunk
Revision
185070
Author
cdu...@apple.com
Date
2015-06-01 12:31:34 -0700 (Mon, 01 Jun 2015)

Log Message

ASSERT(revalidatingResource.inCache()) in MemoryCache when reloading tumblr.com
https://bugs.webkit.org/show_bug.cgi?id=145518
<rdar://problem/21168573>

Reviewed by Darin Adler.

Source/WebCore:

There was an assertion in MemoryCache::revalidationSucceeded() making
sure that the resource that was revalidated is still in the memory
cache. However, nothing prevents this resource from being pruned while
it is being revalidated. We do make sure that the resource in question
cannot be destroyed though (see CachedResource::canDelete()).

This patch gets rid of this assertion as it is incorrect. Also, the
fact that the resource is no longer in the memory cache is not an
issue. We are merely going to call MemoryCache::remove() to remove
it from the memory cache before re-adding it and updating its
HTTP response. The call to MemoryCache::remove() will simply be a
no-op in this case and we will not have any problem adding the
resource back to the memory cache because the resource is kept alive.

Test: http/tests/cache/memory-cache-pruning-during-revalidation.html

* loader/cache/MemoryCache.cpp:
(WebCore::MemoryCache::revalidationSucceeded): Deleted.

LayoutTests:

Add layout test to make sure we no longer crash if the memory cache is
pruned while a resource is being revalidated.

* http/tests/cache/memory-cache-pruning-during-revalidation-expected.txt: Added.
* http/tests/cache/memory-cache-pruning-during-revalidation.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (185069 => 185070)


--- trunk/LayoutTests/ChangeLog	2015-06-01 19:05:44 UTC (rev 185069)
+++ trunk/LayoutTests/ChangeLog	2015-06-01 19:31:34 UTC (rev 185070)
@@ -1,3 +1,17 @@
+2015-06-01  Chris Dumez  <cdu...@apple.com>
+
+        ASSERT(revalidatingResource.inCache()) in MemoryCache when reloading tumblr.com
+        https://bugs.webkit.org/show_bug.cgi?id=145518
+        <rdar://problem/21168573>
+
+        Reviewed by Darin Adler.
+
+        Add layout test to make sure we no longer crash if the memory cache is
+        pruned while a resource is being revalidated.
+
+        * http/tests/cache/memory-cache-pruning-during-revalidation-expected.txt: Added.
+        * http/tests/cache/memory-cache-pruning-during-revalidation.html: Added.
+
 2015-05-31  Youenn Fablet  <youenn.fab...@crf.canon.fr>
 
         Async XMLHttpRequest should get access to AppCache resources stored as flat files

Added: trunk/LayoutTests/http/tests/cache/memory-cache-pruning-during-revalidation-expected.txt (0 => 185070)


--- trunk/LayoutTests/http/tests/cache/memory-cache-pruning-during-revalidation-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/http/tests/cache/memory-cache-pruning-during-revalidation-expected.txt	2015-06-01 19:31:34 UTC (rev 185070)
@@ -0,0 +1,9 @@
+Make sure we don't crash if the memory cache is getting pruned while a resource is being revalidated.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/http/tests/cache/memory-cache-pruning-during-revalidation.html (0 => 185070)


--- trunk/LayoutTests/http/tests/cache/memory-cache-pruning-during-revalidation.html	                        (rev 0)
+++ trunk/LayoutTests/http/tests/cache/memory-cache-pruning-during-revalidation.html	2015-06-01 19:31:34 UTC (rev 185070)
@@ -0,0 +1,31 @@
+<!DOCTYPE html>
+<html>
+<body _onload_="runTest()">
+<script src=""
+<script>
+description("Make sure we don't crash if the memory cache is getting pruned while a resource is being revalidated.");
+window.jsTestIsAsync = true;
+
+function removeImageAndReload() {
+  img.remove();
+
+  img = document.createElement("img");
+  img.src = ""
+  img._onload_ = finishJSTest;
+  document.body.appendChild(img);
+
+  internals.clearMemoryCache();
+}
+
+function runTest() {
+    setTimeout(function() {
+        img = document.createElement("img");
+        img.src = ""
+        img._onload_ = removeImageAndReload;
+        document.body.appendChild(img);
+    }, 0);
+}
+</script>
+<script src=""
+<body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (185069 => 185070)


--- trunk/Source/WebCore/ChangeLog	2015-06-01 19:05:44 UTC (rev 185069)
+++ trunk/Source/WebCore/ChangeLog	2015-06-01 19:31:34 UTC (rev 185070)
@@ -1,3 +1,30 @@
+2015-06-01  Chris Dumez  <cdu...@apple.com>
+
+        ASSERT(revalidatingResource.inCache()) in MemoryCache when reloading tumblr.com
+        https://bugs.webkit.org/show_bug.cgi?id=145518
+        <rdar://problem/21168573>
+
+        Reviewed by Darin Adler.
+
+        There was an assertion in MemoryCache::revalidationSucceeded() making
+        sure that the resource that was revalidated is still in the memory
+        cache. However, nothing prevents this resource from being pruned while
+        it is being revalidated. We do make sure that the resource in question
+        cannot be destroyed though (see CachedResource::canDelete()).
+
+        This patch gets rid of this assertion as it is incorrect. Also, the
+        fact that the resource is no longer in the memory cache is not an
+        issue. We are merely going to call MemoryCache::remove() to remove
+        it from the memory cache before re-adding it and updating its
+        HTTP response. The call to MemoryCache::remove() will simply be a
+        no-op in this case and we will not have any problem adding the
+        resource back to the memory cache because the resource is kept alive.
+
+        Test: http/tests/cache/memory-cache-pruning-during-revalidation.html
+
+        * loader/cache/MemoryCache.cpp:
+        (WebCore::MemoryCache::revalidationSucceeded): Deleted.
+
 2015-06-01  Matt Rajca  <mra...@apple.com>
 
         Add stub implementation of MediaRemoteControls, part of the Media Session spec.

Modified: trunk/Source/WebCore/loader/cache/MemoryCache.cpp (185069 => 185070)


--- trunk/Source/WebCore/loader/cache/MemoryCache.cpp	2015-06-01 19:05:44 UTC (rev 185069)
+++ trunk/Source/WebCore/loader/cache/MemoryCache.cpp	2015-06-01 19:31:34 UTC (rev 185070)
@@ -129,7 +129,6 @@
     CachedResource& resource = *revalidatingResource.resourceToRevalidate();
     ASSERT(!resource.inCache());
     ASSERT(resource.isLoaded());
-    ASSERT(revalidatingResource.inCache());
 
     // Calling remove() can potentially delete revalidatingResource, which we use
     // below. This mustn't be the case since revalidation means it is loaded
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to