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

Changeset 235992 in webkit


Ignore:
Timestamp:
Sep 13, 2018, 3:32:33 PM (8 years ago)
Author:
Keith Rollin
Message:

WebPageProxy::reportPageLoadResult can crash on some code paths
​https://bugs.webkit.org/show_bug.cgi?id=189568

Reviewed by Chris Dumez.

WebPageProxy::reportPageLoadResult (which is called from
WebPageProxy::didFinishLoadForFrame) can sometimes crash when
accessing m_pageLoadStart (a std::optional) in its unloaded state.
Normally, m_pageLoadStart is initialized in
WebPageProxy::didStartProvisionalLoadForFrame, which one would expect
would be called before WebPageProxy::didFinishLoadForFrame. But that
turns out to not always be the case. It's not apparent under what
conditions didStartProvisionalLoadForFrame will not be called, but
it's happening in the wild, leading to crashes now that std::optional
asserts in release builds on bad accesses (see
​https://bugs.webkit.org/show_bug.cgi?id=189568).

Fix this by checking m_pageLoadState on entry to reportPageLoadResult.

  • UIProcess/WebPageProxy.cpp:

(WebKit::WebPageProxy::didFailProvisionalLoadForFrame):
(WebKit::WebPageProxy::didFinishLoadForFrame):
(WebKit::WebPageProxy::didFailLoadForFrame):
(WebKit::WebPageProxy::reportPageLoadResult):

Location:
trunk/Source/WebKit
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r235988 r235992  
     12018-09-13  Keith Rollin  <krollin@apple.com>
     2
     3        WebPageProxy::reportPageLoadResult can crash on some code paths
     4        https://bugs.webkit.org/show_bug.cgi?id=189568
     5
     6        Reviewed by Chris Dumez.
     7
     8        WebPageProxy::reportPageLoadResult (which is called from
     9        WebPageProxy::didFinishLoadForFrame) can sometimes crash when
     10        accessing m_pageLoadStart (a std::optional) in its unloaded state.
     11        Normally, m_pageLoadStart is initialized in
     12        WebPageProxy::didStartProvisionalLoadForFrame, which one would expect
     13        would be called before WebPageProxy::didFinishLoadForFrame. But that
     14        turns out to not always be the case. It's not apparent under what
     15        conditions didStartProvisionalLoadForFrame will not be called, but
     16        it's happening in the wild, leading to crashes now that std::optional
     17        asserts in release builds on bad accesses (see
     18        https://bugs.webkit.org/show_bug.cgi?id=189568).
     19
     20        Fix this by checking m_pageLoadState on entry to reportPageLoadResult.
     21
     22        * UIProcess/WebPageProxy.cpp:
     23        (WebKit::WebPageProxy::didFailProvisionalLoadForFrame):
     24        (WebKit::WebPageProxy::didFinishLoadForFrame):
     25        (WebKit::WebPageProxy::didFailLoadForFrame):
     26        (WebKit::WebPageProxy::reportPageLoadResult):
     27
    1282018-09-13  Chris Dumez  <cdumez@apple.com>
    229
  • trunk/Source/WebKit/UIProcess/WebPageProxy.cpp

    r235988 r235992  
    889889    m_isClosed = true;
    890890
    891     if (m_pageLoadStart)
    892         reportPageLoadResult(ResourceError { ResourceError::Type::Cancellation });
     891    reportPageLoadResult(ResourceError { ResourceError::Type::Cancellation });
    893892
    894893    if (m_activePopupMenu)
    … …  
    34643463
    34653464    if (frame->isMainFrame()) {
    3466         if (m_pageLoadStart)
    3467             reportPageLoadResult(ResourceError { ResourceError::Type::Cancellation });
     3465        reportPageLoadResult(ResourceError { ResourceError::Type::Cancellation });
    34683466        m_pageLoadStart = MonotonicTime::now();
    34693467        m_pageLoadState.didStartProvisionalLoad(transaction, url, unreachableURL);
    … …  
    79127910        });
    79137911
    7914     ASSERT(m_pageLoadStart);
     7912    if (!m_pageLoadStart)
     7913        return;
    79157914
    79167915    auto pageLoadTime = MonotonicTime::now() - *m_pageLoadStart;
Note: See TracChangeset for help on using the changeset viewer.