Skip to content

Commit 5dab57d

Browse files
committed
just null out cancelled finalizers
1 parent f12b6f1 commit 5dab57d

File tree

2 files changed

+4
-8
lines changed

2 files changed

+4
-8
lines changed

src/gc-common.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -487,22 +487,18 @@ int erase_finalizer_at(arraylist_t *list, jl_value_t *o, size_t idx)
487487
void **items = list->items;
488488
void *v = items[idx];
489489
if (o == (jl_value_t*)gc_ptr_clear_tag(v, 1)) {
490-
for (size_t j = idx + 2; j < list->len; j += 2) {
491-
items[j-2] = items[j];
492-
items[j-1] = items[j+1];
493-
}
494-
list->len = list->len - 2;
490+
items[idx] = NULL;
491+
items[idx+1] = NULL;
495492
return 1;
496493
}
497494
return 0;
498495
}
499496

500497
int erase_finalizer(arraylist_t *list, jl_value_t *o)
501498
{
502-
for (size_t i = 0; i < list->len; i += 2) {
499+
for (size_t i = 0; i < list->len; i += 2)
503500
if (erase_finalizer_at(list, o, i))
504501
return 1;
505-
}
506502
return 0;
507503
}
508504

test/compiler/inline.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1672,7 +1672,7 @@ const _xs_with_finalizers_ = Any[]
16721672
if _gc_or_register[]
16731673
# this would hit the slow path
16741674
empty!(_xs_with_finalizers_)
1675-
GC.gc()
1675+
GC.gc(); GC.gc();
16761676
else
16771677
# still hits the fast path
16781678
push!(_xs_with_finalizers_, finalizer(Ref(y)) do x

0 commit comments

Comments
 (0)