Conversation
reply() force-unwrapped xpc_dictionary_create_reply, which returns NULL for messages sent without reply context, trapping the apiserver or any helper on a single one-way dictionary. Make reply() non-trapping with an empty-dictionary fallback, add canReply, and drop no-reply-context input in handleMessage/replyWithError after logging. Adds ContainerXPCTests with regression coverage, including a live connection-pair repro of the crash. Fixes apple#2281
Author
|
Hi @jglogan @katiewasnothere — I'm new around here and this is my first contribution, so please point me at anything I'm doing wrong. This one crashes I kept |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Type of Change
Motivation and Context
Fixes #2281.
XPCMessage.reply()force-unwrappedxpc_dictionary_create_reply(), which returnsNULLfor any message sent fire-and-forget viaxpc_connection_send_message. Every path inXPCServer.handleMessage— all four error paths throughreplyWithErrorplus every success path built by the route handlers (88reply()call sites across 13 files) — hits this, so one one-way dictionary from any same-uid process trapscontainer-apiserveror any helper (container-runtime-linux,container-network-vmnet,container-core-images,machine-apiserver) withFatal error: Unexpectedly found nilatXPCMessage.swift:60.The fix keeps the
reply()signature (no caller churn) but makes it non-trapping with an empty-dictionary fallback, adds acanReplycheck, and drops no-reply-context input inhandleMessage/replyWithErrorafter logging. Legitimate_with_replytraffic takes the identical code path as before.Testing
Verification done on
main@57f0b93, macOS 27.0, CommandLineTools Swift 6.4:reply()on the received dict): traps pre-fix (exit 133/SIGTRAP atXPCMessage.swift:60), passes post-fix with a usable fallback dictionary.ContainerXPCTestssuite (4 tests: no-reply-context detection, no-trap regression, round-trip, live connection-pair repro). Note: this box has CLT only, so the swift-testing suite itself was validated via equivalent standalone harnesses linked against the built modules — please let CI runContainerXPCTestsunder Xcode.swift buildgreen;swift format lint --strictclean on all touched files.