Skip to content

Native Crash (SIGSEGV) when SerializersModule includes Polymorphic Type with Recursive List #1583

@ashish967

Description

@ashish967

experiencing a native crash (SIGSEGV) in our KMM application when using Zipline. The crash appears to be related to the registration of a specific polymorphic type (ColumnLayout) in the SerializersModule. This ColumnLayout contains a List where Widget is the polymorphic base interface, thus introducing a recursive polymorphic structure.

Steps to Reproduce:


import kotlinx.serialization.*
import kotlinx.serialization.modules.*

@Serializable
sealed interface Widget {
    val id: String?
}

@Serializable
@SerialName("text_widget")
data class TextWidget(
    val text: String,
    override val id: String? = null
) : Widget

@Serializable
@SerialName("column_layout")
data class ColumnLayout(
    val children: List<Widget>, // This field seems critical to the issue
    override val id: String? = null
) : Widget

// SerializersModule including the problematic ColumnLayout
val appSerializersModule = SerializersModule {
    polymorphic(Widget::class) {
        subclass(TextWidget::class)
        subclass(ColumnLayout::class) // Registering this is key to reproducing the crash
    }
}

@Serializable
data class PageData(
    val widget: Widget
)

// in zipline service
fun getPageState():Flow<PageState>

My observations -

  1. if remove column layout class from code then it starts working
  2. if I remove just subclass(ColumnLayout::class) and keep the ColumnLayout class then also crash happpens
  3. if I remove Flow as return type instead direct return PageState object then it starts working
  4. in above 3 case m returning PageState(TextWidget("a","b")) in service impl.

Crash log -

