From 474b2fc90efddc47250418f308ffa6bfba87dcb3 Mon Sep 17 00:00:00 2001 From: Ilya Matveev Date: Fri, 3 Sep 2021 18:57:08 +0700 Subject: [PATCH] [K/N][New MM] Fix getting current thread data in thread suspension --- kotlin-native/runtime/src/mm/cpp/ThreadSuspension.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/kotlin-native/runtime/src/mm/cpp/ThreadSuspension.cpp b/kotlin-native/runtime/src/mm/cpp/ThreadSuspension.cpp index 701e9bd495f..738a637a934 100644 --- a/kotlin-native/runtime/src/mm/cpp/ThreadSuspension.cpp +++ b/kotlin-native/runtime/src/mm/cpp/ThreadSuspension.cpp @@ -22,7 +22,9 @@ bool isSuspendedOrNative(kotlin::mm::ThreadData& thread) noexcept { template bool allThreads(F predicate) noexcept { auto& threadRegistry = kotlin::mm::ThreadRegistry::Instance(); - auto* currentThread = threadRegistry.CurrentThreadData(); + auto* currentThread = (threadRegistry.IsCurrentThreadRegistered()) + ? threadRegistry.CurrentThreadData() + : nullptr; kotlin::mm::ThreadRegistry::Iterable threads = kotlin::mm::ThreadRegistry::Instance().LockForIter(); for (auto& thread : threads) { // Handle if suspension was initiated by the mutator thread.