Bug 241666

Summary: ConnectionCocoa doesn't receive disconnect notifications before the client has finished initializing
Product: WebKit Reporter: Matt Woodrow <mattwoodrow>
Component: PlatformAssignee: Matt Woodrow <mattwoodrow>
Status: RESOLVED FIXED    
Severity: Normal CC: webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
See Also: https://bugs.webkit.org/show_bug.cgi?id=160806

Description Matt Woodrow 2022-06-15 18:15:42 PDT
<rdar://94628205>

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.