From 6778d2c582d8f17b81b9a8894bd3b2c152050bd3 Mon Sep 17 00:00:00 2001 From: Peter Zhu Date: Tue, 5 Sep 2023 10:25:59 -0400 Subject: [PATCH] Support freeing the lowest memory address page This should help fix the following flaky test: ``` 1) Failure: TestProcess#test_warmup_frees_pages [test/ruby/test_process.rb:2751]: <0> expected but was <1>. ``` --- gc.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/gc.c b/gc.c index cf53cf5270..c8f570940c 100644 --- a/gc.c +++ b/gc.c @@ -2058,7 +2058,7 @@ heap_pages_free_unused_pages(rb_objspace_t *objspace) } if (has_pages_in_tomb_heap) { - for (i = j = 1; j < heap_allocated_pages; i++) { + for (i = j = 0; j < heap_allocated_pages; i++) { struct heap_page *page = heap_pages_sorted[i]; if (page->flags.in_tomb && page->free_slots == page->total_slots) { @@ -2078,6 +2078,11 @@ heap_pages_free_unused_pages(rb_objspace_t *objspace) GC_ASSERT(himem <= heap_pages_himem); heap_pages_himem = himem; + struct heap_page *lopage = heap_pages_sorted[0]; + uintptr_t lomem = (uintptr_t)lopage->start; + GC_ASSERT(lomem >= heap_pages_lomem); + heap_pages_lomem = lomem; + GC_ASSERT(j == heap_allocated_pages); } }