KaMPKit icon indicating copy to clipboard operation
KaMPKit copied to clipboard

Compatibility with the new Kotlin/Native memory model

Open sbogolepov opened this issue 3 years ago • 1 comments

When using the new Kotlin/Native memory model, kotlinx-coroutines and ktor, KaMPKit is failing at runtime due to incompatibility of SQLDelight coroutines extensions with the new memory model:

kotlin.native.concurrent.FreezingException: freezing of 1@36ba710 has failed, first blocker is co.touchlab.kampkit.models.BreedModel@36f1b90
    at 0   shared                              0x0000000106cf1931 kfun:kotlin.Throwable#<init>(kotlin.String?){} + 97 (/opt/buildAgent/work/c75bfccfe067806/kotlin/kotlin-native/runtime/src/main/kotlin/kotlin/Throwable.kt:24:56)
    at 1   shared                              0x0000000106ce9f3d kfun:kotlin.Exception#<init>(kotlin.String?){} + 93 (/opt/buildAgent/work/c75bfccfe067806/kotlin/kotlin-native/runtime/src/main/kotlin/kotlin/Exceptions.kt:23:58)
    at 2   shared                              0x0000000106cea16d kfun:kotlin.RuntimeException#<init>(kotlin.String?){} + 93 (/opt/buildAgent/work/c75bfccfe067806/kotlin/kotlin-native/runtime/src/main/kotlin/kotlin/Exceptions.kt:34:58)
    at 3   shared                              0x0000000106d26c5e kfun:kotlin.native.concurrent.FreezingException#<init>(kotlin.Any;kotlin.Any){} + 654 (/opt/buildAgent/work/c75bfccfe067806/kotlin/kotlin-native/runtime/src/main/kotlin/kotlin/native/concurrent/Freezing.kt:17:9)
    at 4   shared                              0x0000000106d28169 ThrowFreezingException + 233 (/opt/buildAgent/work/c75bfccfe067806/kotlin/kotlin-native/runtime/src/main/kotlin/kotlin/native/concurrent/Internal.kt:104:15)
    at 5   shared                              0x00000001073a0c38 FreezeSubgraph + 40
    at 6   shared                              0x00000001073cbb06 Kotlin_Worker_freezeInternal + 38
    at 7   shared                              0x0000000106d269a0 kfun:kotlin.native.concurrent#freeze__at__0:0(){0§<kotlin.Any?>}0:0 + 64 (/opt/buildAgent/work/c75bfccfe067806/kotlin/kotlin-native/runtime/src/main/kotlin/kotlin/native/concurrent/Freezing.kt:37:2)
    at 8   shared                              0x0000000106f3f9d5 kfun:kotlinx.coroutines.internal.LockFreeLinkedListNode#tryCondAddNext(kotlinx.coroutines.internal.LockFreeLinkedListNode;kotlinx.coroutines.internal.LockFreeLinkedListNode;kotlinx.coroutines.internal.LockFreeLinkedListNode.CondAddOp){}kotlin.Int + 1285 (/opt/buildAgent/work/44ec6e850d5c63f0/kotlinx-coroutines-core/concurrent/src/internal/LockFreeLinkedList.kt:228:71)
...

Workaround: disable freezing as described here. Fork with all necessary changes is here. The corresponding SQLDelight issue with the root cause description is here.

sbogolepov avatar Aug 31 '21 14:08 sbogolepov

We'll revisit this when 1.6.20 is released (along with ktor, etc).

kpgalligan avatar Mar 20 '22 15:03 kpgalligan

We've been running on the new memory manager a while now and I don't think this has been an issue, so I'm going to close. Feel free to reopen if it comes back up.

russhwolf avatar Sep 06 '22 22:09 russhwolf