Changeset 211734 in webkit


Ignore:
Timestamp:
Feb 6, 2017 10:00:52 AM (7 years ago)
Author:
Carlos Garcia Campos
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.

Location:
trunk/Source/WebKit2
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r211726 r211734  
     12017-02-06  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        [Soup] Deadlock in NetworkProcess
     4        https://bugs.webkit.org/show_bug.cgi?id=167876
     5
     6        Reviewed by Michael Catanzaro.
     7
     8        WebKitSoupRequestInputStream uses a read lock. What is happening is that webkitSoupRequestInputStreamAddData
     9        takes the lock, and it calls webkitSoupRequestInputStreamPendingReadAsyncComplete with the lock help. That
     10        causes webkitSoupRequestInputStreamReadAsync to be called again to read the next chunk, but in the same run loop
     11        operation. We don't really need the read lock because both webkitSoupRequestInputStreamAddData and
     12        webkitSoupRequestInputStreamReadAsync shoudl always be called from the main thread.
     13
     14        * WebProcess/soup/WebKitSoupRequestInputStream.cpp:
     15        (webkitSoupRequestInputStreamReadAsync): Remove the read lock and assert if called from a secondary thread.
     16        (webkitSoupRequestInputStreamAddData): Ditto.
     17
    1182017-02-03  Anders Carlsson  <andersca@apple.com>
    219
  • trunk/Source/WebKit2/WebProcess/soup/WebKitSoupRequestInputStream.cpp

    r194496 r211734  
    2121#include "WebKitSoupRequestInputStream.h"
    2222
    23 #include <wtf/Lock.h>
    24 #include <wtf/Threading.h>
     23#include <wtf/MainThread.h>
    2524#include <wtf/glib/GRefPtr.h>
    2625#include <wtf/glib/GUniquePtr.h>
     
    4645    GUniquePtr<GError> error;
    4746
    48     Lock readLock;
    4947    std::unique_ptr<AsyncReadData> pendingAsyncRead;
    5048};
     
    8684static void webkitSoupRequestInputStreamReadAsync(GInputStream* inputStream, void* buffer, gsize count, int /*priority*/, GCancellable* cancellable, GAsyncReadyCallback callback, gpointer userData)
    8785{
     86    ASSERT(isMainThread());
    8887    WebKitSoupRequestInputStream* stream = WEBKIT_SOUP_REQUEST_INPUT_STREAM(inputStream);
    8988    GRefPtr<GTask> task = adoptGRef(g_task_new(stream, cancellable, callback, userData));
    90 
    91     LockHolder locker(stream->priv->readLock);
    9289
    9390    if (!webkitSoupRequestInputStreamHasDataToRead(stream) && !webkitSoupRequestInputStreamIsWaitingForData(stream)) {
     
    150147void webkitSoupRequestInputStreamAddData(WebKitSoupRequestInputStream* stream, const void* data, size_t dataLength)
    151148{
     149    ASSERT(isMainThread());
     150
    152151    if (webkitSoupRequestInputStreamFinished(stream))
    153152        return;
    154 
    155     LockHolder locker(stream->priv->readLock);
    156153
    157154    if (dataLength) {
Note: See TracChangeset for help on using the changeset viewer.