KSP crashes if `analyze` is called from a different thread
Open
bug
core
P4
- Dominant language
- Kotlin
- Stars
- 3.5k
- Forks
- 415
- Avg merge
- 1d 2h
- Merged PRs (30d)
- 53
Description
Given thread 1 spawns thread 2, and a symbol `S` is created in thread 1, then if thread 2 captures `S` and performs any query that requires an `analyze` block, then it crashes due to the `Resolver`'s `ktModule` being thread local.
Definition of `analyze`:
https://github.com/google/ksp/blob/98e422e6b32ba2f060d4e2ff20f7552321c2b8c2/kotlin-analysis-api/src/main/kotlin/com/google/devtools/ksp/impl/symbol/kotlin/util.kt#L332
Definition of `Resolver.ktModule`:
https://github.com/google/ksp/blob/98e422e6b32ba2f060d4e2ff20f7552321c2b8c2/kotlin-analysis-api/src/main/kotlin/com/google/devtools/ksp/impl/ResolverAAImpl.kt#L171
Contributor guide
Assessment
This issue has not been assessed yet.