fatal signal 11 (SIGSEGV), code 2 (SEGV_ACCERR), fault addr 0x75801d0ffc in tid 26106 (Zipline), pid 26085 (testing.android)
2025-05-29 03:27:10.526 26123-26123 DEBUG                   pid-26123                            A  Cmdline: com.hyperboot.ziplinekmmtesting.android
2025-05-29 03:27:10.526 26123-26123 DEBUG                   pid-26123                            A  pid: 26085, tid: 26106, name: Zipline  >>> com.hyperboot.ziplinekmmtesting.android <<<
2025-05-29 03:27:10.527 26123-26123 DEBUG                   pid-26123                            A        #00 pc 00000000000552ec  /data/app/~~cB92TfEYe4dVgLm3zNwB2Q==/com.hyperboot.ziplinekmmtesting.android-8vslgtGdF3wyOhEW2nkNFQ==/base.apk!libquickjs.so (offset 0x74000) (JS_CallInternal+588) (BuildId: f905318366a13fac3eb8aae888c542cd07ede18b)
2025-05-29 03:27:10.527 26123-26123 DEBUG                   pid-26123                            A        #01 pc 000000000005622c  /data/app/~~cB92TfEYe4dVgLm3zNwB2Q==/com.hyperboot.ziplinekmmtesting.android-8vslgtGdF3wyOhEW2nkNFQ==/base.apk!libquickjs.so (offset 0x74000) (JS_CallInternal+4492) (BuildId: f905318366a13fac3eb8aae888c542cd07ede18b)
2025-05-29 03:27:10.527 26123-26123 DEBUG                   pid-26123                            A        #02 pc 000000000005622c  /data/app/~~cB92TfEYe4dVgLm3zNwB2Q==/com.hyperboot.ziplinekmmtesting.android-8vslgtGdF3wyOhEW2nkNFQ==/base.apk!libquickjs.so (offset 0x74000) (JS_CallInternal+4492) (BuildId: f905318366a13fac3eb8aae888c542cd07ede18b)
2025-05-29 03:27:10.527 26123-26123 DEBUG                   pid-26123                            A        #03 pc 0000000000096248  /data/app/~~cB92TfEYe4dVgLm3zNwB2Q==/com.hyperboot.ziplinekmmtesting.android-8vslgtGdF3wyOhEW2nkNFQ==/base.apk!libquickjs.so (offset 0x74000) (js_function_call+84) (BuildId: f905318366a13fac3eb8aae888c542cd07ede18b)
2025-05-29 03:27:10.527 26123-26123 DEBUG                   pid-26123                            A        #04 pc 0000000000049ea4  /data/app/~~cB92TfEYe4dVgLm3zNwB2Q==/com.hyperboot.ziplinekmmtesting.android-8vslgtGdF3wyOhEW2nkNFQ==/base.apk!libquickjs.so (offset 0x74000) (js_call_c_function+240) (BuildId: f905318366a13fac3eb8aae888c542cd07ede18b)
2025-05-29 03:27:10.527 26123-26123 DEBUG                   pid-26123                            A        #05 pc 000000000005539c  /data/app/~~cB92TfEYe4dVgLm3zNwB2Q==/com.hyperboot.ziplinekmmtesting.android-8vslgtGdF3wyOhEW2nkNFQ==/base.apk!libquickjs.so (offset 0x74000) (JS_CallInternal+764) (BuildId: f905318366a13fac3eb8aae888c542cd07ede18b)
2025-05-29 03:27:10.527 26123-26123 DEBUG                   pid-26123                            A        #06 pc 00000000000563b8  /data/app/~~cB92TfEYe4dVgLm3zNwB2Q==/com.hyperboot.ziplinekmmtesting.android-8vslgtGdF3wyOhEW2nkNFQ==/base.apk!libquickjs.so (offset 0x74000) (JS_CallInternal+4888) (BuildId: f905318366a13fac3eb8aae888c542cd07ede18b)
2025-05-29 03:27:10.527 26123-26123 DEBUG                   pid-26123                            A        #07 pc 000000000005d1a4  /data/app/~~cB92TfEYe4dVgLm3zNwB2Q==/com.hyperboot.ziplinekmmtesting.android-8vslgtGdF3wyOhEW2nkNFQ==/base.apk!libquickjs.so (offset 0x74000) (JS_CallConstructorInternal+272) (BuildId: f905318366a13fac3eb8aae888c542cd07ede18b)
2025-05-29 03:27:10.527 26123-26123 DEBUG                   pid-26123                            A        #08 pc 00000000000562fc  /data/app/~~cB92TfEYe4dVgLm3zNwB2Q==/com.hyperboot.ziplinekmmtesting.android-8vslgtGdF3wyOhEW2nkNFQ==/base.apk!libquickjs.so (offset 0x74000) (JS_CallInternal+4700) (BuildId: f905318366a13fac3eb8aae888c542cd07ede18b)
2025-05-29 03:27:10.528 26123-26123 DEBUG                   pid-26123                            A        #09 pc 000000000005622c  /data/app/~~cB92TfEYe4dVgLm3zNwB2Q==/com.hyperboot.ziplinekmmtesting.android-8vslgtGdF3wyOhEW2nkNFQ==/base.apk!libquickjs.so (offset 0x74000) (JS_CallInternal+4492) (BuildId: f905318366a13fac3eb8aae888c542cd07ede18b)
2025-05-29 03:27:10.528 26123-26123 DEBUG                   pid-26123                            A        #10 pc 000000000005622c  /data/app/~~cB92TfEYe4dVgLm3zNwB2Q==/com.hyperboot.ziplinekmmtesting.android-8vslgtGdF3wyOhEW2nkNFQ==/base.apk!libquickjs.so (offset 0x74000) (JS_CallInternal+4492) (BuildId: f905318366a13fac3eb8aae888c542cd07ede18b)
2025-05-29 03:27:10.528 26123-26123 DEBUG                   pid-26123                            A        #11 pc 000000000005622c  /data/app/~~cB92TfEYe4dVgLm3zNwB2Q==/com.hyperboot.ziplinekmmtesting.android-8vslgtGdF3wyOhEW2nkNFQ==/base.apk!libquickjs.so (offset 0x74000) (JS_CallInternal+4492) (BuildId: f905318366a13fac3eb8aae888c542cd07ede18b)
2025-05-29 03:27:10.528 26123-26123 DEBUG                   pid-26123                            A        #12 pc 000000000005622c  /data/app/~~cB92TfEYe4dVgLm3zNwB2Q==/com.hyperboot.ziplinekmmtesting.android-8vslgtGdF3wyOhEW2nkNFQ==/base.apk!libquickjs.so (offset 0x74000) (JS_CallInternal+4492) (BuildId: f905318366a13fac3eb8aae888c542cd07ede18b)
2025-05-29 03:27:10.528 26123-26123 DEBUG                   pid-26123                            A        #13 pc 000000000005622c  /data/app/~~cB92TfEYe4dVgLm3zNwB2Q==/com.hyperboot.ziplinekmmtesting.android-8vslgtGdF3wyOhEW2nkNFQ==/base.apk!libquickjs.so (offset 0x74000) (JS_CallInternal+4492) (BuildId: f905318366a13fac3eb8aae888c542cd07ede18b)
2025-05-29 03:27:10.528 26123-26123 DEBUG                   pid-26123                            A        #14 pc 000000000005622c  /data/app/~~cB92TfEYe4dVgLm3zNwB2Q==/com.hyperboot.ziplinekmmtesting.android-8vslgtGdF3wyOhEW2nkNFQ==/base.apk!libquickjs.so (offset 0x74000) (JS_CallInternal+4492) (BuildId: f905318366a13fac3eb8aae888c542cd07ede18b)
2025-05-29 03:27:10.528 26123-26123 DEBUG                   pid-26123                            A        #15

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions