SQLDelight coroutines extensions are incompatible with the new Kotlin/Native memory model
See original GitHub issueSQLDelight Version
1.5.0
Application Operating System
iOS
Describe the Bug
Hi! While testing KaMPKit with the new memory model, kotlinx.coroutines and ktor, I found that SQLDelight is not quite compatible with the new kotlinx.coroutines. When running the application on iOS simulator, I encountered the following exception:
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)
...
Long story short, here we pass an object that captures a Channel
instance into a freezable collection. Since the new kotlinx.coroutines are freeze-transparent, freezing leads to unexpected behavior.
Fortunately, this problem can be mitigated on the user-side by disabling freezing machinery.
KaMPKit fork with all described changes is here.
Stacktrace
No response
Issue Analytics
- State:
- Created 2 years ago
- Reactions:16
- Comments:7 (1 by maintainers)
Top Results From Across the Web
Luis Ramos on Twitter: "Compose 1.1.0-beta04 is out, and that ...
SQLDelight coroutines extensions are incompatible with the new Kotlin/Native memory model · Issue... SQLDelight Version 1.5.0 Application Operating System ...
Read more >Changelog - SQLDelight
New : Complete overhaul of generated code, now in kotlin. New: RxJava2 extensions artifact. New: Android Paging extensions artifact. New: Kotlin Multiplatform ...
Read more >android - KMM: sqldelight:coroutines-extensions sets kotlinx ...
In logs, I see that Ktor is complaining about coroutines version not being native-mt . Which I don't understand why because 1.4.# version...
Read more >Kotlin Language Documentation 1.7.21
New Kotlin K2 compiler for the JVM in Alpha. Language ... Kotlin Android Extensions ... What is Kotlin/Native memory management model?
Read more >Store grand re-opening: loading Android data with coroutines
View Model and Live Data: These help us transmit data that we get from ... RxJava is not compatible with Kotlin native/js and...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
fixed on master, will be out in next 2.0 release
No