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

Changeset 268910 in webkit


Ignore:
Timestamp:
Oct 23, 2020, 1:25:31 AM (6 years ago)
Author:
Carlos Garcia Campos
Message:

Merge r268906 - [SOUP] Fix crash in WebSocketTask
https://bugs.webkit.org/show_bug.cgi?id=217892

Patch by Michael Catanzaro <Michael Catanzaro> on 2020-10-23
Reviewed by Carlos Garcia Campos.

The WebSocketTask connects to the "starting" signal of its SoupMessage and never disconnects
this signal, which is only safe if it is guaranteed to outlive its SoupMessage. However, it
is not. We crash when the signal is emitted after the WebSocketTask is destroyed. To solve
this, we just need to disconnect the signal when required. Normally that would be done in
the destructor, but the WebSocketTask drops its ownership of the SoupMessage prior to that
point, so we need to disconnect on each possible paths.

  • NetworkProcess/soup/WebSocketTaskSoup.cpp:

(WebKit::WebSocketTask::~WebSocketTask):
(WebKit::WebSocketTask::didConnect):
(WebKit::WebSocketTask::didFail):

Location:
releases/WebKitGTK/webkit-2.30/Source/WebKit
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • releases/WebKitGTK/webkit-2.30/Source/WebKit/ChangeLog

    r268451 r268910  
     12020-10-23  Michael Catanzaro  <mcatanzaro@gnome.org>
     2
     3        [SOUP] Fix crash in WebSocketTask
     4        https://bugs.webkit.org/show_bug.cgi?id=217892
     5
     6        Reviewed by Carlos Garcia Campos.
     7
     8        The WebSocketTask connects to the "starting" signal of its SoupMessage and never disconnects
     9        this signal, which is only safe if it is guaranteed to outlive its SoupMessage. However, it
     10        is not. We crash when the signal is emitted after the WebSocketTask is destroyed. To solve
     11        this, we just need to disconnect the signal when required. Normally that would be done in
     12        the destructor, but the WebSocketTask drops its ownership of the SoupMessage prior to that
     13        point, so we need to disconnect on each possible paths.
     14
     15        * NetworkProcess/soup/WebSocketTaskSoup.cpp:
     16        (WebKit::WebSocketTask::~WebSocketTask):
     17        (WebKit::WebSocketTask::didConnect):
     18        (WebKit::WebSocketTask::didFail):
     19
    1202020-10-10  Adrian Perez de Castro  <aperez@igalia.com>
    221
  • releases/WebKitGTK/webkit-2.30/Source/WebKit/NetworkProcess/soup/WebSocketTaskSoup.cpp

    r267695 r268910  
    9090WebSocketTask::~WebSocketTask()
    9191{
     92    if (m_handshakeMessage)
     93        g_signal_handlers_disconnect_by_data(m_handshakeMessage.get(), this);
     94
    9295    cancel();
    9396}
     
    134137    response.updateFromSoupMessage(m_handshakeMessage.get());
    135138    m_channel.didReceiveHandshakeResponse(WTFMove(response));
     139    g_signal_handlers_disconnect_by_data(m_handshakeMessage.get(), this);
    136140    m_handshakeMessage = nullptr;
    137141}
     
    173177        response.updateFromSoupMessage(m_handshakeMessage.get());
    174178        m_channel.didReceiveHandshakeResponse(WTFMove(response));
     179        g_signal_handlers_disconnect_by_data(m_handshakeMessage.get(), this);
    175180        m_handshakeMessage = nullptr;
    176181    }
Note: See TracChangeset for help on using the changeset viewer.