Bug 241666 - ConnectionCocoa doesn't receive disconnect notifications before the client has finished initializing
Summary: ConnectionCocoa doesn't receive disconnect notifications before the client ha...
Alias: None
Product: WebKit
Classification: Unclassified
Component: Platform (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Matt Woodrow
Keywords: InRadar
Depends on:
Reported: 2022-06-15 18:15 PDT by Matt Woodrow
Modified: 2022-06-21 18:06 PDT (History)
1 user (show)

See Also:


Note You need to log in before you can comment on or make changes to this bug.
Description Matt Woodrow 2022-06-15 18:15:42 PDT

Creating a server/client Connection requires a roundtrip from the server to the client. The server side allocates a port with receive rights, and sends this to the destination process (in the WebContent<->GPUP case, this goes via the UI process) as a port with send rights. Upon receiving this, the client also allocates a receive port, and sends the send right to the server via the send right it received upon initialisation. Once the server receives this, we have a fully initialised bi-directional connection.

The handler for detecting disconnections (the client process crashing) is part of the send right that the server receives at the last stage of connection. This means that if the remote process crashes before we've finished the round-trip, then we never get notified, and the originating process can end up stuck waiting forever.

We can fix this by temporarily adding a notifications request to the receive port, and listening for MACH_NOTIFY_NO_SENDERS, until we get a send port. Bug 160806 handled a similar case, for process launch connections.
Comment 1 Matt Woodrow 2022-06-15 18:32:35 PDT
Pull request: https://github.com/WebKit/WebKit/pull/1564
Comment 2 EWS 2022-06-21 18:06:20 PDT
Committed r295707 (251712@main): <https://commits.webkit.org/251712@main>

Reviewed commits have been landed. Closing PR #1564 and removing active labels.