Changeset 233939 in webkit


Ignore:
Timestamp:
Jul 18, 2018 4:13:36 PM (6 years ago)
Author:
Chris Dumez
Message:

WebContent crash in WebProcess::ensureNetworkProcessConnection
https://bugs.webkit.org/show_bug.cgi?id=187791
<rdar://problem/41995022>

Reviewed by Ryosuke Niwa.

If the WebProcessProxy::GetNetworkProcessConnection synchronous IPC between the WebProcess
and the UIProcess succeeded but we received an invalid connection identifier, then try
once more. This may indicate the network process has crashed, in which case it will be
relaunched.

  • WebProcess/WebProcess.cpp:

(WebKit::getNetworkProcessConnection):
(WebKit::WebProcess::ensureNetworkProcessConnection):

Location:
trunk/Source/WebKit
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r233932 r233939  
     12018-07-18  Chris Dumez  <cdumez@apple.com>
     2
     3        WebContent crash in WebProcess::ensureNetworkProcessConnection
     4        https://bugs.webkit.org/show_bug.cgi?id=187791
     5        <rdar://problem/41995022>
     6
     7        Reviewed by Ryosuke Niwa.
     8
     9        If the WebProcessProxy::GetNetworkProcessConnection synchronous IPC between the WebProcess
     10        and the UIProcess succeeded but we received an invalid connection identifier, then try
     11        once more. This may indicate the network process has crashed, in which case it will be
     12        relaunched.
     13
     14        * WebProcess/WebProcess.cpp:
     15        (WebKit::getNetworkProcessConnection):
     16        (WebKit::WebProcess::ensureNetworkProcessConnection):
     17
    1182018-07-18  Per Arne Vollan  <pvollan@apple.com>
    219
  • trunk/Source/WebKit/WebProcess/WebProcess.cpp

    r233784 r233939  
    10981098}
    10991099
     1100static IPC::Connection::Identifier getNetworkProcessConnection(IPC::Connection& connection)
     1101{
     1102    IPC::Attachment encodedConnectionIdentifier;
     1103    if (!connection.sendSync(Messages::WebProcessProxy::GetNetworkProcessConnection(), Messages::WebProcessProxy::GetNetworkProcessConnection::Reply(encodedConnectionIdentifier), 0, Seconds::infinity(), IPC::SendSyncOption::DoNotProcessIncomingMessagesWhenWaitingForSyncReply)) {
     1104#if PLATFORM(GTK) || PLATFORM(WPE)
     1105        // GTK+ and WPE ports don't exit on send sync message failure.
     1106        // In this particular case, the network process can be terminated by the UI process while the
     1107        // Web process is still initializing, so we always want to exit instead of crashing. This can
     1108        // happen when the WebView is created and then destroyed quickly.
     1109        // See https://bugs.webkit.org/show_bug.cgi?id=183348.
     1110        exit(0);
     1111#else
     1112        CRASH();
     1113#endif
     1114    }
     1115
     1116#if USE(UNIX_DOMAIN_SOCKETS)
     1117    return encodedConnectionIdentifier.releaseFileDescriptor();
     1118#elif OS(DARWIN)
     1119    return encodedConnectionIdentifier.port();
     1120#elif OS(WINDOWS)
     1121    return encodedConnectionIdentifier.handle();
     1122#else
     1123    ASSERT_NOT_REACHED();
     1124    return IPC::Connection::Identifier();
     1125#endif
     1126}
     1127
    11001128NetworkProcessConnection& WebProcess::ensureNetworkProcessConnection()
    11011129{
     
    11041132    // If we've lost our connection to the network process (e.g. it crashed) try to re-establish it.
    11051133    if (!m_networkProcessConnection) {
    1106         IPC::Attachment encodedConnectionIdentifier;
    1107 
    1108         if (!parentProcessConnection()->sendSync(Messages::WebProcessProxy::GetNetworkProcessConnection(), Messages::WebProcessProxy::GetNetworkProcessConnection::Reply(encodedConnectionIdentifier), 0, Seconds::infinity(), IPC::SendSyncOption::DoNotProcessIncomingMessagesWhenWaitingForSyncReply)) {
    1109 #if PLATFORM(GTK) || PLATFORM(WPE)
    1110             // GTK+ and WPE ports don't exit on send sync message failure.
    1111             // In this particular case, the network process can be terminated by the UI process while the
    1112             // Web process is still initializing, so we always want to exit instead of crashing. This can
    1113             // happen when the WebView is created and then destroyed quickly.
    1114             // See https://bugs.webkit.org/show_bug.cgi?id=183348.
    1115             exit(0);
    1116 #else
    1117             CRASH();
    1118 #endif
    1119         }
    1120 
    1121 #if USE(UNIX_DOMAIN_SOCKETS)
    1122         IPC::Connection::Identifier connectionIdentifier = encodedConnectionIdentifier.releaseFileDescriptor();
    1123 #elif OS(DARWIN)
    1124         IPC::Connection::Identifier connectionIdentifier(encodedConnectionIdentifier.port());
    1125 #elif OS(WINDOWS)
    1126         IPC::Connection::Identifier connectionIdentifier(encodedConnectionIdentifier.handle());
    1127 #else
    1128         ASSERT_NOT_REACHED();
    1129 #endif
     1134        IPC::Connection::Identifier connectionIdentifier = getNetworkProcessConnection(*parentProcessConnection());
     1135
     1136        // Retry once if the IPC to get the connectionIdentifier succeeded but the connectionIdentifier we received
     1137        // is invalid. This may indicate that the network process has crashed.
     1138        if (!IPC::Connection::identifierIsValid(connectionIdentifier))
     1139            connectionIdentifier = getNetworkProcessConnection(*parentProcessConnection());
     1140
    11301141        if (!IPC::Connection::identifierIsValid(connectionIdentifier))
    11311142            CRASH();
     1143
    11321144        m_networkProcessConnection = NetworkProcessConnection::create(connectionIdentifier);
    11331145    }
Note: See TracChangeset for help on using the changeset viewer.