From fe27aff14808f5ab7f94d5e59abd0364f35526e4 Mon Sep 17 00:00:00 2001 From: Justin Ethier Date: Thu, 7 Jul 2016 03:09:36 -0400 Subject: [PATCH] Properly find last page of huge heap --- gc.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/gc.c b/gc.c index 031cfa0f..4aedeeee 100644 --- a/gc.c +++ b/gc.c @@ -429,16 +429,18 @@ char *gc_copy_obj(object dest, char *obj, gc_thread_data * thd) int gc_grow_heap(gc_heap * h, int heap_type, size_t size, size_t chunk_size) { size_t cur_size, new_size; - gc_heap *h_last, *h_new; + gc_heap *h_last = h, *h_new; pthread_mutex_lock(&heap_lock); // Compute size of new heap page if (heap_type == HEAP_HUGE) { new_size = gc_heap_align(size); + while (h_last->next) { + h_last = h_last->next; + } } else { // Grow heap gradually using fibonnaci sequence. size_t prev_size = GROW_HEAP_BY_SIZE; new_size = 0; - h_last = h; while (h_last->next) { if (new_size < HEAP_SIZE) { new_size = prev_size + h_last->size;