https://kotlinlang.org logo
#kotlin-native
Title
# kotlin-native
s

Seth Madison

12/12/2023, 9:42 PM
We’ve started seeing crashes like the one below since upgrading a library we’re shipping to iOS from 1.8.0 to 1.9.21.
Copy code
0   libsystem_pthread.dylib             0x000000021b1b6400 pthread_mutex_lock + 12 (pthread_mutex.c:1709)
1   libc++.1.dylib                      0x00000001c200fd20 std::__1::mutex::lock() + 16 (mutex.cpp:38)
2   FooBar                        0x0000000106d656f8 std::__1::__function::__func<kotlin::gcScheduler::GCScheduler::Impl::Impl(kotlin::gcScheduler::GCSchedulerConfig&)::$_0, std::__1::allocator<kotlin::gcScheduler::GCScheduler::Impl::Impl(kotlin::gcS... + 40
3   FooBar                        0x0000000106d65000 kotlin::gcScheduler::internal::EpochScheduler::scheduleNextEpochIfNotInProgress() + 104
4   FooBar                        0x0000000106d65448 void kotlin::RepeatedTimer<kotlin::steady_clock>::Run<kotlin::gcScheduler::internal::GCSchedulerDataAdaptive<kotlin::steady_clock>::GCSchedulerDataAdaptive(kotlin::gcScheduler::GCSchedulerConfig&, ... + 532
5   FooBar                        0x0000000106d655c0 void* std::__1::__thread_proxy<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, void (*)(kotlin::ScopedThread::attributes, void... + 112
6   libsystem_pthread.dylib             0x000000021b1b74d4 _pthread_start + 136 (pthread.c:904)
7   libsystem_pthread.dylib             0x000000021b1b6a10 thread_start + 8 (:-1)
It looks like there were some changes in this code in 1.9.20 here https://github.com/JetBrains/kotlin/commit/2846707a35f7cd8dc6ba0520870fd413fc0738eb#diff-0a5cb6e9380770de11079ffeb[…]f571c4c09f61a30ac65198c176fb039 Anybody else hitting this? Is there already a YouTrack open? cc @Alexander Shabalin [JB].
a

Alexander Shabalin [JB]

12/13/2023, 12:03 PM
Didn't see this one before. Could you, please, create a YT ticket? And will you be able to attach the full crash report there? So far it's unclear why it crashed: was it a segfault, what are the other threads doing, …
s

Seth Madison

12/13/2023, 2:02 PM
Yeah I can make a ticket with a few sanitized crash reports a bit later. It is a seg fault. In each case, the main thread seems to be initializing the library:
Copy code
0   libobjc.A.dylib                     0x00000001aa3ced48 object_setClass + 56 (objc-class.mm:0)
1   CoreFoundation                      0x00000001b1fd01c0 _CFRuntimeCreateInstance + 824 (CFRuntime.c:840)
2   CoreFoundation                      0x00000001b2078da4 CFRunLoopSourceCreate + 108 (CFRunLoop.c:4232)
3   FooBar                        0x0000000106d887cc _GLOBAL__sub_I_GlobalData.cpp + 1436
4   dyld                                0x00000001d47fc944 invocation function for block in dyld4::Loader::findAndRunAllInitializers(dyld4::RuntimeState&) const::$_0::operator()() const + 168 (Loader.cpp:2152)
I created a YouTrack with a sample crash here https://youtrack.jetbrains.com/issue/KT-64313/Kotlin-Native-Seg-Fault-during-Garbage-Collection-on-1.9.21-observed-on-iOS Happy to provide more info if needed.
a

Alexander Shabalin [JB]

12/13/2023, 6:02 PM
Thanks! Will take a look.
gratitude thank you 1