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

Changeset 286800 in webkit


Ignore:
Timestamp:
Dec 9, 2021, 1:14:04 PM (5 years ago)
Author:
Chris Dumez
Message:

[WPE] Crash under WebProcessProxy::setIsInProcessCache when closing web view in debug builds
https://bugs.webkit.org/show_bug.cgi?id=233933

Reviewed by Geoffrey Garen.

The crash would occur because the WebProcessPool destructor would call WebProcessCache::clear()
which would destroy WebProcessCache::CachedProcess objects, causing
WebProcessProxy::setIsInProcessCache(false) to get called. Previously, this call to
setIsInProcessCache() would convert the WeakPtr the WebProcessProxy held to its process pool
into a RefPtr, thus causing the WebProcessPool to get ref'd while in the middle of destruction.

To address the issue, the setIsInProcessCache() setter now takes a WillShutDown flag that gets
set in the CachedProcess destructor and which causes setIsInProcessCache() to return early
right after setting the m_isInProcessCache flag, without trying to send IPC to the WebProcess
or trying to ref the WebProcessPool.

  • UIProcess/WebProcessCache.cpp:

(WebKit::WebProcessCache::CachedProcess::~CachedProcess):

  • UIProcess/WebProcessProxy.cpp:

(WebKit::WebProcessProxy::setIsInProcessCache):

  • UIProcess/WebProcessProxy.h:
Location:
trunk/Source/WebKit
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r286799 r286800  
     12021-12-09  Chris Dumez  <cdumez@apple.com>
     2
     3        [WPE] Crash under WebProcessProxy::setIsInProcessCache when closing web view in debug builds
     4        https://bugs.webkit.org/show_bug.cgi?id=233933
     5
     6        Reviewed by Geoffrey Garen.
     7
     8        The crash would occur because the WebProcessPool destructor would call WebProcessCache::clear()
     9        which would destroy WebProcessCache::CachedProcess objects, causing
     10        WebProcessProxy::setIsInProcessCache(false) to get called. Previously, this call to
     11        setIsInProcessCache() would convert the WeakPtr the WebProcessProxy held to its process pool
     12        into a RefPtr, thus causing the WebProcessPool to get ref'd while in the middle of destruction.
     13
     14        To address the issue, the setIsInProcessCache() setter now takes a WillShutDown flag that gets
     15        set in the CachedProcess destructor and which causes setIsInProcessCache() to return early
     16        right after setting the m_isInProcessCache flag, without trying to send IPC to the WebProcess
     17        or trying to ref the WebProcessPool.
     18
     19        * UIProcess/WebProcessCache.cpp:
     20        (WebKit::WebProcessCache::CachedProcess::~CachedProcess):
     21        * UIProcess/WebProcessProxy.cpp:
     22        (WebKit::WebProcessProxy::setIsInProcessCache):
     23        * UIProcess/WebProcessProxy.h:
     24
    1252021-12-08  BJ Burg  <bburg@apple.com>
    226
  • trunk/Source/WebKit/UIProcess/WebProcessCache.cpp

    r285594 r286800  
    295295        m_process->platformResumeProcess();
    296296#endif
    297     m_process->setIsInProcessCache(false);
     297    m_process->setIsInProcessCache(false, WebProcessProxy::WillShutDown::Yes);
    298298    m_process->shutDown();
    299299}
  • trunk/Source/WebKit/UIProcess/WebProcessProxy.cpp

    r286455 r286800  
    310310#endif
    311311
    312 void WebProcessProxy::setIsInProcessCache(bool value)
     312void WebProcessProxy::setIsInProcessCache(bool value, WillShutDown willShutDown)
    313313{
    314314    WEBPROCESSPROXY_RELEASE_LOG(Process, "setIsInProcessCache(%d)", value);
     
    321321    ASSERT(m_isInProcessCache != value);
    322322    m_isInProcessCache = value;
     323
     324    // No point in doing anything else if the process is about to shut down.
     325    ASSERT(willShutDown == WillShutDown::No || !value);
     326    if (willShutDown == WillShutDown::Yes)
     327        return;
    323328
    324329    send(Messages::WebProcess::SetIsInProcessCache(m_isInProcessCache), 0);
  • trunk/Source/WebKit/UIProcess/WebProcessProxy.h

    r286455 r286800  
    157157    WebCore::RegistrableDomain registrableDomain() const { return m_registrableDomain.value_or(WebCore::RegistrableDomain { }); }
    158158    const std::optional<WebCore::RegistrableDomain>& optionalRegistrableDomain() const { return m_registrableDomain; }
    159     void setIsInProcessCache(bool);
     159
     160    enum class WillShutDown : bool { No, Yes };
     161    void setIsInProcessCache(bool, WillShutDown = WillShutDown::No);
    160162    bool isInProcessCache() const { return m_isInProcessCache; }
    161163
Note: See TracChangeset for help on using the changeset viewer.