Skip to content

fix(xpc): honor request timeouts#1965

Draft
stephenlclarke wants to merge 1 commit into
apple:mainfrom
stephenlclarke:fix/xpc-request-timeout
Draft

fix(xpc): honor request timeouts#1965
stephenlclarke wants to merge 1 commit into
apple:mainfrom
stephenlclarke:fix/xpc-request-timeout

Conversation

@stephenlclarke

Copy link
Copy Markdown

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update

Motivation and Context

apple/container#1927 documents a copy-out stall that can leave a container cp request waiting without a response. apple/containerization#799 addresses the guest-side lifecycle lock responsible for that stall. This PR makes the apple/container client's existing response timeout a reliable safeguard when a peer still does not reply.

XPCClient.send races a timeout task against an XPC reply task. The reply task waits in a checked continuation, but an XPC reply callback does not observe task cancellation. When the timeout wins, that continuation remained suspended and the task group continued to wait indefinitely.

This change uses a locked, one-shot continuation bridge: cancellation resumes it exactly once, and any later XPC reply is ignored. The scope is intentionally limited to cancellable request handling; it does not include the unrelated unknown-route behaviour proposed in #1862.

Testing

  • Tested locally
  • Added/updated tests
  • Added/updated docs (not needed: no public API or CLI behaviour changes)

Validation

  • swift test --disable-automatic-resolution -Xswiftc -warnings-as-errors --filter XPCClientTests — 5/5 passed. These exercise a real anonymous XPC endpoint: response timeout, direct caller cancellation, cancellation before continuation storage, client reuse, and late replies.
  • make test — passed: 570 tests in 71 suites (plus 94 XCTest cases).
  • make check — passed (Swift format and license-header checks).
  • git diff --check — passed.
  • make APP_ROOT=… LOG_ROOT=… SCRATCH_ROOT=… all integration — executed the VM integration suite. Warmup passed; the default-width run had three unrelated TCP-forwarding retries fail. Rerunning those three serially passed. A broader serial TestCLIRunCommand rerun was blocked before execution for its other cases because ghcr.io/linuxcontainers/alpine:3.20 was unavailable in the test environment.

Related

The XPC reply continuation did not observe task cancellation, so a configured client timeout could not complete until the server replied. Resume the continuation exactly once when cancellation wins and ignore late replies.

Refs: apple#1927
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant