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!
This commit is contained in:
Justin Ethier 2018-07-13 22:35:44 -04:00
parent bcb680f7f6
commit 5216131309

4
gc.c
View file

@ -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,