Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CoroutinesInternalError: Fatal exception in coroutines machinery for DispatchedContinuation #2429

Closed
rohandhruva opened this issue Dec 4, 2020 · 2 comments

Comments

@rohandhruva
Copy link

rohandhruva commented Dec 4, 2020

We use coroutines in our Android app, and recently we've started to see crashes from what looks like the internal coroutines machinery.

kotlinx.coroutines.CoroutinesInternalError: Fatal exception in coroutines machinery for DispatchedContinuation[Dispatchers.Main, Continuation at com.app.myapp.widget.CustomTextView$getMeasuredSpannable$2@d593f0e]. Please read KDoc to 'handleFatalException' method and report this incident to maintainers
        at kotlinx.coroutines.DispatchedTask.handleFatalException$kotlinx_coroutines_core(DispatchedTask:144)
        at kotlinx.coroutines.DispatchedTask.run(DispatchedTask:115)
        at android.os.Handler.handleCallback(Handler.java:793)
        at android.os.Handler.dispatchMessage(Handler.java:98)
        at android.os.Looper.loop(Looper.java:173)
        at android.app.ActivityThread.main(ActivityThread.java:6698)
        at java.lang.reflect.Method.invoke(Method.java:-2)
        at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:782)

Caused by: java.lang.StackOverflowError: stack size 8MB

Full stack trace is here: https://gist.github.com/rohandhruva/d7a3d92244fd8ae1a592ab6e4211ca41

Few more crashes in the same crash cluster: https://gist.github.com/rohandhruva/b62ee9e79cfce45fc40ea8fd12fe5052
https://gist.github.com/rohandhruva/966139a91a3bc652c4d848a3c9cb3321

It looks like the crash happens when some internal code is trying to build a string for easier debugging. As you can see, some stack traces do go all the way up to CoroutinesInternalError, but some crash earlier with a StackOverflowError.

Versions:

org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.10
org.jetbrains.kotlin:kotlin-stdlib:1.4.10
org.jetbrains.kotlin:kotlin-stdlib-common:1.4.10
org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.4.10
org.jetbrains.kotlinx:kotlinx-coroutines-android:1.4.1
org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.1

We've not been able to get a standalone reproducer so far, but I'm still working on it. I'll also share the pseudo code of what we do in the custom widget in just a bit.

@mhernand40
Copy link

Possible dupe of #2371?

@rohandhruva
Copy link
Author

Thank you, @mhernand40 : it does look like a duplicate :) Looks like upgrading to 1.4.2 should fix this issue for us.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants