clear some pointers after they are free()ed

If the pointer value is kept, then its possible (though unlikely)
that the GC will get confused.
This commit is contained in:
Matthew Flatt 2012-12-21 10:05:37 -07:00
parent 4b16c7616e
commit 3d9b103181
3 changed files with 28 additions and 35 deletions

View File

@ -31,8 +31,6 @@
READ_ONLY static Scheme_Object *scheme_local[MAX_CONST_LOCAL_POS][MAX_CONST_LOCAL_TYPES][MAX_CONST_LOCAL_FLAG_VAL + 1]; READ_ONLY static Scheme_Object *scheme_local[MAX_CONST_LOCAL_POS][MAX_CONST_LOCAL_TYPES][MAX_CONST_LOCAL_FLAG_VAL + 1];
READ_ONLY static Scheme_Object *toplevels[MAX_CONST_TOPLEVEL_DEPTH][MAX_CONST_TOPLEVEL_POS][SCHEME_TOPLEVEL_FLAGS_MASK + 1]; READ_ONLY static Scheme_Object *toplevels[MAX_CONST_TOPLEVEL_DEPTH][MAX_CONST_TOPLEVEL_POS][SCHEME_TOPLEVEL_FLAGS_MASK + 1];
READ_ONLY static Scheme_Object *unshadowable_symbol;
/* If locked, these are probably sharable: */ /* If locked, these are probably sharable: */
THREAD_LOCAL_DECL(static Scheme_Hash_Table *toplevels_ht); THREAD_LOCAL_DECL(static Scheme_Hash_Table *toplevels_ht);
THREAD_LOCAL_DECL(static Scheme_Hash_Table *locals_ht[2]); THREAD_LOCAL_DECL(static Scheme_Hash_Table *locals_ht[2]);
@ -2421,12 +2419,7 @@ Scheme_Object *scheme_namespace_lookup_value(Scheme_Object *sym, Scheme_Env *gen
Scheme_Object *scheme_find_local_shadower(Scheme_Object *sym, Scheme_Object *sym_marks, Scheme_Comp_Env *env) Scheme_Object *scheme_find_local_shadower(Scheme_Object *sym, Scheme_Object *sym_marks, Scheme_Comp_Env *env)
{ {
Scheme_Comp_Env *frame; Scheme_Comp_Env *frame;
Scheme_Object *esym, *uid = NULL, *env_marks, *prop; Scheme_Object *esym, *uid = NULL, *env_marks;
if (!unshadowable_symbol) {
REGISTER_SO(unshadowable_symbol);
unshadowable_symbol = scheme_intern_symbol("unshadowable");
}
/* Walk backward through the frames, looking for a renaming binding /* Walk backward through the frames, looking for a renaming binding
with the same marks as the given identifier, sym. Skip over with the same marks as the given identifier, sym. Skip over
@ -2438,19 +2431,16 @@ Scheme_Object *scheme_find_local_shadower(Scheme_Object *sym, Scheme_Object *sym
for (i = frame->num_bindings; i--; ) { for (i = frame->num_bindings; i--; ) {
if (frame->values[i]) { if (frame->values[i]) {
if (SAME_OBJ(SCHEME_STX_VAL(sym), SCHEME_STX_VAL(frame->values[i]))) { if (SAME_OBJ(SCHEME_STX_VAL(sym), SCHEME_STX_VAL(frame->values[i]))) {
prop = scheme_stx_property(frame->values[i], unshadowable_symbol, NULL); esym = frame->values[i];
if (SCHEME_FALSEP(prop)) { env_marks = scheme_stx_extract_marks(esym);
esym = frame->values[i]; if (scheme_equal(env_marks, sym_marks)) {
env_marks = scheme_stx_extract_marks(esym); sym = esym;
if (scheme_equal(env_marks, sym_marks)) { if (frame->uids)
sym = esym; uid = frame->uids[i];
if (frame->uids) else
uid = frame->uids[i]; uid = frame->uid;
else break;
uid = frame->uid; }
break;
}
}
} }
} }
} }
@ -2463,18 +2453,15 @@ Scheme_Object *scheme_find_local_shadower(Scheme_Object *sym, Scheme_Object *sym
if (SAME_OBJ(SCHEME_STX_VAL(sym), if (SAME_OBJ(SCHEME_STX_VAL(sym),
SCHEME_STX_VAL(COMPILE_DATA(frame)->const_names[i]))) { SCHEME_STX_VAL(COMPILE_DATA(frame)->const_names[i]))) {
esym = COMPILE_DATA(frame)->const_names[i]; esym = COMPILE_DATA(frame)->const_names[i];
prop = scheme_stx_property(esym, unshadowable_symbol, NULL); env_marks = scheme_stx_extract_marks(esym);
if (SCHEME_FALSEP(prop)) { if (scheme_equal(env_marks, sym_marks)) { /* This used to have 1 || --- why? */
env_marks = scheme_stx_extract_marks(esym); sym = esym;
if (scheme_equal(env_marks, sym_marks)) { /* This used to have 1 || --- why? */ if (COMPILE_DATA(frame)->const_uids)
sym = esym; uid = COMPILE_DATA(frame)->const_uids[i];
if (COMPILE_DATA(frame)->const_uids) else
uid = COMPILE_DATA(frame)->const_uids[i]; uid = frame->uid;
else break;
uid = frame->uid; }
break;
}
}
} }
} }
} }

