Debugging...

This commit is contained in:
Justin Ethier 2015-11-17 02:05:55 -05:00
parent 2be274d1be
commit 3d41425e88
2 changed files with 26 additions and 3 deletions

View file

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

19
gc.c
View file

@ -532,9 +532,18 @@ void gc_mut_update(gc_thread_data *thd, object old_obj, object value)
int status = ATOMIC_GET(&gc_status_col), int status = ATOMIC_GET(&gc_status_col),
stage = ATOMIC_GET(&gc_stage); stage = ATOMIC_GET(&gc_stage);
if (thd->gc_status != STATUS_ASYNC) { 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, old_obj);
gc_mark_gray(thd, value); gc_mark_gray(thd, value);
} else if (stage == STAGE_TRACING) { } 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); gc_mark_gray(thd, old_obj);
} }
// TODO: concerned there may be an issue here with a stack object // 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 // 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 // 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... // any heap refs. may need to add debug code to do that...
@ -710,11 +718,18 @@ void gc_mark_black(object obj)
} }
break; break;
} }
case cvar_tag: {
gc_collector_mark_gray( *(((cvar_type *)obj)->pvar) );
break;
}
default: default:
break; break;
} }
if (mark(obj) != gc_color_red) {
// Only blacken objects on the heap
mark(obj) = markColor; mark(obj) = markColor;
} }
}
} }
void gc_collector_mark_gray(object obj) void gc_collector_mark_gray(object obj)
@ -828,7 +843,7 @@ void *collector_main(void *arg)
// this is inefficient but it should be good enough to // this is inefficient but it should be good enough to
// at least stand up this collector. then we'll have to // at least stand up this collector. then we'll have to
// come back and improve it // come back and improve it
sleep(1); // sleep(1);
} }
} }