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

Rx WorkflowHost adapters swallow "Fatal" (as def'd by Rx2) exceptions from subscribers. #399

Closed
rjrjr opened this issue Jun 7, 2019 · 8 comments
Assignees
Labels
bug Something isn't working kotlin Affects the Kotlin library.

Comments

@rjrjr
Copy link
Contributor

rjrjr commented Jun 7, 2019

  • Build the Tic Tac Toe app from branch ray/DNM-swallowed-exception
  • Launch the app and login with a bad password, e.g. foo@bar / pass
  • Notice that you hang on the Loading screen when you should pop back to login.

Now uncomment the block at line 47 of MainActivity, to make another subscription to workflowRunner.renderings. Repeat the recipe, and crash (stack below).

I suspect that in the hang recipe this exception is being swallowed, but I haven't dug further yet.

Caused by: java.lang.ClassNotFoundException: Didn't find class "com.squareup.workflow.ui.backstack.ViewStateCache$prepareToUpdate$2$1" on path: DexPathList[[zip file "/data/app/com.squareup.sample.tictacworkflow-emIWXcG5jN7vKiZo1257Gg==/base.apk"],nativeLibraryDirectories=[/data/app/com.squareup.sample.tictacworkflow-emIWXcG5jN7vKiZo1257Gg==/lib/x86, /system/lib]]
   at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:134)
   at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
   at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
@rjrjr rjrjr added bug Something isn't working kotlin labels Jun 7, 2019
@zach-klippenstein zach-klippenstein self-assigned this Jun 7, 2019
@rjrjr
Copy link
Contributor Author

rjrjr commented Jun 7, 2019

The exception is pretty clearly a compiler bug, I'll get that reported. Goes away if I change the UpdateTools interface in ViewStateCache to a data class -- probably a problem w/anonymous objects in lambdas.

@rjrjr rjrjr removed the kotlin label Jun 7, 2019
@zach-klippenstein
Copy link
Collaborator

zach-klippenstein commented Jun 18, 2019

If I explicitly throw a RuntimeException just before running the lambda that triggers this exception, it crashes as expected.

IntelliJ will occasionally suck up all my CPU and hang while stepping around after the ClassNotFoundException gets thrown, so that's a good sign.

RxJava is seeing the error as a NoClassDefFoundError, which is a LinkageError, which means that Rx rethrows it directly and bypasses all the usual exception processing logic. Wondering if that might have something to do with it.

@zach-klippenstein
Copy link
Collaborator

I can't repro in a clean room project, and the code that it is occuring in (flatMapWorkflow) has been deleted, so I'm going to close this issue.

@zach-klippenstein
Copy link
Collaborator

I reproduced in unit tests: 86b82bc

Going to replicate these tests for (our internal-only, for now) RxWorkflowHost.

@zach-klippenstein zach-klippenstein changed the title WorkflowLayout or WorkflowRunnerViewModel swallowing exceptions? Rx WorkflowHost adapters swallow "Fatal" (as def'd by Rx2) exceptions from subscribers. Jun 19, 2019
@zach-klippenstein
Copy link
Collaborator

Working around this internally by checking for this condition and manually passing to the thread's UncaughtExceptionHandler if it will be swallowed.

I've also reproduced the bug in an isolated project and filed as Kotlin/kotlinx.coroutines#1297.

@rjrjr
Copy link
Contributor Author

rjrjr commented Jul 1, 2019

Finally got around to reporting the swallowed exception to JetBrains, https://youtrack.jetbrains.com/issue/KT-32351

@rjrjr
Copy link
Contributor Author

rjrjr commented Jul 1, 2019

@zach-klippenstein we can close this now, yeah?

@zach-klippenstein
Copy link
Collaborator

I want to leave this open until I'm able to remove our workarounds (I think using Flow should fix).

@zach-klippenstein zach-klippenstein added the kotlin Affects the Kotlin library. label Mar 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working kotlin Affects the Kotlin library.
Projects
None yet
Development

No branches or pull requests

2 participants