From 20d8f54ea309cbd6e804886423f92baf2e56ad9d Mon Sep 17 00:00:00 2001 From: Troels Bjerre Lund Date: Mon, 22 May 2023 12:16:48 +0000 Subject: [PATCH] Unlink weakref objects on finalizer-enque ^KT-55364 Co-authored-by: Troels Lund Merge-request: KOTLIN-MR-694 Merged-by: Alexander Shabalin --- kotlin-native/runtime/src/custom_alloc/cpp/GCApi.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/kotlin-native/runtime/src/custom_alloc/cpp/GCApi.cpp b/kotlin-native/runtime/src/custom_alloc/cpp/GCApi.cpp index 40ac83e34ee..56da0aa9246 100644 --- a/kotlin-native/runtime/src/custom_alloc/cpp/GCApi.cpp +++ b/kotlin-native/runtime/src/custom_alloc/cpp/GCApi.cpp @@ -43,6 +43,7 @@ bool SweepObject(uint8_t* object, FinalizerQueue& finalizerQueue, gc::GCHandle:: if (!extraObject->getFlag(mm::ExtraObjectData::FLAGS_IN_FINALIZER_QUEUE)) { CustomAllocDebug("SweepObject(%p): needs to be finalized, extraObject at %p", object, extraObject); extraObject->setFlag(mm::ExtraObjectData::FLAGS_IN_FINALIZER_QUEUE); + extraObject->ClearRegularWeakReferenceImpl(); CustomAllocDebug("SweepObject: fromExtraObject(%p) = %p", extraObject, ExtraObjectCell::fromExtraObject(extraObject)); finalizerQueue.Push(ExtraObjectCell::fromExtraObject(extraObject)); gcHandle.addMarkedObject();