From 3d41425e883e8afabcda690d80ba18b73a38939c Mon Sep 17 00:00:00 2001 From: Justin Ethier Date: Tue, 17 Nov 2015 02:05:55 -0500 Subject: [PATCH] Debugging... --- gc-notes.txt | 8 ++++++++ gc.c | 21 ++++++++++++++++++--- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/gc-notes.txt b/gc-notes.txt index 2af6c93c..55cf5e22 100644 --- a/gc-notes.txt +++ b/gc-notes.txt @@ -3,3 +3,11 @@ Phase 2 (gc-dev2) - Change how strings are allocated, to clean up the code and b Phase 3 (gc-dev3) - Change from using a Cheney-style copying collector to a naive mark&sweep algorithm. Phase 4 (gc-dev4) - Integrating new tracing GC algorithm, added new thread data argument to runtime. Phase 5 (gc-dev5) - Require pthreads library, stand cyclone back up using new GC algorithm. + + +Debugging notes: +__glo_list_91ref - +tag is 0 +car appears corrupt +cdr is set to 0x2 during a segfault. +how could this have happened? this variable should always be assigned a closure diff --git a/gc.c b/gc.c index f0d7df6b..f3f67433 100644 --- a/gc.c +++ b/gc.c @@ -532,9 +532,18 @@ void gc_mut_update(gc_thread_data *thd, object old_obj, object value) int status = ATOMIC_GET(&gc_status_col), stage = ATOMIC_GET(&gc_stage); if (thd->gc_status != STATUS_ASYNC) { +printf("DEBUG - GC sync marking heap obj "); +Cyc_display(old_obj, stdout); +printf(" and new value "); +Cyc_display(value, stdout); +//printf(" for heap object "); +printf("\n"); gc_mark_gray(thd, old_obj); gc_mark_gray(thd, value); } else if (stage == STAGE_TRACING) { +printf("DEBUG - GC async tracing marking heap obj "); +Cyc_display(old_obj, stdout); +printf("\n"); gc_mark_gray(thd, old_obj); } // TODO: concerned there may be an issue here with a stack object @@ -613,7 +622,6 @@ void gc_mark_gray(gc_thread_data *thd, object obj) } } -TODO: // TODO: before doing this, may want to debug a bit and see what is // being passed to gc_mut_update. see if those objects tend to have // any heap refs. may need to add debug code to do that... @@ -710,10 +718,17 @@ void gc_mark_black(object obj) } break; } + case cvar_tag: { + gc_collector_mark_gray( *(((cvar_type *)obj)->pvar) ); + break; + } default: break; } - mark(obj) = markColor; + if (mark(obj) != gc_color_red) { + // Only blacken objects on the heap + mark(obj) = markColor; + } } } @@ -828,7 +843,7 @@ void *collector_main(void *arg) // this is inefficient but it should be good enough to // at least stand up this collector. then we'll have to // come back and improve it - sleep(1); +// sleep(1); } }