PostResolutionCallbackDisabler can resume pending requests while a ResourceLoadSuspen...
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 20 Jul 2016 13:02:30 +0000 (13:02 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 20 Jul 2016 13:02:30 +0000 (13:02 +0000)
commitad325d195c3d1c4bdf87b18c644a2dc56ea6cfc6
tree7c558ca5e867d1292c238bddcc021e27cdd46dc7
parentb35601c6a21dc449e224a1c05aa1ec39d90cb465
PostResolutionCallbackDisabler can resume pending requests while a ResourceLoadSuspender is alive
https://bugs.webkit.org/show_bug.cgi?id=159962
<rdar://problem/21439264>

Reviewed by David Kilzer.

PostResolutionCallbackDisabler can resume pending requests while a ResourceLoadSuspender
is alive. We have both PostResolutionCallbackDisabler and ResourceLoadSuspender that
call LoaderStrategy::suspendPendingRequests() / LoaderStrategy::resumePendingRequests().
However, PostResolutionCallbackDisabler and ResourceLoadSuspender are not aware of each
other. It is therefore possible for a PostResolutionCallbackDisabler object to get
destroyed, causing LoaderStrategy::resumePendingRequests() to be called while a
ResourceLoadSuspender object is alive.

This leads to hard to investigate crashes where we end up re-entering WebKit and killing
the style resolver.

This patch drops ResourceLoadSuspender and uses PostResolutionCallbackDisabler instead.
There was only one user of ResourceLoadSuspender and PostResolutionCallbackDisabler
is better because it manages a resolutionNestingDepth counter internally to make sure
it only calls LoaderStrategy::resumePendingRequests() once all
PostResolutionCallbackDisabler instances are destroyed.

No new tests, there is no easy way to reproduce the crashes.

* dom/Document.cpp:
(WebCore::Document::styleForElementIgnoringPendingStylesheets):
* loader/LoaderStrategy.cpp:
(WebCore::ResourceLoadSuspender::ResourceLoadSuspender): Deleted.
(WebCore::ResourceLoadSuspender::~ResourceLoadSuspender): Deleted.
* loader/LoaderStrategy.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@203450 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/WebCore/ChangeLog
Source/WebCore/dom/Document.cpp
Source/WebCore/loader/LoaderStrategy.cpp
Source/WebCore/loader/LoaderStrategy.h