From e29633f2b25f88159fac5a411bb4fc05252dad80 Mon Sep 17 00:00:00 2001 From: Justin Ethier Date: Tue, 1 Dec 2015 03:07:34 -0500 Subject: [PATCH] Fixed off-by-one error WRT last read/write --- gc.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/gc.c b/gc.c index 2761bc18..eabeb290 100644 --- a/gc.c +++ b/gc.c @@ -931,18 +931,18 @@ void gc_collector_trace() pthread_mutex_lock(&(m->lock)); while (m->last_read < m->last_write) { clean = 0; - (m->last_read)++; -TODO: I think there is an off-by-one error here. inspect last read/write. -is the code going one too many? per paper it is not, but based on -logs it looks like it is reading past end of buffer. (ie, errors always seem -to be on the last object traced, and checking the history, an object -incorrectly marked at position X can be seen to have been stored at position -X in a previous collection. +//TODO: I think there is an off-by-one error here. inspect last read/write. +//is the code going one too many? per paper it is not, but based on +//logs it looks like it is reading past end of buffer. (ie, errors always seem +//to be on the last object traced, and checking the history, an object +//incorrectly marked at position X can be seen to have been stored at position +//X in a previous collection. printf("gc_mark_black mark buffer %p, last_read = %d last_write = %d\n", (m->mark_buffer)[m->last_read], m->last_read, m->last_write); gc_mark_black((m->mark_buffer)[m->last_read]); gc_empty_collector_stack(); + (m->last_read)++; // Inc here to try to prevent off-by-one errors } pthread_mutex_unlock(&(m->lock)); }