Hello, could someone help with the following iOS e...
# kotlin-native
a
Hello, could someone help with the following iOS exception? What might be the cause?
Copy code
Uncaught Kotlin exception: kotlin.native.IncorrectDereferenceException: illegal attempt to access non-shared kotlin.collections.ArrayList@3edc938 from other thread
        at 0   MppLib                              0x000000010ce1c165 kfun:kotlin.Exception.<init>(kotlin.String?)kotlin.Exception + 85
        at 1   MppLib                              0x000000010ce1b4c5 kfun:kotlin.RuntimeException.<init>(kotlin.String?)kotlin.RuntimeException + 85
        at 2   MppLib                              0x000000010ce460d5 kfun:kotlin.native.IncorrectDereferenceException.<init>(kotlin.String)kotlin.native.IncorrectDereferenceException + 85
        at 3   MppLib                              0x000000010ce48058 ThrowIllegalObjectSharingException + 744
        at 4   MppLib                              0x000000010cff3d79 _ZNK16KRefSharedHolder14verifyRefOwnerEv + 185
        at 5   MppLib                              0x000000010d000efc -[KMutableListAsNSMutableArray dealloc] + 44
        at 6   libobjc.A.dylib                     0x00007fff50bad0d6 _ZN11objc_object17sidetable_releaseEb + 174
        at 7   libobjc.A.dylib                     0x00007fff50bae75b _ZN19AutoreleasePoolPage12releaseUntilEPP11objc_object + 147
        at 8   libobjc.A.dylib                     0x00007fff50bae67a objc_autoreleasePoolPop + 199
        at 9   libobjc.A.dylib                     0x00007fff50bae9c4 _ZN19AutoreleasePoolPage11tls_deallocEPv + 112
        at 10  libsystem_pthread.dylib             0x00007fff51bfe6ab _pthread_tsd_cleanup + 551
        at 11  libsystem_pthread.dylib             0x00007fff51c01655 _pthread_exit + 70
        at 12  libsystem_pthread.dylib             0x00007fff51bfe2f6 _pthread_body + 137
        at 13  libsystem_pthread.dylib             0x00007fff51c01249 _pthread_start + 66
        at 14  libsystem_pthread.dylib             0x00007fff51bfd40d thread_start + 13
(lldb)
k
you shared a mutable object between threads
a
How can I find which and where?
k
well, debugging, i would imagine
a
Hmm, all the lists I'm sharing are frozen
Will double check though
q
Could you give some related code snippets ?
a
you can try build custom kotlin/native compiler libs for ios target with debugging logs here 1.3.50 with logs (i use it for same purpose) - https://github.com/icerockdev/kotlin-native/tree/1.3.50-memlog 1. clone repo 2. build K/N runtime with
./gradlew :runtime:ios_x64Runtime
(or arm if you test on device) 3. copy
runtime/build/ios_x64/runtime.bc
to
~/.konan/kotlin-native-macos-1.3.50/klib/common/stdlib/targets/ios_x64/native/runtime.bc
and all other *.bc to в
~/.konan/kotlin-native-macos-1.3.50/konan/targets/ios_x64/native/
4. rebuild your app and see logs from memory manager
or just use my already compiled *.bc libs 🙂
o
please try 1.3.60 eap3
a
Thanks guys will try the suggestions. Is it possible to use 1.3.60 eap if my lib depends on another third-party libs compiled with 1.3.50?
o
not really so far, but we’re working on library stabilization format