iOS 17: Accessing @Dependency inside withTaskGroup crashes with swift_task_reportIllegalTaskLocalBindingWithinWithTaskGroup #459
EmadBeyrami
started this conversation in
General
Replies: 1 comment
|
Hi @EmadBeyrami, this is just a bug in Swift that was fixed here and available in iOS 18. Not sure there's much we can say beyond that. Also your AI summary should mention that this was a Swift bug that was fixed, not a swift-dependencies bug, and that it's perfectly fine to access dependencies in try await withThrowingTaskGroup(of: Bool.self) { group in
group.addTask {
try await connectionClient.isAvailable() ✅
}
}And further (I would have to double check), I believe moving the capture to try await withThrowingTaskGroup(of: Bool.self) { [connectionClient] group in
group.addTask {
try await connectionClient.isAvailable() ✅
}
let state = try await connectionClient.currentState() ✅
}But again, I would double check that before assuming that works. |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Hi 👋
I recently ran into an interesting issue while using
swift-dependenciesand wanted to check whether this is expected behavior or if it's something worth documenting.The issue
On iOS 17, accessing a
@Dependencyfrom within the body ofwithTaskGroup(orwithThrowingTaskGroup) causes a runtime trap:For example:
The workaround is to resolve the dependency before entering the task group:
Observations
swift_task_reportIllegalTaskLocalBindingWithinWithTaskGroupQuestion
Is this expected due to how
swift-dependenciesinteracts with Swift's task-local values on the iOS 17 concurrency runtime?If so, would it make sense to mention this in the documentation? It took me quite a while to track down because the code compiles cleanly and only fails on iOS 17.
I also wrote up the investigation here if it's useful:
https://dev.to/emadbeyrami/the-silent-ios-17-crash-hiding-in-dependency-and-withtaskgroup-g8c
Thanks!
All reactions