From b7f82245885ffe0fdaff0e32ea83f1975e03c1ec Mon Sep 17 00:00:00 2001 From: Calvin Rose Date: Sun, 20 Aug 2023 14:53:25 -0500 Subject: [PATCH] Address #1263 Fix reference counting when cleaning up unused abstract types per-thread. --- src/core/gc.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/core/gc.c b/src/core/gc.c index f0ecdd9a..c2a89877 100644 --- a/src/core/gc.c +++ b/src/core/gc.c @@ -370,14 +370,15 @@ void janet_sweep() { if (head->type->gc) { janet_assert(!head->type->gc(head->data, head->size), "finalizer failed"); } - /* Mark as tombstone in place */ - items[i].key = janet_wrap_nil(); - items[i].value = janet_wrap_false(); - janet_vm.threaded_abstracts.deleted++; - janet_vm.threaded_abstracts.count--; /* Free memory */ janet_free(janet_abstract_head(abst)); } + + /* Mark as tombstone in place */ + items[i].key = janet_wrap_nil(); + items[i].value = janet_wrap_false(); + janet_vm.threaded_abstracts.deleted++; + janet_vm.threaded_abstracts.count--; } /* Reset for next sweep */