From 5216131309ed57e0fa6c89d6ea1ed106b58af791 Mon Sep 17 00:00:00 2001 From: Justin Ethier Date: Fri, 13 Jul 2018 22:35:44 -0400 Subject: [PATCH] Temporary (?) failsafe in gc_sweep Also account for collector's mark color when sweeping old objects. Sucks to have to make 3 comparisons but its better than risking accidentally freeing a traced object! --- gc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/gc.c b/gc.c index 2f003f70..2f5aa90a 100644 --- a/gc.c +++ b/gc.c @@ -1562,6 +1562,7 @@ gc_heap *gc_sweep(gc_heap * h, int heap_type, gc_thread_data *thd) gc_heap *orig_heap_ptr = h; #endif gc_heap *rv = h; + int markColor = ck_pr_load_8(&gc_color_mark); //h->next_free = h; h->last_alloc_size = 0; @@ -1619,7 +1620,8 @@ gc_heap *gc_sweep(gc_heap * h, int heap_type, gc_thread_data *thd) } #endif - if (mark(p) != thd->gc_alloc_color && + if (mark(p) != markColor && + mark(p) != thd->gc_alloc_color && mark(p) != thd->gc_trace_color) { //gc_color_clear) #if GC_DEBUG_VERBOSE fprintf(stderr, "sweep is freeing unmarked obj: %p with tag %d mark %d - alloc color %d trace color %d\n", p,