Changeset 228469 in webkit


Ignore:
Timestamp:
Feb 14, 2018 10:27:37 AM (6 years ago)
Author:
jmarcell@apple.com
Message:

Cherry-pick r228435. rdar://problem/37538686

Location:
tags/Safari-605.1.27.2
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • tags/Safari-605.1.27.2/LayoutTests/ChangeLog

    r228280 r228469  
     12018-02-14  Jason Marcell  <jmarcell@apple.com>
     2
     3        Cherry-pick r228435. rdar://problem/37538686
     4
     5    2018-02-13  Antti Koivisto  <antti@apple.com>
     6
     7            Crash when breakpoint hit in unload handler
     8            https://bugs.webkit.org/show_bug.cgi?id=169855
     9            <rdar://problem/28683567>
     10
     11            Reviewed by Daniel Bates and Joseph Pecoraro.
     12
     13            * inspector/debugger/reload-paused-expected.txt: Added.
     14            * inspector/debugger/reload-paused.html: Added.
     15
    1162018-02-08  Ryan Haddad  <ryanhaddad@apple.com>
    217
  • tags/Safari-605.1.27.2/Source/WebCore/ChangeLog

    r228426 r228469  
     12018-02-14  Jason Marcell  <jmarcell@apple.com>
     2
     3        Cherry-pick r228435. rdar://problem/37538686
     4
     5    2018-02-13  Antti Koivisto  <antti@apple.com>
     6
     7            Crash when breakpoint hit in unload handler
     8            https://bugs.webkit.org/show_bug.cgi?id=169855
     9            <rdar://problem/28683567>
     10
     11            Reviewed by Daniel Bates.
     12
     13            Test: inspector/debugger/reload-paused.html
     14
     15            CachedRawResource::updateBuffer may generate unload event in client notify callback. If Inspector was
     16            paused, this even would spawn a nested runloop. CachedRawResource::finishLoading would get called in
     17            the nested loop, confusing the DocumentLoader state machine and resulting in crashes later.
     18
     19            * loader/cache/CachedRawResource.cpp:
     20            (WebCore::CachedRawResource::updateBuffer):
     21
     22            - Set a bit when entering the client callback.
     23            - Ensure we don't re-enter updateBuffer.
     24            - If finishLoading got delayed during client callback, do it at the end.
     25
     26            (WebCore::CachedRawResource::finishLoading):
     27
     28            If we are in updateBuffer client callback, save the buffer and bail out.
     29
     30            * loader/cache/CachedRawResource.h:
     31
    1322018-02-12  Jason Marcell  <jmarcell@apple.com>
    233
  • tags/Safari-605.1.27.2/Source/WebCore/loader/cache/CachedRawResource.cpp

    r224699 r228469  
    3434#include "SubresourceLoader.h"
    3535#include <wtf/CompletionHandler.h>
     36#include <wtf/SetForScope.h>
    3637#include <wtf/text/StringView.h>
    3738
     
    5657void CachedRawResource::updateBuffer(SharedBuffer& data)
    5758{
     59    // Skip any updateBuffers triggered from nested runloops. We'll have the complete buffer in finishLoading.
     60    if (m_inIncrementalDataNotify)
     61        return;
     62
    5863    CachedResourceHandle<CachedRawResource> protectedThis(this);
    5964    ASSERT(dataBufferingPolicy() == BufferData);
     
    6267    auto incrementalData = calculateIncrementalDataChunk(&data);
    6368    setEncodedSize(data.size());
    64     if (incrementalData)
     69    if (incrementalData) {
     70        SetForScope<bool> notifyScope(m_inIncrementalDataNotify, true);
    6571        notifyClientsDataWasReceived(incrementalData->data(), incrementalData->size());
     72    }
     73
    6674    if (dataBufferingPolicy() == DoNotBufferData) {
    6775        if (m_loader)
    6876            m_loader->setDataBufferingPolicy(DoNotBufferData);
    6977        clear();
    70         return;
    71     }
    72 
    73     CachedResource::updateBuffer(data);
     78    } else
     79        CachedResource::updateBuffer(data);
     80
     81    if (m_delayedFinishLoading) {
     82        auto delayedFinishLoading = std::exchange(m_delayedFinishLoading, std::nullopt);
     83        finishLoading(delayedFinishLoading->buffer.get());
     84    }
    7485}
    7586
     
    8394void CachedRawResource::finishLoading(SharedBuffer* data)
    8495{
     96    if (m_inIncrementalDataNotify) {
     97        // We may get here synchronously from updateBuffer() if the callback there ends up spinning a runloop.
     98        // In that case delay the call.
     99        m_delayedFinishLoading = std::make_optional(DelayedFinishLoading { data });
     100        return;
     101    };
    85102    CachedResourceHandle<CachedRawResource> protectedThis(this);
    86103    DataBufferingPolicy dataBufferingPolicy = this->dataBufferingPolicy();
  • tags/Safari-605.1.27.2/Source/WebCore/loader/cache/CachedRawResource.h

    r226508 r228469  
    7676    unsigned long m_identifier;
    7777    bool m_allowEncodedDataReplacement;
     78    bool m_inIncrementalDataNotify { false };
    7879
    7980    struct RedirectPair {
     
    9091
    9192    Vector<RedirectPair> m_redirectChain;
     93
     94    struct DelayedFinishLoading {
     95        RefPtr<SharedBuffer> buffer;
     96    };
     97    std::optional<DelayedFinishLoading> m_delayedFinishLoading;
    9298};
    9399
Note: See TracChangeset for help on using the changeset viewer.