Hi All, When I try this tutorial - <https://kotlin...
# multiplatform
a
Hi All, When I try this tutorial - https://kotlinlang.org/docs/multiplatform-mobile-upgrade-app.html i get this crash on iOS simulator. See thread
solved 2
Copy code
/Users/josepha/AndroidStudioProjects/KotlinMultiplatformSandbox/build/ios/Debug-iphonesimulator/iosApp.app
Uncaught Kotlin exception: kotlin.native.IncorrectDereferenceException: illegal attempt to access non-shared <object>@2a61b48 from other thread
    at 0   shared                              0x1093c5c68        kfun:kotlin.Throwable#<init>(kotlin.String?){} + 88 (/opt/buildAgent/work/67fbc2b507315583/kotlin/kotlin-native/runtime/src/main/kotlin/kotlin/Throwable.kt:24:37)
    at 1   shared                              0x1093bfd06        kfun:kotlin.Exception#<init>(kotlin.String?){} + 86 (/opt/buildAgent/work/67fbc2b507315583/kotlin/kotlin-native/runtime/src/main/kotlin/kotlin/Exceptions.kt:23:44)
    at 2   shared                              0x1093bfef6        kfun:kotlin.RuntimeException#<init>(kotlin.String?){} + 86 (/opt/buildAgent/work/67fbc2b507315583/kotlin/kotlin-native/runtime/src/main/kotlin/kotlin/Exceptions.kt:34:44)
    at 3   shared                              0x1093d2856        kfun:kotlin.native.IncorrectDereferenceException#<init>(kotlin.String){} + 86 (/opt/buildAgent/work/67fbc2b507315583/kotlin/kotlin-native/runtime/src/main/kotlin/kotlin/native/Runtime.kt:34:36)
    at 4   shared                              0x1093d5834        ThrowIllegalObjectSharingException + 596 (/opt/buildAgent/work/67fbc2b507315583/kotlin/kotlin-native/runtime/src/main/kotlin/kotlin/native/concurrent/Internal.kt:115:11)
    at 5   shared                              0x10952c405        _ZN12_GLOBAL__N_128throwIllegalSharingExceptionEP9ObjHeader + 21 
    at 6   shared                              0x10952d738        _ZN12_GLOBAL__N_136terminateWithIllegalSharingExceptionEP9ObjHeader + 8 
    at 7   shared                              0x10952d8a8        _ZNK27BackRefFromAssociatedObject3refIL11ErrorPolicy3EEEP9ObjHeaderv + 184 
    at 8   shared                              0x10952cbce        _ZN12_GLOBAL__N_111toKotlinImpEP11objc_objectP13objc_selectorPP9ObjHeader + 46 
    at 9   shared                              0x109522a8b        Kotlin_Interop_refFromObjC + 75 
    at 10  shared                              0x109718b9b        _696f2e6b746f723a6b746f722d636c69656e742d64617277696e_knbridge160 + 315 (/opt/buildAgent/work/8d547b974a7be21f/ktor-client/ktor-client-darwin/darwin/src/io/ktor/client/engine/darwin/internal/DarwinResponseReader.kt:59:14)
    at 11  shared                              0x10972401e        _696f2e6b746f723a6b746f722d636c69656e742d64617277696e_kncfun162 + 78 
    at 12  CFNetwork                           0x7fff23dba540     _CFHostIsDomainTopLevelForCertificatePolicy + 13906 
    at 13  Foundation                          0x7fff207df16a     __NSBLOCKOPERATION_IS_CALLING_OUT_TO_A_BLOCK__ + 6 
    at 14  Foundation                          0x7fff207df062     -[NSBlockOperation main] + 97 
    at 15  Foundation                          0x7fff207e2072     __NSOPERATION_IS_INVOKING_MAIN__ + 16 
    at 16  Foundation                          0x7fff207de2af     -[NSOperation start] + 784 
    at 17  Foundation                          0x7fff207e29c6     __NSOPERATIONQUEUE_IS_STARTING_AN_OPERATION__ + 16 
    at 18  Foundation                          0x7fff207e250b     __NSOQSchedule_f + 181 
    at 19  libdispatch.dylib                   0x7fff2011f5cb     _dispatch_block_async_invoke2 + 82 
    at 20  libdispatch.dylib                   0x7fff20111a55     _dispatch_client_callout + 7 
    at 21  libdispatch.dylib                   0x7fff2011461c     _dispatch_continuation_pop + 481 
    at 22  libdispatch.dylib                   0x7fff20113cb2     _dispatch_async_redirect_invoke + 749 
    at 23  libdispatch.dylib                   0x7fff2012207d     _dispatch_root_queue_drain + 404 
    at 24  libdispatch.dylib                   0x7fff201229c7     _dispatch_worker_thread2 + 154 
    at 25  libsystem_pthread.dylib             0x7fff6bff2f89     _pthread_wqthread + 255 
    at 26  libsystem_pthread.dylib             0x7fff6bff1f56     start_wqthread + 14
It works until I add this block -
Copy code
init() {
        Greeting().greeting { greeting, error in
            DispatchQueue.main.async {
                if let greeting = greeting {
                    self.text = greeting
                } else {
                    self.text = error?.localizedDescription ?? "error"
                }
            }
        }
    }
Solved by
Copy code
kotlin.native.binary.memoryModel=experimental
kotlin.native.binary.freezing=disabled
in gradle.properties or kotlin 1.7.20