[Bug #18014] Add assertion to verify freelist
This commit adds an assertion has been added after `gc_page_sweep` to verify that the freelist length is equal to the number of free slots in the page.
This commit is contained in:
parent
4a627dbdfd
commit
e5fe48646c
Notes:
git
2021-07-16 00:49:20 +09:00
12
gc.c
12
gc.c
@ -5483,6 +5483,18 @@ gc_page_sweep(rb_objspace_t *objspace, rb_heap_t *heap, struct heap_page *sweep_
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if RGENGC_CHECK_MODE
|
||||||
|
short freelist_len = 0;
|
||||||
|
RVALUE *ptr = sweep_page->freelist;
|
||||||
|
while (ptr) {
|
||||||
|
freelist_len++;
|
||||||
|
ptr = ptr->as.free.next;
|
||||||
|
}
|
||||||
|
if (freelist_len != sweep_page->free_slots) {
|
||||||
|
rb_bug("inconsistent freelist length: expected %d but was %d", sweep_page->free_slots, freelist_len);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
gc_report(2, objspace, "page_sweep: end.\n");
|
gc_report(2, objspace, "page_sweep: end.\n");
|
||||||
|
|
||||||
return ctx.freed_slots + ctx.empty_slots;
|
return ctx.freed_slots + ctx.empty_slots;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user