From 266208c5000bb8df90b9bde0f59ad2ac2a3d2bfc Mon Sep 17 00:00:00 2001 From: Alexander Shabalin Date: Thu, 18 Jan 2024 13:07:00 +0100 Subject: [PATCH] [K/N] Fix finalizer handling with mimalloc ^KT-63423 --- .../runtime/src/alloc/legacy/cpp/ObjectFactorySweep.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kotlin-native/runtime/src/alloc/legacy/cpp/ObjectFactorySweep.hpp b/kotlin-native/runtime/src/alloc/legacy/cpp/ObjectFactorySweep.hpp index 8733e71eadb..9cc9ddea43b 100644 --- a/kotlin-native/runtime/src/alloc/legacy/cpp/ObjectFactorySweep.hpp +++ b/kotlin-native/runtime/src/alloc/legacy/cpp/ObjectFactorySweep.hpp @@ -59,7 +59,7 @@ SegregatedFinalizerQueue Sweep( sweepHandle.addSweptObject(); if (HasFinalizers(objHeader)) { auto* extraObject = mm::ExtraObjectData::Get(objHeader); - if (compiler::objcDisposeOnMain() && extraObject->getFlag(mm::ExtraObjectData::FLAGS_RELEASE_ON_MAIN_QUEUE)) { + if (compiler::objcDisposeOnMain() && extraObject && extraObject->getFlag(mm::ExtraObjectData::FLAGS_RELEASE_ON_MAIN_QUEUE)) { objectFactoryIter.MoveAndAdvance(finalizerQueue.mainThread, it); } else { objectFactoryIter.MoveAndAdvance(finalizerQueue.regular, it);