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

Changeset 182866 in webkit


Ignore:
Timestamp:
Apr 15, 2015, 3:56:56 PM (11 years ago)
Author:
ap@apple.com
Message:

No thread safety when passing ThreadableLoaderOptions from a worker thread
https://bugs.webkit.org/show_bug.cgi?id=143790

Reviewed by Geoffrey Garen.

  • loader/ThreadableLoader.h:
  • loader/ThreadableLoader.cpp: (WebCore::ThreadableLoaderOptions::isolatedCopy): Added.
  • loader/WorkerThreadableLoader.cpp:

(WebCore::WorkerThreadableLoader::MainThreadBridge::MainThreadBridge): Don't just send
a structure with strings to a different thread, that's bad.

  • platform/CrossThreadCopier.h: I think that this is dead code, but for this bug,

just removing a clearly wrong specialization.

Location:
trunk/Source/WebCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r182865 r182866  
     12015-04-15  Alexey Proskuryakov  <ap@apple.com>
     2
     3        No thread safety when passing ThreadableLoaderOptions from a worker thread
     4        https://bugs.webkit.org/show_bug.cgi?id=143790
     5
     6        Reviewed by Geoffrey Garen.
     7
     8        * loader/ThreadableLoader.h:
     9        * loader/ThreadableLoader.cpp: (WebCore::ThreadableLoaderOptions::isolatedCopy): Added.
     10
     11        * loader/WorkerThreadableLoader.cpp:
     12        (WebCore::WorkerThreadableLoader::MainThreadBridge::MainThreadBridge): Don't just send
     13        a structure with strings to a different thread, that's bad.
     14
     15        * platform/CrossThreadCopier.h: I think that this is dead code, but for this bug,
     16        just removing a clearly wrong specialization.
     17
    1182015-04-15  Alex Christensen  <achristensen@webkit.org>
    219
  • trunk/Source/WebCore/loader/ThreadableLoader.cpp

    r174225 r182866  
    5252}
    5353
     54std::unique_ptr<ThreadableLoaderOptions> ThreadableLoaderOptions::isolatedCopy() const
     55{
     56    std::unique_ptr<ThreadableLoaderOptions> copy = std::make_unique<ThreadableLoaderOptions>();
     57    copy->preflightPolicy = preflightPolicy;
     58    copy->crossOriginRequestPolicy = crossOriginRequestPolicy;
     59    if (securityOrigin)
     60        copy->securityOrigin = securityOrigin->isolatedCopy();
     61    copy->initiator = initiator.string().isolatedCopy();
     62    return copy;
     63}
     64
    5465PassRefPtr<ThreadableLoader> ThreadableLoader::create(ScriptExecutionContext* context, ThreadableLoaderClient* client, const ResourceRequest& request, const ThreadableLoaderOptions& options)
    5566{
  • trunk/Source/WebCore/loader/ThreadableLoader.h

    r181480 r182866  
    6464        ~ThreadableLoaderOptions();
    6565
     66        std::unique_ptr<ThreadableLoaderOptions> isolatedCopy() const;
     67
    6668        PreflightPolicy preflightPolicy; // If AccessControl is used, how to determine if a preflight is needed.
    6769        CrossOriginRequestPolicy crossOriginRequestPolicy;
  • trunk/Source/WebCore/loader/WorkerThreadableLoader.cpp

    r182707 r182866  
    9292
    9393    auto* requestData = request.copyData().release();
     94    auto* optionsCopy = options.isolatedCopy().release();
    9495    StringCapture capturedOutgoingReferrer(outgoingReferrer);
    95     m_loaderProxy.postTaskToLoader([this, requestData, options, capturedOutgoingReferrer](ScriptExecutionContext& context) {
     96    m_loaderProxy.postTaskToLoader([this, requestData, optionsCopy, capturedOutgoingReferrer](ScriptExecutionContext& context) {
    9697        ASSERT(isMainThread());
    9798        Document& document = downcast<Document>(context);
     
    99100        auto request = ResourceRequest::adopt(std::unique_ptr<CrossThreadResourceRequestData>(requestData));
    100101        request->setHTTPReferrer(capturedOutgoingReferrer.string());
     102
     103        auto options = std::unique_ptr<ThreadableLoaderOptions>(optionsCopy);
    101104
    102105        // FIXME: If the a site requests a local resource, then this will return a non-zero value but the sync path
    103106        // will return a 0 value. Either this should return 0 or the other code path should do a callback with
    104107        // a failure.
    105         m_mainThreadLoader = DocumentThreadableLoader::create(document, *this, *request, options);
     108        m_mainThreadLoader = DocumentThreadableLoader::create(document, *this, *request, *options);
    106109        ASSERT(m_mainThreadLoader);
    107110    });
  • trunk/Source/WebCore/platform/CrossThreadCopier.h

    r182707 r182866  
    9393    // To allow a type to be passed across threads using its copy constructor, add a forward declaration of the type and
    9494    // a CopyThreadCopierBase<false, false, TypeName> : public CrossThreadCopierPassThrough<TypeName> { }; to this file.
    95     template<> struct CrossThreadCopierBase<false, false, ThreadableLoaderOptions> : public CrossThreadCopierPassThrough<ThreadableLoaderOptions> {
    96     };
    97 
    9895    template<> struct CrossThreadCopierBase<false, false, IntRect> : public CrossThreadCopierPassThrough<IntRect> {
    9996    };
Note: See TracChangeset for help on using the changeset viewer.