- Revision
- 183259
- Author
- [email protected]
- Date
- 2015-04-24 04:05:40 -0700 (Fri, 24 Apr 2015)
Log Message
Source/WebCore:
CrashTracer: WebProcess at com.apple.WebCore: WebCore::toScriptElementIfPossible + 4
https://bugs.webkit.org/show_bug.cgi?id=144050
Reviewed by Chris Dumez.
We are seeing null Element pointer crashes with this stack:
47 com.apple.WebCore: WebCore::toScriptElementIfPossible + 4 <==
47 com.apple.WebCore: WebCore::ScriptRunner::timerFired + 452
47 com.apple.WebCore: WebCore::ThreadTimers::sharedTimerFiredInternal + 175
The most likely cause seems to be that this code
ASSERT(m_pendingAsyncScripts.contains(scriptElement));
m_scriptsToExecuteSoon.append(m_pendingAsyncScripts.take(scriptElement));
in ScriptRunner::notifyScriptReady fails to find scriptElement and we are left with null entry in
m_scriptsToExecuteSoon. However I haven't managed to repro this or find the exact path how this
could happen. The related code is fragile with lot of state (especially in ScriptElement class)
and involves many opportunities for re-entry via scripts.
No repro, no test case.
* dom/ScriptRunner.cpp:
(WebCore::ScriptRunner::timerFired):
Paper this over by adding a null check. We could check m_pendingAsyncScripts.take() above
but this also covers possibility this is caused by something else.
LayoutTests:
Memory cache live resources repeatedly purged during painting
https://bugs.webkit.org/show_bug.cgi?id=144104
Reviewed by Chris Dumez.
* http/tests/cache/disk-cache/disk-cache-vary-cookie.html:
These clearMemoryCache calls are now done by cache-test.js.
* http/tests/cache/disk-cache/resources/cache-test.js:
(loadResources):
Make sure to clear the memory cache explicitly in the beginning so we always hit the disk cache.
(runTests):
Modified Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (183258 => 183259)
--- trunk/LayoutTests/ChangeLog 2015-04-24 10:21:13 UTC (rev 183258)
+++ trunk/LayoutTests/ChangeLog 2015-04-24 11:05:40 UTC (rev 183259)
@@ -1,3 +1,21 @@
+2015-04-24 Antti Koivisto <[email protected]>
+
+ Memory cache live resources repeatedly purged during painting
+ https://bugs.webkit.org/show_bug.cgi?id=144104
+
+ Reviewed by Chris Dumez.
+
+ * http/tests/cache/disk-cache/disk-cache-vary-cookie.html:
+
+ These clearMemoryCache calls are now done by cache-test.js.
+
+ * http/tests/cache/disk-cache/resources/cache-test.js:
+ (loadResources):
+
+ Make sure to clear the memory cache explicitly in the beginning so we always hit the disk cache.
+
+ (runTests):
+
2015-04-23 Basile Clement <[email protected]>
Allow function allocation sinking
Modified: trunk/LayoutTests/http/tests/cache/disk-cache/disk-cache-vary-cookie.html (183258 => 183259)
--- trunk/LayoutTests/http/tests/cache/disk-cache/disk-cache-vary-cookie.html 2015-04-24 10:21:13 UTC (rev 183258)
+++ trunk/LayoutTests/http/tests/cache/disk-cache/disk-cache-vary-cookie.html 2015-04-24 11:05:40 UTC (rev 183259)
@@ -15,16 +15,13 @@
document.cookie = "cookie=value";
loadResources(tests, function () {
printResults(tests);
- internals.clearMemoryCache();
debug("Loading again");
loadResources(tests, function () {
printResults(tests);
- internals.clearMemoryCache();
debug("Changing cookie and loading");
document.cookie = "cookie=othervalue";
loadResources(tests, function () {
printResults(tests);
- internals.clearMemoryCache()
debug("Loading again");
loadResources(tests, function () {
printResults(tests);
Modified: trunk/LayoutTests/http/tests/cache/disk-cache/resources/cache-test.js (183258 => 183259)
--- trunk/LayoutTests/http/tests/cache/disk-cache/resources/cache-test.js 2015-04-24 10:21:13 UTC (rev 183258)
+++ trunk/LayoutTests/http/tests/cache/disk-cache/resources/cache-test.js 2015-04-24 11:05:40 UTC (rev 183259)
@@ -69,6 +69,9 @@
function loadResources(tests, completetion)
{
+ // Otherwise we just get responses from the memory cache.
+ internals.clearMemoryCache();
+
var pendingCount = tests.length;
for (var i = 0; i < tests.length; ++i) {
loadResource(tests[i], function (ev) {
@@ -97,8 +100,6 @@
function runTests(tests, completionHandler)
{
loadResources(tests, function () {
- // Otherwise we just get responses from the memory cache.
- internals.clearMemoryCache();
// Wait a bit so things settle down in the disk cache.
setTimeout(function () {
loadResources(tests, function () {
Modified: trunk/Source/WebCore/ChangeLog (183258 => 183259)
--- trunk/Source/WebCore/ChangeLog 2015-04-24 10:21:13 UTC (rev 183258)
+++ trunk/Source/WebCore/ChangeLog 2015-04-24 11:05:40 UTC (rev 183259)
@@ -1,3 +1,34 @@
+2015-04-24 Antti Koivisto <[email protected]>
+
+ CrashTracer: WebProcess at com.apple.WebCore: WebCore::toScriptElementIfPossible + 4
+ https://bugs.webkit.org/show_bug.cgi?id=144050
+
+ Reviewed by Chris Dumez.
+
+ We are seeing null Element pointer crashes with this stack:
+
+ 47 com.apple.WebCore: WebCore::toScriptElementIfPossible + 4 <==
+ 47 com.apple.WebCore: WebCore::ScriptRunner::timerFired + 452
+ 47 com.apple.WebCore: WebCore::ThreadTimers::sharedTimerFiredInternal + 175
+
+ The most likely cause seems to be that this code
+
+ ASSERT(m_pendingAsyncScripts.contains(scriptElement));
+ m_scriptsToExecuteSoon.append(m_pendingAsyncScripts.take(scriptElement));
+
+ in ScriptRunner::notifyScriptReady fails to find scriptElement and we are left with null entry in
+ m_scriptsToExecuteSoon. However I haven't managed to repro this or find the exact path how this
+ could happen. The related code is fragile with lot of state (especially in ScriptElement class)
+ and involves many opportunities for re-entry via scripts.
+
+ No repro, no test case.
+
+ * dom/ScriptRunner.cpp:
+ (WebCore::ScriptRunner::timerFired):
+
+ Paper this over by adding a null check. We could check m_pendingAsyncScripts.take() above
+ but this also covers possibility this is caused by something else.
+
2015-04-24 Carlos Garcia Campos <[email protected]>
[SOUP] Use a webkit subdirectory for the disk cache
Modified: trunk/Source/WebCore/loader/cache/CachedResource.cpp (183258 => 183259)
--- trunk/Source/WebCore/loader/cache/CachedResource.cpp 2015-04-24 10:21:13 UTC (rev 183258)
+++ trunk/Source/WebCore/loader/cache/CachedResource.cpp 2015-04-24 11:05:40 UTC (rev 183259)
@@ -460,7 +460,7 @@
// We allow non-secure content to be reused in history, but we do not allow secure content to be reused.
memoryCache.remove(*this);
}
- memoryCache.prune();
+ memoryCache.pruneSoon();
}
// This object may be dead here.
}
@@ -557,7 +557,7 @@
memoryCache.removeFromLiveDecodedResourcesList(*this);
memoryCache.insertInLiveDecodedResourcesList(*this);
}
- memoryCache.prune();
+ memoryCache.pruneSoon();
}
}
Modified: trunk/Source/WebCore/loader/cache/MemoryCache.cpp (183258 => 183259)
--- trunk/Source/WebCore/loader/cache/MemoryCache.cpp 2015-04-24 10:21:13 UTC (rev 183258)
+++ trunk/Source/WebCore/loader/cache/MemoryCache.cpp 2015-04-24 11:05:40 UTC (rev 183259)
@@ -69,6 +69,7 @@
, m_deadDecodedDataDeletionInterval(defaultDecodedDataDeletionInterval)
, m_liveSize(0)
, m_deadSize(0)
+ , m_pruneTimer(*this, &MemoryCache::pruneTimerFired)
{
}
@@ -745,15 +746,34 @@
ASSERT(!m_sessionResources.contains(sessionID));
}
+bool MemoryCache::needsPruning() const
+{
+ return m_liveSize + m_deadSize > m_capacity || m_deadSize > m_maxDeadCapacity;
+}
+
void MemoryCache::prune()
{
- if (m_liveSize + m_deadSize <= m_capacity && m_deadSize <= m_maxDeadCapacity) // Fast path.
+ if (!needsPruning())
return;
pruneDeadResources(); // Prune dead first, in case it was "borrowing" capacity from live.
pruneLiveResources();
}
+void MemoryCache::pruneTimerFired()
+{
+ prune();
+}
+
+void MemoryCache::pruneSoon()
+{
+ if (m_pruneTimer.isActive())
+ return;
+ if (!needsPruning())
+ return;
+ m_pruneTimer.startOneShot(0);
+}
+
#ifndef NDEBUG
void MemoryCache::dumpStats()
{
Modified: trunk/Source/WebCore/loader/cache/MemoryCache.h (183258 => 183259)
--- trunk/Source/WebCore/loader/cache/MemoryCache.h 2015-04-24 10:21:13 UTC (rev 183258)
+++ trunk/Source/WebCore/loader/cache/MemoryCache.h 2015-04-24 11:05:40 UTC (rev 183259)
@@ -28,6 +28,7 @@
#include "NativeImagePtr.h"
#include "SecurityOriginHash.h"
#include "SessionID.h"
+#include "Timer.h"
#include <wtf/Forward.h>
#include <wtf/HashMap.h>
#include <wtf/HashSet.h>
@@ -117,6 +118,7 @@
WEBCORE_EXPORT void evictResources(SessionID);
void prune();
+ void pruneSoon();
unsigned size() const { return m_liveSize + m_deadSize; }
void setDeadDecodedDataDeletionInterval(std::chrono::milliseconds interval) { m_deadDecodedDataDeletionInterval = interval; }
@@ -184,6 +186,8 @@
unsigned liveCapacity() const;
unsigned deadCapacity() const;
+ bool needsPruning() const;
+ void pruneTimerFired();
CachedResource* resourceForRequestImpl(const ResourceRequest&, CachedResourceMap&);
@@ -213,6 +217,8 @@
// referenced by a Web page).
typedef HashMap<SessionID, std::unique_ptr<CachedResourceMap>> SessionCachedResourceMap;
SessionCachedResourceMap m_sessionResources;
+
+ Timer m_pruneTimer;
};
}