⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 249690 in webkit


Ignore:
Timestamp:
Sep 9, 2019, 8:19:35 PM (7 years ago)
Author:
Alan Coon
Message:

Cherry-pick r249444. rdar://problem/55093558

Null deref under -[WKWebView _addUpdateVisibleContentRectPreCommitHandler]'s handler block
https://bugs.webkit.org/show_bug.cgi?id=201436
<rdar://problem/40640475>

Reviewed by Simon Fraser.

  • UIProcess/API/Cocoa/WKWebView.mm: (-[WKWebView dealloc]): (-[WKWebView _addUpdateVisibleContentRectPreCommitHandler]): We crash sending a message to a deallocated WKWebView inside the handler block passed to +[CATransaction addCommitHandler:]. This seems impossible, because we carefully retain it, but it's possible that it could be the result of the handler block being installed under -dealloc (in which case retaining the WKWebView wouldn't actually extend its lifetime). -[WKWebView dealloc] is fairly sizable, and it's hard to follow all paths from it, so instead add a RELEASE_LOG_FAULT, so we'll get simulated crash logs, and bail, so we'll stop actually crashing (if this is the cause).

This is just a speculative fix, but a hopeful one, since intentionally calling
-_addUpdateVisibleContentRectPreCommitHandler: from dealloc yields a similar-looking
crash under the handler block.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@249444 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Location:
branches/safari-608-branch/Source/WebKit
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/safari-608-branch/Source/WebKit/ChangeLog

    r249550 r249690  
     12019-09-09  Kocsen Chung  <kocsen_chung@apple.com>
     2
     3        Cherry-pick r249444. rdar://problem/55093558
     4
     5    Null deref under -[WKWebView _addUpdateVisibleContentRectPreCommitHandler]'s handler block
     6    https://bugs.webkit.org/show_bug.cgi?id=201436
     7    <rdar://problem/40640475>
     8   
     9    Reviewed by Simon Fraser.
     10   
     11    * UIProcess/API/Cocoa/WKWebView.mm:
     12    (-[WKWebView dealloc]):
     13    (-[WKWebView _addUpdateVisibleContentRectPreCommitHandler]):
     14    We crash sending a message to a deallocated WKWebView inside the handler block
     15    passed to +[CATransaction addCommitHandler:]. This seems impossible, because
     16    we carefully retain it, but it's possible that it could be the result of
     17    the handler block being installed under -dealloc (in which case retaining
     18    the WKWebView wouldn't actually extend its lifetime). -[WKWebView dealloc]
     19    is fairly sizable, and it's hard to follow all paths from it, so instead
     20    add a RELEASE_LOG_FAULT, so we'll get simulated crash logs, and bail,
     21    so we'll stop actually crashing (if this is the cause).
     22   
     23    This is just a speculative fix, but a hopeful one, since intentionally calling
     24    -_addUpdateVisibleContentRectPreCommitHandler: from dealloc yields a similar-looking
     25    crash under the handler block.
     26   
     27   
     28    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@249444 268f45cc-cd09-0410-ab3c-d52691b4dbfc
     29
     30    2019-09-03  Tim Horton  <timothy_horton@apple.com>
     31
     32            Null deref under -[WKWebView _addUpdateVisibleContentRectPreCommitHandler]'s handler block
     33            https://bugs.webkit.org/show_bug.cgi?id=201436
     34            <rdar://problem/40640475>
     35
     36            Reviewed by Simon Fraser.
     37
     38            * UIProcess/API/Cocoa/WKWebView.mm:
     39            (-[WKWebView dealloc]):
     40            (-[WKWebView _addUpdateVisibleContentRectPreCommitHandler]):
     41            We crash sending a message to a deallocated WKWebView inside the handler block
     42            passed to +[CATransaction addCommitHandler:]. This seems impossible, because
     43            we carefully retain it, but it's possible that it could be the result of
     44            the handler block being installed under -dealloc (in which case retaining
     45            the WKWebView wouldn't actually extend its lifetime). -[WKWebView dealloc]
     46            is fairly sizable, and it's hard to follow all paths from it, so instead
     47            add a RELEASE_LOG_FAULT, so we'll get simulated crash logs, and bail,
     48            so we'll stop actually crashing (if this is the cause).
     49
     50            This is just a speculative fix, but a hopeful one, since intentionally calling
     51            -_addUpdateVisibleContentRectPreCommitHandler: from dealloc yields a similar-looking
     52            crash under the handler block.
     53
    1542019-09-05  Kocsen Chung  <kocsen_chung@apple.com>
    255
  • branches/safari-608-branch/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm

    r249475 r249690  
    375375    NSUInteger _focusPreservationCount;
    376376    NSUInteger _activeFocusedStateRetainCount;
     377
     378    BOOL _hasEnteredDealloc;
    377379#endif
    378380#if PLATFORM(MAC)
     
    875877
    876878#if PLATFORM(IOS_FAMILY)
     879    _hasEnteredDealloc = YES;
     880
    877881    [_contentView _webViewDestroyed];
    878882
     
    30123016- (void)_addUpdateVisibleContentRectPreCommitHandler
    30133017{
     3018    if (_hasEnteredDealloc) {
     3019        RELEASE_LOG_FAULT(ViewState, "-[WKWebView %p _addUpdateVisibleContentRectPreCommitHandler]: Attempted to add pre-commit handler under -dealloc. Bailing.", self);
     3020        return;
     3021    }
     3022
    30143023    auto retainedSelf = retainPtr(self);
    30153024    [CATransaction addCommitHandler:[retainedSelf] {
Note: See TracChangeset for help on using the changeset viewer.