diff --git a/kotlin-native/backend.native/tests/interop/cleaners/cleaners.kt b/kotlin-native/backend.native/tests/interop/cleaners/cleaners.kt index a00050c863a..f430ccce5dc 100644 --- a/kotlin-native/backend.native/tests/interop/cleaners/cleaners.kt +++ b/kotlin-native/backend.native/tests/interop/cleaners/cleaners.kt @@ -6,6 +6,8 @@ import kotlin.native.internal.* +fun ensureInitialized() {} + fun createCleaner() { createCleaner(42) { println(it) diff --git a/kotlin-native/backend.native/tests/interop/cleaners/second_thread.cpp b/kotlin-native/backend.native/tests/interop/cleaners/second_thread.cpp index 9ab0dda0941..5ef9463a5aa 100644 --- a/kotlin-native/backend.native/tests/interop/cleaners/second_thread.cpp +++ b/kotlin-native/backend.native/tests/interop/cleaners/second_thread.cpp @@ -8,6 +8,9 @@ #include int main() { + // Make sure runtime is initialized on the main thread, so that secondary thread death + // doesn't destroy the entire runtime. + testlib_symbols()->kotlin.root.ensureInitialized(); std::thread t([]() { testlib_symbols()->kotlin.root.createCleaner(); }); t.join(); testlib_symbols()->kotlin.root.performGC();