From 386e208eb887a7e832ff28f271c368579d417154 Mon Sep 17 00:00:00 2001 From: Justin Ethier Date: Mon, 6 Aug 2018 14:48:37 -0400 Subject: [PATCH] Revert previous changed noticed an intermittent crash running read1 --- gc.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/gc.c b/gc.c index 28a7ebe4..0d30ccbe 100644 --- a/gc.c +++ b/gc.c @@ -541,7 +541,7 @@ size_t gc_convert_heap_page_to_free_list(gc_heap *h, gc_thread_data *thd) gc_heap *gc_sweep_fixed_size(gc_heap * h, int heap_type, gc_thread_data *thd) { short heap_is_empty; - object p, end; + object p; gc_free_list *q, *r, *s; #if GC_DEBUG_SHOW_SWEEP_DIAG gc_heap *orig_heap_ptr = h; @@ -567,15 +567,14 @@ gc_heap *gc_sweep_fixed_size(gc_heap * h, int heap_type, gc_thread_data *thd) size_t remaining = h->size - (h->size % h->block_size); // - h->block_size; // Remove first one?? char *data_end = h->data + remaining; heap_is_empty = 1; // Base case is an empty heap - end = (object)data_end; - p = h->data; q = h->free_list; - while (p < end) { + while (remaining) { + p = data_end - remaining; // find preceding/succeeding free list pointers for p for (r = (q?q->next:NULL); r && ((char *)r < (char *)p); q = r, r = r->next) ; if ((char *)q == (char *)p || (char *)r == (char *)p) { // this is a free block, skip it //printf("Sweep skip free block %p remaining=%lu\n", p, remaining); - p = (object) (((char *)p) + h->block_size); + remaining -= h->block_size; continue; } #if GC_SAFETY_CHECKS @@ -649,7 +648,7 @@ gc_heap *gc_sweep_fixed_size(gc_heap * h, int heap_type, gc_thread_data *thd) } //next->next = (gc_free_list *)(((char *) next) + h->block_size); //next = next->next; - p = (object) (((char *)p) + h->block_size); + remaining -= h->block_size; } } // Free the heap page if possible.