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

Changeset 276712 in webkit


Ignore:
Timestamp:
Apr 28, 2021, 8:20:48 AM (5 years ago)
Author:
Chris Dumez
Message:

Crash under GPUProcessProxy::getGPUProcessConnection()
​https://bugs.webkit.org/show_bug.cgi?id=224017
<rdar://75146104>

Reviewed by Darin Adler.

The crash would happen when replyToPendingMessages() get called in the AuxiliaryProcessProxy
destructor and there would be a pending getGPUProcessConnection() IPC. The lambda in
WebProcessPool::getGPUProcessConnection() would check if a WeakPtr to the WebProcessPool is
valid before calling ensureGPUProcess().getGPUProcessConnection(). However, at this point,
the WebProcessPool destructor is still running so the WeakPtr is still valid but
ensureGPUProcess().getGPUProcessConnection() will crash because the GPUProcessProxy
destructor has already run.

  • UIProcess/WebProcessPool.cpp:

(WebKit::WebProcessPool::~WebProcessPool):
Drop code that was causing the GPUProcessProxy to reply to all its pending IPC messages whenenever
a WebProcessPool gets destroyed. This is incorrect since a GPUProcessProxy may be shared by several
WebProcessPool objects. Note that the AuxiliaryProcessProxy destructor already takes care of
calling replyToPendingMessages().

(WebKit::WebProcessPool::getGPUProcessConnection):
Protect the WebProcessPool is the lambda to prevent the case where this lambda gets called and the
WebProcessPool & GPUProcessProxy are in the middle of destruction.

Location:
trunk/Source/WebKit
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r276706 r276712  
     12021-04-28  Chris Dumez  <cdumez@apple.com>
     2
     3        Crash under GPUProcessProxy::getGPUProcessConnection()
     4        https://bugs.webkit.org/show_bug.cgi?id=224017
     5        <rdar://75146104>
     6
     7        Reviewed by Darin Adler.
     8
     9        The crash would happen when replyToPendingMessages() get called in the AuxiliaryProcessProxy
     10        destructor and there would be a pending getGPUProcessConnection() IPC. The lambda in
     11        WebProcessPool::getGPUProcessConnection() would check if a WeakPtr to the WebProcessPool is
     12        valid before calling `ensureGPUProcess().getGPUProcessConnection()`. However, at this point,
     13        the WebProcessPool destructor is still running so the WeakPtr is still valid but
     14        `ensureGPUProcess().getGPUProcessConnection()` will crash because the GPUProcessProxy
     15        destructor has already run.
     16
     17        * UIProcess/WebProcessPool.cpp:
     18        (WebKit::WebProcessPool::~WebProcessPool):
     19        Drop code that was causing the GPUProcessProxy to reply to all its pending IPC messages whenenever
     20        a WebProcessPool gets destroyed. This is incorrect since a GPUProcessProxy may be shared by several
     21        WebProcessPool objects. Note that the AuxiliaryProcessProxy destructor already takes care of
     22        calling replyToPendingMessages().
     23
     24        (WebKit::WebProcessPool::getGPUProcessConnection):
     25        Protect the WebProcessPool is the lambda to prevent the case where this lambda gets called and the
     26        WebProcessPool & GPUProcessProxy are in the middle of destruction.
     27
    1282021-04-28  Kimmo Kinnunen  <kkinnunen@apple.com>
    229
  • trunk/Source/WebKit/UIProcess/WebProcessPool.cpp

    r276148 r276712  
    361361#endif
    362362
    363 #if ENABLE(GPU_PROCESS)
    364     if (m_gpuProcess)
    365         m_gpuProcess->replyToPendingMessages();
    366 #endif
    367 
    368363    // Only remaining processes should be pre-warmed ones as other keep the process pool alive.
    369364    while (!m_processes.isEmpty()) {
    … …  
    530525void WebProcessPool::getGPUProcessConnection(WebProcessProxy& webProcessProxy, GPUProcessConnectionParameters&& parameters, Messages::WebProcessProxy::GetGPUProcessConnection::DelayedReply&& reply)
    531526{
    532     ensureGPUProcess().getGPUProcessConnection(webProcessProxy, parameters, [this, weakThis = makeWeakPtr(*this), parameters, webProcessProxy = makeWeakPtr(webProcessProxy), reply = WTFMove(reply)] (auto& connectionInfo) mutable {
    533         if (UNLIKELY(!IPC::Connection::identifierIsValid(connectionInfo.identifier()) && webProcessProxy && weakThis)) {
     527    ensureGPUProcess().getGPUProcessConnection(webProcessProxy, parameters, [this, protectedThis = makeRef(*this), parameters, webProcessProxy = makeWeakPtr(webProcessProxy), reply = WTFMove(reply)] (auto& connectionInfo) mutable {
     528        if (UNLIKELY(!IPC::Connection::identifierIsValid(connectionInfo.identifier()) && webProcessProxy)) {
    534529            WEBPROCESSPOOL_RELEASE_LOG_ERROR(Process, "getGPUProcessConnection: Failed first attempt, retrying");
    535530            ensureGPUProcess().getGPUProcessConnection(*webProcessProxy, parameters, WTFMove(reply));
Note: See TracChangeset for help on using the changeset viewer.