Title: [203172] trunk/Source/WebCore
Revision
203172
Author
[email protected]
Date
2016-07-13 12:17:46 -0700 (Wed, 13 Jul 2016)

Log Message

v2: WebContent crash due to RELEASE_ASSERT(!m_inLoadPendingImages) in StyleResolver::~StyleResolver()
https://bugs.webkit.org/show_bug.cgi?id=159722

Reviewed by Andreas Kling.

We have crashes where a StyleResolver is deleted underneath pseudoStyleForElement (key parts of the stack):

0   WebCore::StyleResolver::~StyleResolver
3   WebCore::AuthorStyleSheets::updateActiveStyleSheets
4   WebCore::Document::styleResolverChanged
5   WebKit::WebPage::viewportConfigurationChanged()
6   WebKit::WebPage::mainFrameDidLayout()
9   WebCore::FrameLoader::checkCompleted
13  WebCore::ResourceLoader::cancel
19  WebKit::WebLoaderStrategy::loadResource
24  WebCore::Style::loadPendingImage
27  WebCore::StyleResolver::pseudoStyleForElement
29  WebCore::RenderTreeUpdater::updateBeforeOrAfterPseudoElement
33  WebCore::Document::recalcStyle

This appears to be happening when a content blocker blocks a resource load for an image referenced from a stylesheet
and triggers synchronous cancellation of the load. With engine in suitable state this can clear style resolver.

No test, don't know how to make one. This is very timing and engine state dependent.

* dom/AuthorStyleSheets.cpp:
(WebCore::AuthorStyleSheets::updateActiveStyleSheets):

We have an existing check here that prevents destruction of the style resolver when we are in the middle of
a style resolution. However the old inStyleRecalc() bit no longer covers the render tree update phase. Pseudo
elements are resolved during render tree update.

Fix by adding a check for inRenderTreeUpdate() bit too.

This just fixes a regression. A proper fix would be to gather all resources during style resolution
and trigger the loads afterwards.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (203171 => 203172)


--- trunk/Source/WebCore/ChangeLog	2016-07-13 19:14:59 UTC (rev 203171)
+++ trunk/Source/WebCore/ChangeLog	2016-07-13 19:17:46 UTC (rev 203172)
@@ -1,3 +1,42 @@
+2016-07-13  Antti Koivisto  <[email protected]>
+
+        v2: WebContent crash due to RELEASE_ASSERT(!m_inLoadPendingImages) in StyleResolver::~StyleResolver()
+        https://bugs.webkit.org/show_bug.cgi?id=159722
+
+        Reviewed by Andreas Kling.
+
+        We have crashes where a StyleResolver is deleted underneath pseudoStyleForElement (key parts of the stack):
+
+        0   WebCore::StyleResolver::~StyleResolver
+        3   WebCore::AuthorStyleSheets::updateActiveStyleSheets
+        4   WebCore::Document::styleResolverChanged
+        5   WebKit::WebPage::viewportConfigurationChanged()
+        6   WebKit::WebPage::mainFrameDidLayout()
+        9   WebCore::FrameLoader::checkCompleted
+        13  WebCore::ResourceLoader::cancel
+        19  WebKit::WebLoaderStrategy::loadResource
+        24  WebCore::Style::loadPendingImage
+        27  WebCore::StyleResolver::pseudoStyleForElement
+        29  WebCore::RenderTreeUpdater::updateBeforeOrAfterPseudoElement
+        33  WebCore::Document::recalcStyle
+
+        This appears to be happening when a content blocker blocks a resource load for an image referenced from a stylesheet
+        and triggers synchronous cancellation of the load. With engine in suitable state this can clear style resolver.
+
+        No test, don't know how to make one. This is very timing and engine state dependent.
+
+        * dom/AuthorStyleSheets.cpp:
+        (WebCore::AuthorStyleSheets::updateActiveStyleSheets):
+
+        We have an existing check here that prevents destruction of the style resolver when we are in the middle of
+        a style resolution. However the old inStyleRecalc() bit no longer covers the render tree update phase. Pseudo
+        elements are resolved during render tree update.
+
+        Fix by adding a check for inRenderTreeUpdate() bit too.
+
+        This just fixes a regression. A proper fix would be to gather all resources during style resolution
+        and trigger the loads afterwards.
+
 2016-07-13  Frederic Wang  <[email protected]>
 
         Remove padding and margin around the <math> element

Modified: trunk/Source/WebCore/dom/AuthorStyleSheets.cpp (203171 => 203172)


--- trunk/Source/WebCore/dom/AuthorStyleSheets.cpp	2016-07-13 19:14:59 UTC (rev 203171)
+++ trunk/Source/WebCore/dom/AuthorStyleSheets.cpp	2016-07-13 19:17:46 UTC (rev 203172)
@@ -291,10 +291,10 @@
 
 bool AuthorStyleSheets::updateActiveStyleSheets(UpdateFlag updateFlag)
 {
-    if (m_document.inStyleRecalc()) {
-        // SVG <use> element may manage to invalidate style selector in the middle of a style recalc.
-        // https://bugs.webkit.org/show_bug.cgi?id=54344
-        // FIXME: This should be fixed in SVG and the call site replaced by ASSERT(!m_inStyleRecalc).
+    if (m_document.inStyleRecalc() || m_document.inRenderTreeUpdate()) {
+        // Protect against deleting style resolver in the middle of a style resolution.
+        // Crash stacks indicate we can get here when z resource load fails synchronously (for example due to content blocking).
+        // FIXME: These kind of cases should be eliminated and this path replaced by an assert.
         m_pendingUpdateType = FullUpdate;
         m_document.scheduleForcedStyleRecalc();
         return false;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to