ruby-changes:66797
From: Peter <ko1@a...>
Date: Fri, 16 Jul 2021 00:49:10 +0900 (JST)
Subject: [ruby-changes:66797] e5fe48646c (master): [Bug #18014] Add assertion to verify freelist
https://git.ruby-lang.org/ruby.git/commit/?id=e5fe48646c From e5fe48646c68be0bd45fb8a1d7de36da00eaec4d Mon Sep 17 00:00:00 2001 From: Peter Zhu <peter@p...> Date: Tue, 29 Jun 2021 14:32:54 -0400 Subject: [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. --- gc.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/gc.c b/gc.c index 9af83de..9ccd26d 100644 --- a/gc.c +++ b/gc.c @@ -5483,6 +5483,18 @@ gc_page_sweep(rb_objspace_t *objspace, rb_heap_t *heap, struct heap_page *sweep_ https://github.com/ruby/ruby/blob/trunk/gc.c#L5483 } } +#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"); return ctx.freed_slots + ctx.empty_slots; -- cgit v1.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/