diff --git a/kotlin-native/backend.native/tests/build.gradle b/kotlin-native/backend.native/tests/build.gradle index 69fa5910230..3bbdea75cb7 100644 --- a/kotlin-native/backend.native/tests/build.gradle +++ b/kotlin-native/backend.native/tests/build.gradle @@ -5291,7 +5291,9 @@ if (PlatformInfo.isAppleTarget(project)) { interopTest("interop_objc_kt56402") { // Test depends on macOS-specific AppKit - enabled = (project.testTarget == 'macos_x64' || project.testTarget == 'macos_arm64' || project.testTarget == null) && isExperimentalMM + enabled = (project.testTarget == 'macos_x64' || project.testTarget == 'macos_arm64' || project.testTarget == null) + && isExperimentalMM + && !isNoopGC // requires some GC source = 'interop/objc/kt56402/main.kt' interop = "objc_kt56402" flags = ["-tr", "-e", "runAllTests"] // Generate test suites, but use custom entrypoint. diff --git a/kotlin-native/backend.native/tests/interop/objc/kt56402/main.kt b/kotlin-native/backend.native/tests/interop/objc/kt56402/main.kt index 70ca83b05e1..eca4bdee3ae 100644 --- a/kotlin-native/backend.native/tests/interop/objc/kt56402/main.kt +++ b/kotlin-native/backend.native/tests/interop/objc/kt56402/main.kt @@ -53,7 +53,12 @@ fun alloc(ctor: ((ULong) -> Unit) -> ULong): ULong = autoreleasepool { fun waitDestruction(id: ULong) { assertTrue(isMainThread()) - kotlin.native.internal.GC.collect() + // Make sure the finalizers are not run on the main thread even for STMS. + withWorker { + execute(TransferMode.SAFE, {}) { + kotlin.native.internal.GC.collect() + }.result + } while (true) { spin() if (!(id in aliveObjectIds)) {