Kotlin / kotlinx.serialization

Kotlin multiplatform / multi-format serialization
Apache License 2.0
5.43k stars 622 forks source link

Primitives.kt RuntimeError: dereferencing a null pointer #2583

Open VladislavSumin opened 8 months ago

VladislavSumin commented 8 months ago

The kotlin-serialization library crashes with a null pointer exception when initializing the Serializer in the code of a third-party library compiled with an older version of kotlin. When using such Serializers directly in the code, there is no crash.

wasm stack trace ``` Primitives.kt:79 Uncaught (in promise) RuntimeError: dereferencing a null pointer at .kotlinx.serialization.internal.checkName (Primitives.kt:79:36) at .kotlinx.serialization.internal.PrimitiveDescriptorSafe (Primitives.kt:72:5) at .kotlinx.serialization.descriptors.PrimitiveSerialDescriptor (SerialDescriptors.kt:91:12) at .com.arkivanov.essenty.statekeeper.Serializer. (SerializableContainer.kt:66:53) at .com.arkivanov.essenty.statekeeper.Serializer_getInstance (vs-control-client-wasm-wasm-js.wasm:0x2f6155) at .com.arkivanov.decompose.router.children.Companion. (vs-control-client-wasm-wasm-js.wasm:0x2fccd2) at .com.arkivanov.decompose.router.children.Companion_getInstance (vs-control-client-wasm-wasm-js.wasm:0x2fcd08) at .com.arkivanov.decompose.router.children.childrenNavigator (vs-control-client-wasm-wasm-js.wasm:0x2fcab5) at .com.arkivanov.decompose.router.children.children (ChildrenFactory.kt:127:25) at .com.arkivanov.decompose.router.children.children$default (vs-control-client-wasm-wasm-js.wasm:0x2fc3ec) ```

Environment

sandwwraith commented 8 months ago

Do you have a project with a reproducer, by any chance? It's hard to tell what happened from the stacktrace alone.

VladislavSumin commented 8 months ago

Yes, I have a project with 100 percent reproduction. You need to rollback to the specified commit and call gradle :client:wasm:wasmJsBrowserDevelopmentRun. It crashes immediately at the start, you don’t need to do anything additional. If you roll back one more commit earlier, kotlin-beta01 will be there and everything works. Repo: https://github.com/VladislavSumin/vs-control Revision: c2257bc76d9a8ad68f1460e361dadb511593b1fa

ismai117 commented 8 months ago

I'm receiving the same error

dereferencing a null pointer RuntimeError: dereferencing a null pointer at .kotlinx.serialization.internal.checkName (http://localhost:8080/webApp-wasm.wasm:wasm-function[57078]:0x89fe45)

Shanezor12 commented 8 months ago

I'm also receiving a similar error with serialization and WASM when using Beta4

sandwwraith commented 8 months ago

I was able to reproduce the error, but it seems it is connected to Kotlin/WASM itself. Has anyone reported it to the YouTrack?

ismai117 commented 8 months ago

It seems to be fixed with Kotlin version 2.0.0-Beta5, and I no longer receive the error. If you want to use 2.0.0-Beta5, compose compiler 1.5.11-kt-2.0.0-Beta5 works. 

sandwwraith commented 8 months ago

@VladislavSumin Can you confirm that using 2.0.0-Beta5 indeed solves the issue?

VladislavSumin commented 7 months ago

@sandwwraith Yes I get the same error with the kotlin version Beta5