@DependencyClient async closure parameters appear uninitialized / crash when accessed under Swift 6 #409
Replies: 1 comment
|
Hi @zangqilong198812, please provide a minimal project that reproduces this problem. It's not possible to diagnose from the code snippets you have provided. Also, I doubt this issue has anything to do with TCA, so I would focus on creating a repro that just uses Dependencies. And almost this exact issue came up recently, and it was released to Swift 5 mode. I know you say you are using Swift 6 mode, but your crash is basically identical and so that is why a reproducing project would be helpful for us to investigate. And further, if there really is an issue here it seems almost certainly a Swift bug, either in macros or its concurrency system. And so for now I am going to convert this to a discussion and we can continue the conversation over there. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Description
Summary
When using
@DependencyClientwith an async@Sendablefunction that takes multiple parameters, the generated closure sometimes crashes as soon as I touch the parameters inside theliveValueimplementation.printruns).<uninitialized>/ invalid memory.This happens only with the
@DependencyClientmacro. The same code path, when implemented as a manualDependencyKey(without@DependencyClient), does not show this behavior.Environment
pointfreeco/swift-dependenciesversion: 1.10pointfreeco/swift-composable-architectureversion: 1.23.1Code
Dependency definition
RAGEngineManager is an actor-based singleton, but the crash happens before it is used (just by printing text / id).
Usage in a reducer
Checklist
mainbranch of this package.Expected behavior
Actual behavior
When rag.index is called:
the output is:
There is no manual use of unsafe pointers, C APIs, or force-unwrapping in this path. The only thing that happens before the crash is trying to read text / id in the dependency closure.
Steps to reproduce
No response
Dependencies version information
1.10.0
Destination operating system
ios 26.0
Xcode version information
26.1.1
Swift Compiler version information
All reactions