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

Changeset 282241 in webkit


Ignore:
Timestamp:
Sep 9, 2021, 3:24:42 PM (5 years ago)
Author:
Chris Dumez
Message:

Potential crash under CachedRawResource::didAddClient()
​https://bugs.webkit.org/show_bug.cgi?id=230121
<rdar://82936913>

Reviewed by Alex Christensen.

In r280083, I tried to address this crash by holding a strong reference
to the SharedBuffer before calling forEachSegment() on it. However, the
crash is still happening after this fix.

My suspicion is that the SharedBuffer's internal m_segments vector gets
modified as we iterate over it. As a result, I am reverting r280083 and
iterating over a copy of m_segments in forEachSegment() instead.

No new tests, we haven't been able to reproduce.

  • WebCore.xcodeproj/project.pbxproj:
  • loader/cache/CachedRawResource.cpp:

(WebCore::CachedRawResource::didAddClient):

  • platform/SharedBuffer.cpp:

(WebCore::SharedBuffer::forEachSegment const):

Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r282237 r282241  
     12021-09-09  Chris Dumez  <cdumez@apple.com>
     2
     3        Potential crash under CachedRawResource::didAddClient()
     4        https://bugs.webkit.org/show_bug.cgi?id=230121
     5        <rdar://82936913>
     6
     7        Reviewed by Alex Christensen.
     8
     9        In r280083, I tried to address this crash by holding a strong reference
     10        to the SharedBuffer before calling forEachSegment() on it. However, the
     11        crash is still happening after this fix.
     12
     13        My suspicion is that the SharedBuffer's internal m_segments vector gets
     14        modified as we iterate over it. As a result, I am reverting r280083 and
     15        iterating over a copy of m_segments in forEachSegment() instead.
     16
     17        No new tests, we haven't been able to reproduce.
     18
     19        * WebCore.xcodeproj/project.pbxproj:
     20        * loader/cache/CachedRawResource.cpp:
     21        (WebCore::CachedRawResource::didAddClient):
     22        * platform/SharedBuffer.cpp:
     23        (WebCore::SharedBuffer::forEachSegment const):
     24
    1252021-09-09  Fujii Hironori  <Hironori.Fujii@sony.com>
    226
  • trunk/Source/WebCore/loader/cache/CachedRawResource.cpp

    r280083 r282241  
    168168            if (!hasClient(*client))
    169169                return;
    170             if (auto data = m_data) {
    171                 data->forEachSegment([&](auto& segment) {
     170            if (m_data) {
     171                m_data->forEachSegment([&](auto& segment) {
    172172                    if (hasClient(*client))
    173173                        client->dataReceived(*this, segment.data(), segment.size());
  • trunk/Source/WebCore/platform/SharedBuffer.cpp

    r280260 r282241  
    239239void SharedBuffer::forEachSegment(const Function<void(const Span<const uint8_t>&)>& apply) const
    240240{
    241     for (auto& segment : m_segments)
     241    auto segments = m_segments;
     242    for (auto& segment : segments)
    242243        apply(Span { segment.segment->data(), segment.segment->size() });
    243244}
Note: See TracChangeset for help on using the changeset viewer.