kotlinx.coroutines.CoroutinesInternalError: Fatal exception in coroutines machinery for DispatchedContinuation

Created on 28 Aug 2019  路  4Comments  路  Source: Kotlin/kotlinx.coroutines

Hi there! I've managed to trigger a fatal exception inside coroutines on native:

kotlinx.coroutines.CoroutinesInternalError: Fatal exception in coroutines machinery for DispatchedContinuation[EventLoopImpl@2cbfc8a8, Continuation @ $cancellation works across performAndWait boundary$lambda-24$lambda-21$lambda-20COROUTINE$16]. Please read KDoc to 'handleFatalException' method and report this incident to maintainers

The issue is visible in the following PRs:

In both PRs, you can repro by running ./gradlew testIosSim (need Xcode installed to run tests). Please let me know what other info I can provide, and I'd love to work toward some kind of workaround! Thanks!

Most helpful comment

@zach-klippenstein We'll take a different path as a part of #462. All coroutine internals will keep their state in "freezable atomics", this will make them "freeze transparent". They will continue to work even when they are shared (frozen).

All 4 comments

Note that CI might be green on those PRs, but that's only because the error/exception is logged silently.

Figured this out. This is because I'm freezing coroutine internals that I shouldn't. this.ensureNeverFrozen (to protect against freezing the context) in runBlocking uncovered it. So my fault! Closing

@elizarov Could the coroutines library automatically call ensureNeverFrozen to protect itself on Native? Seems like this is something everyone working with this stuff could hit pretty easily.

@zach-klippenstein We'll take a different path as a part of #462. All coroutine internals will keep their state in "freezable atomics", this will make them "freeze transparent". They will continue to work even when they are shared (frozen).

Was this page helpful?
0 / 5 - 0 ratings