Skip to content

ClassCastException in 0.30.2 after obfuscation #707

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

Closed
HotIceCream opened this issue Oct 15, 2018 · 2 comments
Closed

ClassCastException in 0.30.2 after obfuscation #707

HotIceCream opened this issue Oct 15, 2018 · 2 comments

Comments

@HotIceCream
Copy link

HotIceCream commented Oct 15, 2018

I have the crash in runtime in an obfuscated version of my android application.

The application contains simple code like:

launch {
    ...
    withContext(UI) { ... }
}

Stacktrace after retrace:

    java.lang.ClassCastException: kotlinx.coroutines.experimental.ay cannot be cast to kotlinx.coroutines.experimental.android.b
        at kotlinx.coroutines.experimental.android.HandlerContextKt.getUI(Unknown Source)
        at com.example.myapp.MainActivity$refreshCurrentAuthenticators$1.invoke(Unknown Source)
                                                                                     doResume
                                                                                     create
                                                                                     create
        at kotlin.coroutines.experimental.jvm.internal.CoroutineImpl.getContext(Unknown Source)
                                                                     resume
                                                                     resumeWithException
                                                                     doResume
                                                                     create
        at kotlinx.coroutines.experimental.DispatchedTask$DefaultImpls.getSuccessfulResult(Unknown Source)
                                                                       run
        at kotlinx.coroutines.experimental.DispatchedContinuation.run(Unknown Source)
        at kotlinx.coroutines.experimental.scheduling.Task.run(Unknown Source)
        at kotlinx.coroutines.experimental.scheduling.CoroutineScheduler.parkedWorkersStackTopUpdate(Unknown Source)
                                                                         parkedWorkersStackPush
                                                                         shutdown
                                                                         dispatch
                                                                         dispatch$default
                                                                         createTask$kotlinx_coroutines_core
                                                                         submitToLocalQueue
                                                                         runSafely
                                                                         access$getSchedulerName$p
                                                                         access$runSafely
                                                                         access$getMAX_PARK_TIME_NS$cp
                                                                         access$parkedWorkersStackPush
                                                                         access$parkedWorkersStackTopUpdate
        at kotlinx.coroutines.experimental.scheduling.CoroutineScheduler.parkedWorkersStackTopUpdate(Unknown Source)
                                                                         parkedWorkersStackPush
                                                                         shutdown
                                                                         dispatch
                                                                         dispatch$default
                                                                         createTask$kotlinx_coroutines_core
                                                                         submitToLocalQueue
                                                                         runSafely
                                                                         access$getSchedulerName$p
                                                                         access$runSafely
                                                                         access$getMAX_PARK_TIME_NS$cp
                                                                         access$parkedWorkersStackPush
                                                                         access$parkedWorkersStackTopUpdate
        at kotlinx.coroutines.experimental.scheduling.CoroutineScheduler$Worker.run(Unknown Source)

The application works well with 0.30.0 version
kotlin version 1.2.71
gradle 4.10.1
android gradle plugin 3.2.0
proguard-rules contains:

-keepclassmembernames class kotlinx.** {
    volatile <fields>;
}
@HotIceCream
Copy link
Author

I create a sample of crash in a release build:
https://github.com/HotIceCream/CoroutinesSimpleExample/blob/master/app/src/main/java/com/github/hoticecream/coroutinessimpleexample/MainActivity.kt#L17

@qwwdfsad
Copy link
Collaborator

Thank you for the reproducer.
It appears to be the same bug as in #657. Will be fixed in 1.0.0-RC, workaround is to add

-keepnames class kotlinx.coroutines.experimental.internal.MainDispatcherFactory {}

to your proguard rules.

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