diff --git a/backend.native/tests/framework/values/values.kt b/backend.native/tests/framework/values/values.kt index f3c762f7161..c3c648cddd4 100644 --- a/backend.native/tests/framework/values/values.kt +++ b/backend.native/tests/framework/values/values.kt @@ -8,6 +8,7 @@ package conversions +import kotlin.native.concurrent.freeze import kotlin.native.concurrent.isFrozen import kotlin.properties.ReadWriteProperty import kotlin.reflect.KProperty @@ -337,4 +338,16 @@ fun createTransformDecimalStringToInt(): Transform = TransformDecim open class TransformIntToLong : Transform { override fun map(value: Int): Long = value.toLong() +} + +class GH2931 { + class Data + + class Holder { + val data = Data() + + init { + freeze() + } + } } \ No newline at end of file diff --git a/backend.native/tests/framework/values/values.swift b/backend.native/tests/framework/values/values.swift index 8d158b35c92..f7dc2dc1a14 100644 --- a/backend.native/tests/framework/values/values.swift +++ b/backend.native/tests/framework/values/values.swift @@ -526,6 +526,27 @@ func testKotlinOverride() throws { try assertEquals(actual: TransformIntToLongCallingSuper().map(value: 5), expected: 5) } +// See https://github.com/JetBrains/kotlin-native/issues/2931 +func testGH2931() throws { + for i in 0..<50000 { + let holder = GH2931.Holder() + let queue = DispatchQueue.global(qos: .background) + let group = DispatchGroup() + + for j in 0..<2 { + group.enter() + queue.async { + autoreleasepool { + holder.data + } + group.leave() + } + } + + group.wait() + } +} + // -------- Execution of the test -------- class ValuesTests : TestProvider { @@ -565,6 +586,7 @@ class ValuesTests : TestProvider { TestCase(name: "TestNames", method: withAutorelease(testNames)), TestCase(name: "TestSwiftOverride", method: withAutorelease(testSwiftOverride)), TestCase(name: "TestKotlinOverride", method: withAutorelease(testKotlinOverride)), + TestCase(name: "TestGH2931", method: withAutorelease(testGH2931)), ] } }