ruby-changes:62508
From: Koichi <ko1@a...>
Date: Sun, 2 Aug 2020 08:05:04 +0900 (JST)
Subject: [ruby-changes:62508] f7cf600c8b (master): fix mark bit operation.
https://git.ruby-lang.org/ruby.git/commit/?id=f7cf600c8b From f7cf600c8ba483d389ea400071aa2aea2e5a57e0 Mon Sep 17 00:00:00 2001 From: Koichi Sasada <ko1@a...> Date: Sun, 2 Aug 2020 03:23:16 +0900 Subject: fix mark bit operation. To optimize the sweep phase, there is bit operation to set mark bits for out-of-range bits in the last bit_t. However, if there is no out-of-ragnge bits, it set all last bit_t as mark bits and it braek the assumption (unmarked objects will be swept). GC_DEBUG=1 makes sizeof(RVALUE)=64 on my machine and this condition happens. It took me one Saturday to debug this. diff --git a/gc.c b/gc.c index d2d7b06..03649a2 100644 --- a/gc.c +++ b/gc.c @@ -4247,7 +4247,11 @@ gc_page_sweep(rb_objspace_t *objspace, rb_heap_t *heap, struct heap_page *sweep_ https://github.com/ruby/ruby/blob/trunk/gc.c#L4247 /* create guard : fill 1 out-of-range */ bits[BITMAP_INDEX(p)] |= BITMAP_BIT(p)-1; - bits[BITMAP_INDEX(p) + sweep_page->total_slots / BITS_BITLENGTH] |= ~(((bits_t)1 << ((NUM_IN_PAGE(p) + sweep_page->total_slots) % BITS_BITLENGTH)) - 1); + + int out_of_range_bits = (NUM_IN_PAGE(p) + sweep_page->total_slots) % BITS_BITLENGTH; + if (out_of_range_bits != 0) { // sizeof(RVALUE) == 64 + bits[BITMAP_INDEX(p) + sweep_page->total_slots / BITS_BITLENGTH] |= ~(((bits_t)1 << out_of_range_bits) - 1); + } for (i=0; i < HEAP_PAGE_BITMAP_LIMIT; i++) { bitset = ~bits[i]; -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/