Fix potential bug with recursing too many times duing gc
This commit is contained in:
@ -658,19 +658,20 @@ static ptrdiff_t check_gc_root(RefcountContext *ctx, RefcountList **root_ptr) {
|
||||
continue;
|
||||
}
|
||||
uintptr_t count;
|
||||
queue = refcount_list_pop_full(queue, NULL, &ctx->alloc);
|
||||
if (ht_has(counts, obj)) {
|
||||
count = HT_UUNSTUFF(ht_get(counts, obj));
|
||||
} else {
|
||||
count = REFCOUNT_OBJECT_ENTRY(ctx, obj)->impl.counted.ref_count;
|
||||
++seen_objects;
|
||||
// don't recuse into objects multiple times
|
||||
obj_held_refs(ctx, obj, &queue);
|
||||
}
|
||||
queue = refcount_list_pop_full(queue, NULL, &ctx->alloc);
|
||||
if (count > 0) {
|
||||
ht_insert(counts, obj, HT_STUFF(--count));
|
||||
if (count == 0) {
|
||||
++clear_objects;
|
||||
}
|
||||
obj_held_refs(ctx, obj, &queue);
|
||||
}
|
||||
}
|
||||
ptrdiff_t freed_count = 0;
|
||||
|
Reference in New Issue
Block a user