Repository navigation
Conversation
OnDeviceClient.isReachable() resumes a CheckedContinuation from the NWConnection state update handler. Clearing the handler before resuming isn't enough to guarantee a single resume: Network can already have another state change queued (for example .waiting followed by .failed) that still reaches the closure, and resuming twice traps with a continuation misuse error. Guard finish() with a one-shot flag so only the first result is used. Fixes altstoreio#1850
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.
fixes #1850
OnDeviceClient.isReachable()resumes aCheckedContinuationfrom theNWConnectionstate update handler. it clears the handler before resuming, but that doesn't guarantee a single resume: network can already have another state change queued (for example.waitingfollowed right away by.failed) that still reaches the closure, and resuming twice traps with a continuation misuse error.the crash log in #1850 is that trap:
CheckedContinuation.resume(returning:)calling_assertionFailure, on theio.altstore.reachability-probequeue.this guards
finish()with a one-shot flag (OSAllocatedUnfairLock), so only the first result is used. nothing else changes: the first result is handled exactly as before.validation:
swiftc -parse).finishcalls already queued: without the flag it aborts with "tried to resume its continuation more than once" (exit 133, sigtrap); with the flag it finishes normally.not validated:
NWConnectionfiring two states in a row. i ran the same probe code against unreachable hosts, 240 probes with and without the flag on macos, and neither version crashed, so this is a defensive fix for the trap in the report, not a confirmed root cause of why the handler is called twice on ios 27.2.ldidin AltSign doesn't find openssl's headers in my setup. the same construct (OSAllocatedUnfairLock.withLockinside a@Sendablelocal function) compiles on its own.