-
Notifications
You must be signed in to change notification settings - Fork 10.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Crash in destroy for AsyncChain2Sequence? #69367
Comments
This looks like a crash in |
@phausler could you take a look at this |
|
The root cause of the reported crash seems as if it is the destruction from the unfolding; my guess is that the iterator being sent is not actually Sendable and w/o the Sendable enforcements in place it is hitting a non-thread-safe usage of the capture of Erasing to an AnyAsyncSequence using AsyncStream as a vehicle via that type of pattern can easily lead to missteps as such. The |
here is the "corrected" code... however it would be considerably better to wait for the public init<S: AsyncSequence>(_ sequence: S) where S.Element == Element, S: Sendable {
let iterator = OSAllocatedUnfairLock<S.AsyncIterator?>(uncheckedState: nil)
self.init {
// NOTE: this has a time of check/time of use bug lurking
// if two tasks call next concurrently the iterator will
// be in the wrong state
var iter = iterator.withLock { $0 }
if iter == nil {
iter = sequence.makeAsyncIterator()
}
defer { iterator.withLockUnchecked { $0 = iter } }
return try await iter?.next()
}
} |
In what OS version of macOS, iOS, tvOS was this assert removed? |
Using 0.1.0 of the library I sometimes get a crash (EXC_BAD_ACCESS (code=1, address=0xf2575c505790)) in iterator next(), see example of call stack below (caught from Xcode while debugging). Any ideas what might cause this? In the call stack below I was using a type erasers from: https://github.com/pointfreeco/swift-concurrency-extras, such as:
We are also seeing Intel Macs running 12.x with this crash logs (release builds), not sure if they might be related:
The text was updated successfully, but these errors were encountered: