Title: [184081] releases/WebKitGTK/webkit-2.8/Source/WebCore
Revision
184081
Author
[email protected]
Date
2015-05-11 05:01:21 -0700 (Mon, 11 May 2015)

Log Message

Merge r182866 - 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.

Modified Paths

Diff

Modified: releases/WebKitGTK/webkit-2.8/Source/WebCore/ChangeLog (184080 => 184081)


--- releases/WebKitGTK/webkit-2.8/Source/WebCore/ChangeLog	2015-05-11 12:00:19 UTC (rev 184080)
+++ releases/WebKitGTK/webkit-2.8/Source/WebCore/ChangeLog	2015-05-11 12:01:21 UTC (rev 184081)
@@ -1,3 +1,20 @@
+2015-04-15  Alexey Proskuryakov  <[email protected]>
+
+        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.
+
 2015-04-13  Joonghun Park  <[email protected]>
 
         Use std::unique_ptr instead of PassOwnPtr|OwnPtr for ResourceResponse

Modified: releases/WebKitGTK/webkit-2.8/Source/WebCore/loader/ThreadableLoader.cpp (184080 => 184081)


--- releases/WebKitGTK/webkit-2.8/Source/WebCore/loader/ThreadableLoader.cpp	2015-05-11 12:00:19 UTC (rev 184080)
+++ releases/WebKitGTK/webkit-2.8/Source/WebCore/loader/ThreadableLoader.cpp	2015-05-11 12:01:21 UTC (rev 184081)
@@ -51,6 +51,17 @@
 {
 }
 
+std::unique_ptr<ThreadableLoaderOptions> ThreadableLoaderOptions::isolatedCopy() const
+{
+    std::unique_ptr<ThreadableLoaderOptions> copy = std::make_unique<ThreadableLoaderOptions>();
+    copy->preflightPolicy = preflightPolicy;
+    copy->crossOriginRequestPolicy = crossOriginRequestPolicy;
+    if (securityOrigin)
+        copy->securityOrigin = securityOrigin->isolatedCopy();
+    copy->initiator = initiator.string().isolatedCopy();
+    return copy;
+}
+
 PassRefPtr<ThreadableLoader> ThreadableLoader::create(ScriptExecutionContext* context, ThreadableLoaderClient* client, const ResourceRequest& request, const ThreadableLoaderOptions& options)
 {
     ASSERT(client);

Modified: releases/WebKitGTK/webkit-2.8/Source/WebCore/loader/ThreadableLoader.h (184080 => 184081)


--- releases/WebKitGTK/webkit-2.8/Source/WebCore/loader/ThreadableLoader.h	2015-05-11 12:00:19 UTC (rev 184080)
+++ releases/WebKitGTK/webkit-2.8/Source/WebCore/loader/ThreadableLoader.h	2015-05-11 12:01:21 UTC (rev 184081)
@@ -66,6 +66,8 @@
         ThreadableLoaderOptions();
         ~ThreadableLoaderOptions();
 
+        std::unique_ptr<ThreadableLoaderOptions> isolatedCopy() const;
+
         PreflightPolicy preflightPolicy; // If AccessControl is used, how to determine if a preflight is needed.
         CrossOriginRequestPolicy crossOriginRequestPolicy;
         RefPtr<SecurityOrigin> securityOrigin;

Modified: releases/WebKitGTK/webkit-2.8/Source/WebCore/loader/WorkerThreadableLoader.cpp (184080 => 184081)


--- releases/WebKitGTK/webkit-2.8/Source/WebCore/loader/WorkerThreadableLoader.cpp	2015-05-11 12:00:19 UTC (rev 184080)
+++ releases/WebKitGTK/webkit-2.8/Source/WebCore/loader/WorkerThreadableLoader.cpp	2015-05-11 12:01:21 UTC (rev 184081)
@@ -91,18 +91,21 @@
     ASSERT(m_workerClientWrapper.get());
 
     auto* requestData = request.copyData().release();
+    auto* optionsCopy = options.isolatedCopy().release();
     StringCapture capturedOutgoingReferrer(outgoingReferrer);
-    m_loaderProxy.postTaskToLoader([this, requestData, options, capturedOutgoingReferrer](ScriptExecutionContext& context) {
+    m_loaderProxy.postTaskToLoader([this, requestData, optionsCopy, capturedOutgoingReferrer](ScriptExecutionContext& context) {
         ASSERT(isMainThread());
         Document& document = downcast<Document>(context);
 
         auto request = ResourceRequest::adopt(std::unique_ptr<CrossThreadResourceRequestData>(requestData));
         request->setHTTPReferrer(capturedOutgoingReferrer.string());
 
+        auto options = std::unique_ptr<ThreadableLoaderOptions>(optionsCopy);
+
         // FIXME: If the a site requests a local resource, then this will return a non-zero value but the sync path
         // will return a 0 value. Either this should return 0 or the other code path should do a callback with
         // a failure.
-        m_mainThreadLoader = DocumentThreadableLoader::create(document, *this, *request, options);
+        m_mainThreadLoader = DocumentThreadableLoader::create(document, *this, *request, *options);
         ASSERT(m_mainThreadLoader);
     });
 }

Modified: releases/WebKitGTK/webkit-2.8/Source/WebCore/platform/CrossThreadCopier.h (184080 => 184081)


--- releases/WebKitGTK/webkit-2.8/Source/WebCore/platform/CrossThreadCopier.h	2015-05-11 12:00:19 UTC (rev 184080)
+++ releases/WebKitGTK/webkit-2.8/Source/WebCore/platform/CrossThreadCopier.h	2015-05-11 12:01:21 UTC (rev 184081)
@@ -92,9 +92,6 @@
 
     // To allow a type to be passed across threads using its copy constructor, add a forward declaration of the type and
     // a CopyThreadCopierBase<false, false, TypeName> : public CrossThreadCopierPassThrough<TypeName> { }; to this file.
-    template<> struct CrossThreadCopierBase<false, false, ThreadableLoaderOptions> : public CrossThreadCopierPassThrough<ThreadableLoaderOptions> {
-    };
-
     template<> struct CrossThreadCopierBase<false, false, IntRect> : public CrossThreadCopierPassThrough<IntRect> {
     };
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to