From 548dcdb1952d57de695482ff9350ef925d485123 Mon Sep 17 00:00:00 2001 From: Yuuki Wesp Date: Sun, 11 Aug 2024 00:54:20 +0300 Subject: [PATCH] add check IsDestroyedObject --- runtime/ishtar.vm/runtime/gc/IshtarGC.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/runtime/ishtar.vm/runtime/gc/IshtarGC.cs b/runtime/ishtar.vm/runtime/gc/IshtarGC.cs index c878d3f9..21eef60a 100644 --- a/runtime/ishtar.vm/runtime/gc/IshtarGC.cs +++ b/runtime/ishtar.vm/runtime/gc/IshtarGC.cs @@ -579,6 +579,17 @@ public void FreeObject(IshtarObject* obj, CallFrame* frame) { using var _ = GCSync.Begin(this); + if (obj->IsDestroyedObject()) + { + gcLayout.register_finalizer_no_order(obj, null, frame); + DeleteDebugData((nint)obj); + RefsHeap.Remove((nint)obj); + Stats.total_bytes_requested -= allocatorPool.Return(obj); + Stats.total_allocations--; + Stats.alive_objects--; + return; + } + if (!obj->IsValidObject()) { VM.FastFail(WNE.STATE_CORRUPT, "trying free memory of invalid object", frame);