Skip to content

Commit

Permalink
just null out cancelled finalizers
Browse files Browse the repository at this point in the history
  • Loading branch information
aviatesk committed Oct 23, 2024
1 parent 164e38f commit 87cc08b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
10 changes: 3 additions & 7 deletions src/gc-common.c
Original file line number Diff line number Diff line change
Expand Up @@ -487,22 +487,18 @@ int erase_finalizer_at(arraylist_t *list, jl_value_t *o, size_t idx)
void **items = list->items;
void *v = items[idx];
if (o == (jl_value_t*)gc_ptr_clear_tag(v, 1)) {
for (size_t j = idx + 2; j < list->len; j += 2) {
items[j-2] = items[j];
items[j-1] = items[j+1];
}
list->len = list->len - 2;
items[idx] = NULL;
items[idx+1] = NULL;
return 1;
}
return 0;
}

int erase_finalizer(arraylist_t *list, jl_value_t *o)
{
for (size_t i = 0; i < list->len; i += 2) {
for (size_t i = 0; i < list->len; i += 2)
if (erase_finalizer_at(list, o, i))
return 1;
}
return 0;
}

Expand Down
2 changes: 1 addition & 1 deletion test/compiler/inline.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1672,7 +1672,7 @@ const _xs_with_finalizers_ = Any[]
if _gc_or_register[]
# this would hit the slow path
empty!(_xs_with_finalizers_)
GC.gc()
GC.gc(); GC.gc();
else
# still hits the fast path
push!(_xs_with_finalizers_, finalizer(Ref(y)) do x
Expand Down

0 comments on commit 87cc08b

Please sign in to comment.