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

Changeset 280935 in webkit


Ignore:
Timestamp:
Aug 11, 2021, 3:33:17 PM (5 years ago)
Author:
ddkilzer@apple.com
Message:

ThreadSanitizer: data race in WTF::StringImpl::deref() under WebKit::NetworkCache::IOChannel::~IOChannel()
<https://webkit.org/b/229003>
<rdar://problem/81795626>

Reviewed by Chris Dumez.

Covered by 3245 layout tests running with TSan including:

http/wpt/service-workers/file-upload.html

  • NetworkProcess/cache/NetworkCacheIOChannel.h:

(WebKit::NetworkCache::IOChannel::open):

  • Update to use #pragma once.
  • Make an isolatedCopy() for m_path.

(WebKit::NetworkCache::IOChannel::IOChannel):

  • Switch to using an rvalue reference.
  • NetworkProcess/cache/NetworkCacheIOChannelCocoa.mm:

(WebKit::NetworkCache::IOChannel::IOChannel): Ditto.

  • NetworkProcess/cache/NetworkCacheIOChannelCurl.cpp:

(WebKit::NetworkCache::IOChannel::IOChannel): Ditto.

  • NetworkProcess/cache/NetworkCacheIOChannelGLib.cpp:

(WebKit::NetworkCache::IOChannel::IOChannel): Ditto.

  • Switch to use m_path instead of filePath to prevent use-after-move.
Location:
trunk/Source/WebKit
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r280934 r280935  
     12021-08-11  David Kilzer  <ddkilzer@apple.com>
     2
     3        ThreadSanitizer: data race in WTF::StringImpl::deref() under WebKit::NetworkCache::IOChannel::~IOChannel()
     4        <https://webkit.org/b/229003>
     5        <rdar://problem/81795626>
     6
     7        Reviewed by Chris Dumez.
     8
     9        Covered by 3245 layout tests running with TSan including:
     10            http/wpt/service-workers/file-upload.html
     11
     12        * NetworkProcess/cache/NetworkCacheIOChannel.h:
     13        (WebKit::NetworkCache::IOChannel::open):
     14        - Update to use #pragma once.
     15        - Make an isolatedCopy() for m_path.
     16        (WebKit::NetworkCache::IOChannel::IOChannel):
     17        - Switch to using an rvalue reference.
     18        * NetworkProcess/cache/NetworkCacheIOChannelCocoa.mm:
     19        (WebKit::NetworkCache::IOChannel::IOChannel): Ditto.
     20        * NetworkProcess/cache/NetworkCacheIOChannelCurl.cpp:
     21        (WebKit::NetworkCache::IOChannel::IOChannel): Ditto.
     22        * NetworkProcess/cache/NetworkCacheIOChannelGLib.cpp:
     23        (WebKit::NetworkCache::IOChannel::IOChannel): Ditto.
     24        - Switch to use m_path instead of filePath to prevent
     25          use-after-move.
     26
    1272021-08-11  Sihui Liu  <sihui_liu@apple.com>
    228
  • trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheIOChannel.h

    r278253 r280935  
    2424 */
    2525
    26 #ifndef NetworkCacheIOChannel_h
    27 #define NetworkCacheIOChannel_h
     26#pragma once
    2827
    2928#include "NetworkCacheData.h"
     
    4746public:
    4847    enum class Type { Read, Write, Create };
    49     static Ref<IOChannel> open(const String& file, Type type, std::optional<WorkQueue::QOS> qos = { }) { return adoptRef(*new IOChannel(file, type, qos)); }
     48    static Ref<IOChannel> open(const String& file, Type type, std::optional<WorkQueue::QOS> qos = { }) { return adoptRef(*new IOChannel(file.isolatedCopy(), type, qos)); }
    5049
    5150    // Using nullptr as queue submits the result to the main queue.
     
    6665
    6766private:
    68     IOChannel(const String& filePath, IOChannel::Type, std::optional<WorkQueue::QOS>);
     67    IOChannel(String&& filePath, IOChannel::Type, std::optional<WorkQueue::QOS>);
    6968
    7069#if USE(GLIB)
     
    8988};
    9089
    91 }
    92 }
    93 
    94 #endif
     90} // namespace NetworkCache
     91} // namespace WebKit
  • trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheIOChannelCocoa.mm

    r278253 r280935  
    5252}
    5353
    54 IOChannel::IOChannel(const String& filePath, Type type, std::optional<WorkQueue::QOS> qos)
    55     : m_path(filePath)
     54IOChannel::IOChannel(String&& filePath, Type type, std::optional<WorkQueue::QOS> qos)
     55    : m_path(WTFMove(filePath))
    5656    , m_type(type)
    5757{
    58     auto path = FileSystem::fileSystemRepresentation(filePath);
     58    auto path = FileSystem::fileSystemRepresentation(m_path);
    5959    int oflag;
    6060    mode_t mode;
  • trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheIOChannelCurl.cpp

    r278521 r280935  
    3232namespace NetworkCache {
    3333
    34 IOChannel::IOChannel(const String& filePath, Type type, std::optional<WorkQueue::QOS>)
    35     : m_path(filePath)
     34IOChannel::IOChannel(String&& filePath, Type type, std::optional<WorkQueue::QOS>)
     35    : m_path(WTFMove(filePath))
    3636    , m_type(type)
    3737{
     
    4848        break;
    4949    }
    50     m_fileDescriptor = FileSystem::openFile(filePath, mode);
     50    m_fileDescriptor = FileSystem::openFile(m_path, mode);
    5151}
    5252
  • trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheIOChannelGLib.cpp

    r278253 r280935  
    3838static const size_t gDefaultReadBufferSize = 4096;
    3939
    40 IOChannel::IOChannel(const String& filePath, Type type, std::optional<WorkQueue::QOS>)
    41     : m_path(filePath)
     40IOChannel::IOChannel(String&& filePath, Type type, std::optional<WorkQueue::QOS>)
     41    : m_path(WTFMove(filePath))
    4242    , m_type(type)
    4343{
    44     auto path = FileSystem::fileSystemRepresentation(filePath);
     44    auto path = FileSystem::fileSystemRepresentation(m_path);
    4545    GRefPtr<GFile> file = adoptGRef(g_file_new_for_path(path.data()));
    4646    switch (m_type) {
Note: See TracChangeset for help on using the changeset viewer.