realm-kotlin
realm-kotlin copied to clipboard
[macos] Crash when trying to clean up scheduler used by multiple realms
Trying to release dispatcher/scheduler used across multiple realms in https://github.com/realm/realm-kotlin/pull/1559/commits/f3e4ce362d56231c77bbf6dffcf8240bf5756fd2#diff-291d3886fa0a21b98dc0ebd5ff0ce3846d78dab19a8d3ccffe6386899f0879a4R79 causes
io.realm.kotlin.test.common.utils.PlatformUtilsTests.createTempDir_createDifferentDirs STANDARD_OUT
Uncaught Kotlin exception: kotlin.IllegalStateException: Dispatcher multipleSchedulersOnSameThread was closed, attempted to schedule: DispatchedContinuation[MultiWorkerDispatcher@584bb7d0, Continuation @ 0]
io.realm.kotlin.test.darwin.CoroutineTests.dispatchQueueScheduler SKIPPED
io.realm.kotlin.test.darwin.MemoryTests.closeShouldFreeMemory STANDARD_OUT
NEW_MEMORY_MODEL: true
at 0 test.kexe 0x10950b47b kfun:kotlin.Throwable#<init>(kotlin.String?){} + 107 (/opt/buildAgent/work/acafc8c59a79cc1/kotlin/kotlin-native/runtime/src/main/kotlin/kotlin/Throwable.kt:25:37)
at 1 test.kexe 0x109504ca7 kfun:kotlin.Exception#<init>(kotlin.String?){} + 103 (/opt/buildAgent/work/acafc8c59a79cc1/kotlin/kotlin-native/runtime/src/main/kotlin/kotlin/Exceptions.kt:23:44)
at 2 test.kexe 0x109504ee7 kfun:kotlin.RuntimeException#<init>(kotlin.String?){} + 103 (/opt/buildAgent/work/acafc8c59a79cc1/kotlin/kotlin-native/runtime/src/main/kotlin/kotlin/Exceptions.kt:34:44)
at 3 test.kexe 0x1095055a7 kfun:kotlin.IllegalStateException#<init>(kotlin.String?){} + 103 (/opt/buildAgent/work/acafc8c59a79cc1/kotlin/kotlin-native/runtime/src/main/kotlin/kotlin/Exceptions.kt:70:44)
at 4 test.kexe 0x1098de8a9 kfun:kotlinx.coroutines.MultiWorkerDispatcher.dispatch#internal + 969 (/opt/buildAgent/work/44ec6e850d5c63f0/kotlinx-coroutines-core/native/src/MultithreadedDispatchers.kt:123:23)
at 5 test.kexe 0x1098aa717 kfun:kotlinx.coroutines.internal#resumeCancellableWith__at__kotlin.coroutines.Continuation<0:0>(kotlin.Result<0:0>;kotlin.Function1<kotlin.Throwable,kotlin.Unit>?){0§<kotlin.Any?>} + 1111 (/opt/buildAgent/work/44ec6e850d5c63f0/kotlinx-coroutines-core/common/src/internal/DispatchedContinuation.kt:280:64)
at 6 test.kexe 0x1098b9d6b kfun:kotlinx.coroutines.intrinsics#startCoroutineCancellable__at__kotlin.coroutines.SuspendFunction1<0:0,0:1>(0:0;kotlin.coroutines.Continuation<0:1>;kotlin.Function1<kotlin.Throwable,kotlin.Unit>?){0§<kotlin.Any?>;1§<kotlin.Any?>} + 619 (/opt/buildAgent/work/44ec6e850d5c63f0/kotlinx-coroutines-core/common/src/intrinsics/Cancellable.kt:30:74)
at 7 test.kexe 0x1098b9f8c kfun:kotlinx.coroutines.intrinsics#startCoroutineCancellable$default__at__kotlin.coroutines.SuspendFunction1<0:0,0:1>(0:0;kotlin.coroutines.Continuation<0:1>;kotlin.Function1<kotlin.Throwable,kotlin.Unit>?;kotlin.Int){0§<kotlin.Any?>;1§<kotlin.Any?>} + 364 (/opt/buildAgent/work/44ec6e850d5c63f0/kotlinx-coroutines-core/common/src/intrinsics/Cancellable.kt:25:10)
at 8 test.kexe 0x10982914c kfun:kotlinx.coroutines.CoroutineStart#invoke(kotlin.coroutines.SuspendFunction1<0:0,0:1>;0:0;kotlin.coroutines.Continuation<0:1>){0§<kotlin.Any?>;1§<kotlin.Any?>} + 364 (/opt/buildAgent/work/44ec6e850d5c63f0/kotlinx-coroutines-core/common/src/CoroutineStart.kt:110:30)
at 9 test.kexe 0x1098164cf kfun:kotlinx.coroutines.AbstractCoroutine#start(kotlinx.coroutines.CoroutineStart;0:0;kotlin.coroutines.SuspendFunction1<0:0,1:0>){0§<kotlin.Any?>} + 159 (/opt/buildAgent/work/44ec6e850d5c63f0/kotlinx-coroutines-core/common/src/AbstractCoroutine.kt:126:9)
at 10 test.kexe 0x109816785 kfun:kotlinx.coroutines#launch__at__kotlinx.coroutines.CoroutineScope(kotlin.coroutines.CoroutineContext;kotlinx.coroutines.CoroutineStart;kotlin.coroutines.SuspendFunction1<kotlinx.coroutines.CoroutineScope,kotlin.Unit>){}kotlinx.coroutines.Job + 677 (/opt/buildAgent/work/44ec6e850d5c63f0/kotlinx-coroutines-core/common/src/Builders.common.kt:56:15)
at 11 test.kexe 0x109816a26 kfun:kotlinx.coroutines#launch$default__at__kotlinx.coroutines.CoroutineScope(kotlin.coroutines.CoroutineContext?;kotlinx.coroutines.CoroutineStart?;kotlin.coroutines.SuspendFunction1<kotlinx.coroutines.CoroutineScope,kotlin.Unit>;kotlin.Int){}kotlinx.coroutines.Job + 582 (/opt/buildAgent/work/44ec6e850d5c63f0/kotlinx-coroutines-core/common/src/Builders.common.kt:47:8)
at 12 test.kexe 0x10994548f kfun:io.realm.kotlin.internal.interop.RealmInterop.SingleThreadDispatcherScheduler#notify(kotlinx.cinterop.CPointer<cnames.structs.realm_work_queue>?){} + 303 (/Users/realm/workspace-realm-kotlin/cr/fix-scheduler-crash/packages/cinterop/src/nativeDarwin/kotlin/io/realm/kotlin/internal/interop/RealmInterop.kt:3416:19)
at 13 test.kexe 0x10994b0f3 kfun:io.realm.kotlin.internal.interop.RealmInterop.realm_create_scheduler$lambda$12#internal + 739 (/Users/realm/workspace-realm-kotlin/cr/fix-scheduler-crash/packages/cinterop/src/nativeDarwin/kotlin/io/realm/kotlin/internal/interop/RealmInterop.kt:576:35)
at 14 test.kexe 0x109954fd6 _696f2e7265616c6d2e6b6f746c696e3a63696e7465726f702f55736572732f7265616c6d2f776f726b73706163652d7265616c6d2d6b6f746c696e2f63722f6669782d7363686564756c65722d63726173682f7061636b616765732f63696e7465726f702f7372632f6e617469766544617277696e2f6b6f746c696e2f696f2f7265616c6d2f6b6f746c696e2f696e7465726e616c2f696e7465726f702f5265616c6d496e7465726f702e6b74_knbridge75 + 150 (/Users/realm/workspace-realm-kotlin/cr/fix-scheduler-crash/packages/cinterop/src/nativeDarwin/kotlin/io/realm/kotlin/internal/interop/RealmInterop.kt:570:17)
at 15 test.kexe 0x109b0b151 _ZN5realm5_impl17WeakRealmNotifier6notifyEv + 81
at 16 test.kexe 0x109afb1d7 _ZN5realm5_impl16RealmCoordinator9on_changeEv + 135
at 17 test.kexe 0x109adfd68 _ZN5realm5_impl20ExternalCommitHelper6listenEv + 184
at 18 test.kexe 0x109adfecd _ZNSt3__1L14__thread_proxyINS_5tupleIJNS_10unique_ptrINS_15__thread_structENS_14default_deleteIS3_EEEEZN5realm5_impl20ExternalCommitHelperC1ERNS8_16RealmCoordinatorERKNS7_11RealmConfigEE3$_0EEEEEPvSH_ + 45
at 19 libsystem_pthread.dylib 0x7fff204728fb _pthread_start + 223
at 20 libsystem_pthread.dylib 0x7fff2046e442 thread_start + 14
Suppressed: kotlinx.coroutines.internal.DiagnosticCoroutineContextException: [StandaloneCoroutine{Cancelling}@744557a0, MultiWorkerDispatcher@584bb7d0]
at 0 test.kexe 0x10950b47b kfun:kotlin.Throwable#<init>(kotlin.String?){} + 107 (/opt/buildAgent/work/acafc8c59a79cc1/kotlin/kotlin-native/runtime/src/main/kotlin/kotlin/Throwable.kt:25:37)
at 1 test.kexe 0x109504ca7 kfun:kotlin.Exception#<init>(kotlin.String?){} + 103 (/opt/buildAgent/work/acafc8c59a79cc1/kotlin/kotlin-native/runtime/src/main/kotlin/kotlin/Exceptions.kt:23:44)
at 2 test.kexe 0x109504ee7 kfun:kotlin.RuntimeException#<init>(kotlin.String?){} + 103 (/opt/buildAgent/work/acafc8c59a79cc1/kotlin/kotlin-native/runtime/src/main/kotlin/kotlin/Exceptions.kt:34:44)
at 3 test.kexe 0x1098e3347 kfun:kotlinx.coroutines.internal.DiagnosticCoroutineContextException#<init>(kotlin.coroutines.CoroutineContext){} + 199 (/opt/buildAgent/work/44ec6e850d5c63f0/kotlinx-coroutines-core/native/src/internal/CoroutineExceptionHandlerImpl.kt:31:5)
at 4 test.kexe 0x1098a6de5 kfun:kotlinx.coroutines.internal#handleUncaughtCoroutineException(kotlin.coroutines.CoroutineContext;kotlin.Throwable){} + 1333 (/opt/buildAgent/work/44ec6e850d5c63f0/kotlinx-coroutines-core/common/src/internal/CoroutineExceptionHandlerImpl.common.kt:47:33)
at 5 test.kexe 0x109826c45 kfun:kotlinx.coroutines#handleCoroutineException(kotlin.coroutines.CoroutineContext;kotlin.Throwable){} + 949 (/opt/buildAgent/work/44ec6e850d5c63f0/kotlinx-coroutines-core/common/src/CoroutineExceptionHandler.kt:32:5)
at 6 test.kexe 0x10981827f kfun:kotlinx.coroutines.StandaloneCoroutine.handleJobException#internal + 191 (/opt/buildAgent/work/44ec6e850d5c63f0/kotlinx-coroutines-core/common/src/Builders.common.kt:194:9)
at 7 test.kexe 0x109833fe1 kfun:kotlinx.coroutines.JobSupport.finalizeFinishingState#internal + 1377 (/opt/buildAgent/work/44ec6e850d5c63f0/kotlinx-coroutines-core/common/src/JobSupport.kt:230:59)
at 8 test.kexe 0x10983f388 kfun:kotlinx.coroutines.JobSupport.tryMakeCompletingSlowPath#internal + 2392 (/opt/buildAgent/work/44ec6e850d5c63f0/kotlinx-coroutines-core/common/src/JobSupport.kt:909:16)
at 9 test.kexe 0x10983e9ed kfun:kotlinx.coroutines.JobSupport.tryMakeCompleting#internal + 653 (/opt/buildAgent/work/44ec6e850d5c63f0/kotlinx-coroutines-core/common/src/JobSupport.kt:866:16)
at 10 test.kexe 0x10983e527 kfun:kotlinx.coroutines.JobSupport#makeCompletingOnce(kotlin.Any?){}kotlin.Any? + 471 (/opt/buildAgent/work/44ec6e850d5c63f0/kotlinx-coroutines-core/common/src/JobSupport.kt:831:30)
at 11 test.kexe 0x109815ed3 kfun:kotlinx.coroutines.AbstractCoroutine#resumeWith(kotlin.Result<1:0>){} + 307 (/opt/buildAgent/work/44ec6e850d5c63f0/kotlinx-coroutines-core/common/src/AbstractCoroutine.kt:100:21)
at 12 test.kexe 0x1098ba3f3 kfun:kotlinx.coroutines.intrinsics.dispatcherFailure#internal + 451 (/opt/buildAgent/work/44ec6e850d5c63f0/kotlinx-coroutines-core/common/src/intrinsics/Cancellable.kt:65:16)
at 13 test.kexe 0x1098b9df4 kfun:kotlinx.coroutines.intrinsics#startCoroutineCancellable__at__kotlin.coroutines.SuspendFunction1<0:0,0:1>(0:0;kotlin.coroutines.Continuation<0:1>;kotlin.Function1<kotlin.Throwable,kotlin.Unit>?){0§<kotlin.Any?>;1§<kotlin.Any?>} + 756 (/opt/buildAgent/work/44ec6e850d5c63f0/kotlinx-coroutines-core/common/src/intrinsics/Cancellable.kt:29:15)
at 14 test.kexe 0x1098b9f8c kfun:kotlinx.coroutines.intrinsics#startCoroutineCancellable$default__at__kotlin.coroutines.SuspendFunction1<0:0,0:1>(0:0;kotlin.coroutines.Continuation<0:1>;kotlin.Function1<kotlin.Throwable,kotlin.Unit>?;kotlin.Int){0§<kotlin.Any?>;1§<kotlin.Any?>} + 364 (/opt/buildAgent/work/44ec6e850d5c63f0/kotlinx-coroutines-core/common/src/intrinsics/Cancellable.kt:25:10)
... and 13 more common stack frames skipped
io.realm.kotlin.test.darwin.MemoryTests.closeShouldFreeMemory FAILED
This is not releated to the reworked clean up in #1559 as it is also experienced on the current main.