Changeset 263996 in webkit


Ignore:
Timestamp:
Jul 6, 2020, 4:30:05 PM (5 years ago)
Author:
Chris Dumez
Message:

Regression(r249303) Crash under NetworkLoad::NetworkLoad()
https://bugs.webkit.org/show_bug.cgi?id=214008
<rdar://problem/64853936>

Reviewed by Alex Christensen.

  • NetworkProcess/cache/NetworkCacheSpeculativeLoad.cpp:

(WebKit::NetworkCache::SpeculativeLoad::SpeculativeLoad):
Do some hardening and fail the SpeculativeLoad if the network session is null, instead of dereferencing
the network session unconditionally. The NetworkCache owns the NetworkCacheSpeculativeLoadManager and
the NetworkCache is RefCounted so it may outlive its NetworkSession in theory and schedule speculative
loads for a session that was just destroyed.

  • NetworkProcess/cache/NetworkCacheSpeculativeLoadManager.cpp:

(WebKit::NetworkCache::SpeculativeLoadManager::registerLoad):
(WebKit::NetworkCache::SpeculativeLoadManager::preloadEntry):

  • NetworkProcess/cache/NetworkCacheSpeculativeLoadManager.h:

Capture weakThis in a few lambda and check it when the lambda gets called. It looked unsafe so I
decided to do some hardening.

Location:
trunk/Source/WebKit
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r263991 r263996  
     12020-07-06  Chris Dumez  <cdumez@apple.com>
     2
     3        Regression(r249303) Crash under NetworkLoad::NetworkLoad()
     4        https://bugs.webkit.org/show_bug.cgi?id=214008
     5        <rdar://problem/64853936>
     6
     7        Reviewed by Alex Christensen.
     8
     9        * NetworkProcess/cache/NetworkCacheSpeculativeLoad.cpp:
     10        (WebKit::NetworkCache::SpeculativeLoad::SpeculativeLoad):
     11        Do some hardening and fail the SpeculativeLoad if the network session is null, instead of dereferencing
     12        the network session unconditionally. The NetworkCache owns the NetworkCacheSpeculativeLoadManager and
     13        the NetworkCache is RefCounted so it may outlive its NetworkSession in theory and schedule speculative
     14        loads for a session that was just destroyed.
     15
     16        * NetworkProcess/cache/NetworkCacheSpeculativeLoadManager.cpp:
     17        (WebKit::NetworkCache::SpeculativeLoadManager::registerLoad):
     18        (WebKit::NetworkCache::SpeculativeLoadManager::preloadEntry):
     19        * NetworkProcess/cache/NetworkCacheSpeculativeLoadManager.h:
     20        Capture weakThis in a few lambda and check it when the lambda gets called. It looked unsafe so I
     21        decided to do some hardening.
     22
    1232020-07-06  Peng Liu  <peng.liu6@apple.com>
    224
  • trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheSpeculativeLoad.cpp

    r260031 r263996  
    5252    ASSERT(!m_cacheEntry || m_cacheEntry->needsValidation());
    5353
     54    auto* networkSession = m_cache->networkProcess().networkSession(m_cache->sessionID());
     55    if (!networkSession) {
     56        RunLoop::main().dispatch([completionHandler = WTFMove(m_completionHandler)]() mutable {
     57            completionHandler(nullptr);
     58        });
     59        return;
     60    }
     61
    5462    NetworkLoadParameters parameters;
    5563    parameters.webPageProxyID = globalFrameID.webPageProxyID;
     
    6169    parameters.request = m_originalRequest;
    6270    parameters.isNavigatingToAppBoundDomain = isNavigatingToAppBoundDomain;
    63     m_networkLoad = makeUnique<NetworkLoad>(*this, nullptr, WTFMove(parameters), *cache.networkProcess().networkSession(cache.sessionID()));
     71    m_networkLoad = makeUnique<NetworkLoad>(*this, nullptr, WTFMove(parameters), *networkSession);
    6472}
    6573
  • trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheSpeculativeLoadManager.cpp

    r261405 r263996  
    368368
    369369        // Retrieve the subresources entry if it exists to start speculative revalidation and to update it.
    370         retrieveSubresourcesEntry(resourceKey, [this, frameID, pendingFrameLoad = WTFMove(pendingFrameLoad), isNavigatingToAppBoundDomain](std::unique_ptr<SubresourcesEntry> entry) {
     370        retrieveSubresourcesEntry(resourceKey, [this, weakThis = makeWeakPtr(*this), frameID, pendingFrameLoad = WTFMove(pendingFrameLoad), isNavigatingToAppBoundDomain](std::unique_ptr<SubresourcesEntry> entry) {
     371            if (!weakThis)
     372                return;
     373
    371374            if (entry)
    372375                startSpeculativeRevalidation(frameID, *entry, isNavigatingToAppBoundDomain);
     
    560563    m_pendingPreloads.add(key, nullptr);
    561564   
    562     retrieveEntryFromStorage(subresourceInfo, [this, key, subresourceInfo, frameID, isNavigatingToAppBoundDomain](std::unique_ptr<Entry> entry) {
     565    retrieveEntryFromStorage(subresourceInfo, [this, weakThis = makeWeakPtr(*this), key, subresourceInfo, frameID, isNavigatingToAppBoundDomain](std::unique_ptr<Entry> entry) {
     566        if (!weakThis)
     567            return;
     568
    563569        ASSERT(!m_pendingPreloads.get(key));
    564570        bool removed = m_pendingPreloads.remove(key);
  • trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheSpeculativeLoadManager.h

    r260031 r263996  
    3434#include <wtf/HashMap.h>
    3535#include <wtf/Vector.h>
     36#include <wtf/WeakPtr.h>
    3637
    3738namespace WebKit {
     
    4445class SubresourcesEntry;
    4546
    46 class SpeculativeLoadManager {
     47class SpeculativeLoadManager : public CanMakeWeakPtr<SpeculativeLoadManager> {
    4748    WTF_MAKE_FAST_ALLOCATED;
    4849public:
Note: See TracChangeset for help on using the changeset viewer.