kotlinx.coroutines: java.lang.ClassCastException: kotlin.coroutines.jvm.internal.CompletedContinuation cannot be cast to kotlinx.coroutines.internal.DispatchedContinuation
21:05:05 ERROR: AndroidRuntime : kotlinx.coroutines.CoroutinesInternalError: Fatal exception in coroutines machinery for CancellableContinuation(DispatchedContinuation[Dispatchers.IO, Continuation at kotlinx.coroutines.channels.AbstractChannel.receiveCatching-JP2dKIU(AbstractChannel.kt:632)@8d8755]){Completed}@c3cb56a. Please read KDoc to 'handleFatalException' method and report this incident to maintainers
21:05:05 ERROR: AndroidRuntime : at kotlinx.coroutines.DispatchedTask.handleFatalException(DispatchedTask.kt:144)
21:05:05 ERROR: AndroidRuntime : at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:115)
21:05:05 ERROR: AndroidRuntime : at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:571)
21:05:05 ERROR: AndroidRuntime : at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:750)
21:05:05 ERROR: AndroidRuntime : at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:678)
21:05:05 ERROR: AndroidRuntime : at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:665)
21:05:05 ERROR: AndroidRuntime : Caused by: java.lang.ClassCastException: kotlin.coroutines.jvm.internal.CompletedContinuation cannot be cast to kotlinx.coroutines.internal.DispatchedContinuation
21:05:05 ERROR: AndroidRuntime : at kotlinx.coroutines.CoroutineDispatcher.releaseInterceptedContinuation(CoroutineDispatcher.kt:108)
21:05:05 ERROR: AndroidRuntime : at kotlin.coroutines.jvm.internal.ContinuationImpl.releaseIntercepted(ContinuationImpl.kt:118)
21:05:05 ERROR: AndroidRuntime : at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:39)
21:05:05 ERROR: AndroidRuntime : at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
21:05:05 ERROR: AndroidRuntime : ... 4 more
kotlin version: 1.5.10 coroutines version: 1.5.0
I’m not sure how to reproduce, it sometimes happens during espresso tests
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 22
- Comments: 20 (8 by maintainers)
Commits related to this issue
- Properly detect non-released reusable continuations in non-reusable ones and await for reusability to have a consistent state Fixes #2736 Fixes #2768 — committed to Kotlin/kotlinx.coroutines by qwwdfsad 3 years ago
- Properly detect non-released reusable continuations in non-reusable o… (#2772) * Properly detect non-released reusable continuations in non-reusable ones and await for reusability to have a consisten... — committed to Kotlin/kotlinx.coroutines by qwwdfsad 3 years ago
- Properly detect non-released reusable continuations in non-reusable o… (#2772) * Properly detect non-released reusable continuations in non-reusable ones and await for reusability to have a consisten... — committed to pablobaxter/kotlinx.coroutines by qwwdfsad 3 years ago
In our android app it crashes when using stateflow/sharedflow + debounce. So I was able to repro this with just launching ton of different coroutines which use stateflow+debounce.
Then I ran
TestRunner(scope).run()in Application.it’s always (5 out 5 launches) crashing with the following stacktrace:
@qwwdfsad it is, run it multiple times and sometimes it fails with exact classcastexception: to increase your chances (i don’t know why) run more coroutines:
produces
in most of the runs (and it fails faster)
It’s reproducible even without launching android app just by adding:
The fix will be released with Kotlin 1.5.20-RC (~roughly next week)
We still don’t have reproducible case but all of our crashes happen in background. Is it same for everyone?
It would be really helpful if anybody could provide a reproduced even if it’s a set of espresso tests that fail 1 in 1000 times. Without that, it’s quite hard to do anything meaningful about this error