Title: [211734] trunk/Source/WebKit2
Revision
211734
Author
carlo...@webkit.org
Date
2017-02-06 10:00:52 -0800 (Mon, 06 Feb 2017)

Log Message

[Soup] Deadlock in NetworkProcess
https://bugs.webkit.org/show_bug.cgi?id=167876

Reviewed by Michael Catanzaro.

WebKitSoupRequestInputStream uses a read lock. What is happening is that webkitSoupRequestInputStreamAddData
takes the lock, and it calls webkitSoupRequestInputStreamPendingReadAsyncComplete with the lock help. That
causes webkitSoupRequestInputStreamReadAsync to be called again to read the next chunk, but in the same run loop
operation. We don't really need the read lock because both webkitSoupRequestInputStreamAddData and
webkitSoupRequestInputStreamReadAsync shoudl always be called from the main thread.

* WebProcess/soup/WebKitSoupRequestInputStream.cpp:
(webkitSoupRequestInputStreamReadAsync): Remove the read lock and assert if called from a secondary thread.
(webkitSoupRequestInputStreamAddData): Ditto.

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (211733 => 211734)


--- trunk/Source/WebKit2/ChangeLog	2017-02-06 17:49:18 UTC (rev 211733)
+++ trunk/Source/WebKit2/ChangeLog	2017-02-06 18:00:52 UTC (rev 211734)
@@ -1,3 +1,20 @@
+2017-02-06  Carlos Garcia Campos  <cgar...@igalia.com>
+
+        [Soup] Deadlock in NetworkProcess
+        https://bugs.webkit.org/show_bug.cgi?id=167876
+
+        Reviewed by Michael Catanzaro.
+
+        WebKitSoupRequestInputStream uses a read lock. What is happening is that webkitSoupRequestInputStreamAddData
+        takes the lock, and it calls webkitSoupRequestInputStreamPendingReadAsyncComplete with the lock help. That
+        causes webkitSoupRequestInputStreamReadAsync to be called again to read the next chunk, but in the same run loop
+        operation. We don't really need the read lock because both webkitSoupRequestInputStreamAddData and
+        webkitSoupRequestInputStreamReadAsync shoudl always be called from the main thread.
+
+        * WebProcess/soup/WebKitSoupRequestInputStream.cpp:
+        (webkitSoupRequestInputStreamReadAsync): Remove the read lock and assert if called from a secondary thread.
+        (webkitSoupRequestInputStreamAddData): Ditto.
+
 2017-02-03  Anders Carlsson  <ander...@apple.com>
 
         Guard and unguard ports in a much less intrusive way

Modified: trunk/Source/WebKit2/WebProcess/soup/WebKitSoupRequestInputStream.cpp (211733 => 211734)


--- trunk/Source/WebKit2/WebProcess/soup/WebKitSoupRequestInputStream.cpp	2017-02-06 17:49:18 UTC (rev 211733)
+++ trunk/Source/WebKit2/WebProcess/soup/WebKitSoupRequestInputStream.cpp	2017-02-06 18:00:52 UTC (rev 211734)
@@ -20,8 +20,7 @@
 #include "config.h"
 #include "WebKitSoupRequestInputStream.h"
 
-#include <wtf/Lock.h>
-#include <wtf/Threading.h>
+#include <wtf/MainThread.h>
 #include <wtf/glib/GRefPtr.h>
 #include <wtf/glib/GUniquePtr.h>
 
@@ -45,7 +44,6 @@
 
     GUniquePtr<GError> error;
 
-    Lock readLock;
     std::unique_ptr<AsyncReadData> pendingAsyncRead;
 };
 
@@ -85,11 +83,10 @@
 
 static void webkitSoupRequestInputStreamReadAsync(GInputStream* inputStream, void* buffer, gsize count, int /*priority*/, GCancellable* cancellable, GAsyncReadyCallback callback, gpointer userData)
 {
+    ASSERT(isMainThread());
     WebKitSoupRequestInputStream* stream = WEBKIT_SOUP_REQUEST_INPUT_STREAM(inputStream);
     GRefPtr<GTask> task = adoptGRef(g_task_new(stream, cancellable, callback, userData));
 
-    LockHolder locker(stream->priv->readLock);
-
     if (!webkitSoupRequestInputStreamHasDataToRead(stream) && !webkitSoupRequestInputStreamIsWaitingForData(stream)) {
         g_task_return_int(task.get(), 0);
         return;
@@ -149,11 +146,11 @@
 
 void webkitSoupRequestInputStreamAddData(WebKitSoupRequestInputStream* stream, const void* data, size_t dataLength)
 {
+    ASSERT(isMainThread());
+
     if (webkitSoupRequestInputStreamFinished(stream))
         return;
 
-    LockHolder locker(stream->priv->readLock);
-
     if (dataLength) {
         // Truncate the dataLength to the contentLength if it's known.
         if (stream->priv->contentLength && stream->priv->bytesReceived + dataLength > stream->priv->contentLength)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to