View File

@ -699,6 +699,7 @@ static void init_future_thread(Scheme_Future_State *fs, int i)
t = mz_proc_thread_create_w_stacksize(worker_thread_future_loop, &params, FUTURE_C_STACK_SIZE); t = mz_proc_thread_create_w_stacksize(worker_thread_future_loop, &params, FUTURE_C_STACK_SIZE);
mzrt_sema_wait(params.ready_sema); mzrt_sema_wait(params.ready_sema);
mzrt_sema_destroy(params.ready_sema); mzrt_sema_destroy(params.ready_sema);
params.ready_sema = NULL;
fts->t = t; fts->t = t;

View File

@ -454,16 +454,19 @@ Scheme_Object *scheme_place(int argc, Scheme_Object *args[]) {
if (!proc_thread) { if (!proc_thread) {
mzrt_sema_destroy(ready); mzrt_sema_destroy(ready);
ready = NULL;
scheme_signal_error("place: place creation failed"); scheme_signal_error("place: place creation failed");
} }
mz_proc_thread_detach(proc_thread); mz_proc_thread_detach(proc_thread);
proc_thread = NULL;
/* wait until the place has started and grabbed the value /* wait until the place has started and grabbed the value
from `place_data'; it's important that a GC doesn't happen from `place_data'; it's important that a GC doesn't happen
here until the other place is far enough. */ here until the other place is far enough. */
mzrt_sema_wait(ready); mzrt_sema_wait(ready);
mzrt_sema_destroy(ready); mzrt_sema_destroy(ready);
ready = NULL;
place_data->ready = NULL; place_data->ready = NULL;
place_data->place_obj = NULL; place_data->place_obj = NULL;
@ -2370,6 +2373,7 @@ void scheme_place_check_for_interruption()
pause_all_child_places(); pause_all_child_places();
mzrt_sema_wait(local_pause); mzrt_sema_wait(local_pause);
mzrt_sema_destroy(local_pause); mzrt_sema_destroy(local_pause);
local_pause = NULL;
resume_all_child_places(); resume_all_child_places();
} else } else
break; break;
@ -2817,6 +2821,7 @@ static void async_channel_finalize(void *p, void* data) {
maybe_report_message_size(ch); maybe_report_message_size(ch);
mzrt_mutex_destroy(ch->lock); mzrt_mutex_destroy(ch->lock);
ch->lock = NULL;
for (i = 0; i < ch->size ; i++) { for (i = 0; i < ch->size ; i++) {
ht = NULL; ht = NULL;
if (ch->msgs[i]) { if (ch->msgs[i]) {
@ -2843,8 +2848,8 @@ static void async_channel_finalize(void *p, void* data) {
place_obj = ((Scheme_Place_Object *) ch->wakeup_signal); place_obj = ((Scheme_Place_Object *) ch->wakeup_signal);
mzrt_mutex_lock(place_obj->lock); mzrt_mutex_lock(place_obj->lock);
place_obj->refcount--; place_obj->refcount--;
refcount = place_obj->refcount; refcount = place_obj->refcount;
mzrt_mutex_unlock(place_obj->lock); mzrt_mutex_unlock(place_obj->lock);
if (!refcount) { if (!refcount) {
destroy_place_object_locks(place_obj); destroy_place_object_locks(place_obj);