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

Changeset 263852 in webkit


Ignore:
Timestamp:
Jul 2, 2020, 11:45:34 AM (6 years ago)
Author:
Chris Dumez
Message:

Crash under WebKit::NetworkProcessProxy::updateProcessAssertion()
​https://bugs.webkit.org/show_bug.cgi?id=213891
<rdar://problem/65017909>

Reviewed by Alex Christensen.

The crash was due to NetworkProcessProxy::updateProcessAssertion() re-entering while
in the middle of the m_activityFromWebProcesses = nullptr; assignment. Calling
the ProcessThrottler::BackgroundActivity destructor, could cause updateProcessAssertion()
to get called again, in which case we may dereference m_activityFromWebProcesses and
crash. To address the issue, use std::exchange(m_activityFromWebProcesses, nullptr);
instead, so that m_activityFromWebProcesses becomes null BEFORE the BackgroundActivity
destructor gets called. updateProcessAssertion() will still re-enter but
m_activityFromWebProcesses will be nullptr and updateProcessAssertion() will do the
right thing.

  • UIProcess/Network/NetworkProcessProxy.cpp:

(WebKit::NetworkProcessProxy::updateProcessAssertion):

Location:
trunk/Source/WebKit
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r263843 r263852  
     12020-07-02  Chris Dumez  <cdumez@apple.com>
     2
     3        Crash under WebKit::NetworkProcessProxy::updateProcessAssertion()
     4        https://bugs.webkit.org/show_bug.cgi?id=213891
     5        <rdar://problem/65017909>
     6
     7        Reviewed by Alex Christensen.
     8
     9        The crash was due to NetworkProcessProxy::updateProcessAssertion() re-entering while
     10        in the middle of the `m_activityFromWebProcesses = nullptr;` assignment. Calling
     11        the ProcessThrottler::BackgroundActivity destructor, could cause updateProcessAssertion()
     12        to get called again, in which case we may dereference m_activityFromWebProcesses and
     13        crash. To address the issue, use `std::exchange(m_activityFromWebProcesses, nullptr);`
     14        instead, so that m_activityFromWebProcesses becomes null BEFORE the BackgroundActivity
     15        destructor gets called. updateProcessAssertion() will still re-enter but
     16        m_activityFromWebProcesses will be nullptr and updateProcessAssertion() will do the
     17        right thing.
     18
     19        * UIProcess/Network/NetworkProcessProxy.cpp:
     20        (WebKit::NetworkProcessProxy::updateProcessAssertion):
     21
    1222020-07-02  Carlos Garcia Campos  <cgarcia@igalia.com>
    223
  • trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp

    r263695 r263852  
    15261526        return;
    15271527    }
    1528     m_activityFromWebProcesses = nullptr;
     1528    // Use std::exchange() instead of a simple nullptr assignment to avoid re-entering this
     1529    // function during the destructor of the ProcessThrottler activity, before setting
     1530    // m_activityFromWebProcesses.
     1531    std::exchange(m_activityFromWebProcesses, nullptr);
    15291532}
    15301533
Note: See TracChangeset for help on using the changeset viewer.