Permalink
Browse files

[GC] During global destruction of the Parrot interpreter, mark the pa…

…rent

thread as suspended for GC.  When it collects all PMCs, this allows the PMC
freer that it's safe to free all shared PMCs.

Without this, they go away without having their destroy vtable entries invoked.

With this, Memcheck says of "Hello, world!":

    All heap blocks were freed -- no leaks are possible.

Yippee.

git-svn-id: https://svn.parrot.org/parrot/trunk@24478 d31e2699-5ff4-0310-a27c-f18f2fbe73fe
  • Loading branch information...
1 parent 32f19c7 commit a61e8b1f6c893765824f1e611984c80de2e0b215 @chromatic chromatic committed Jan 3, 2008
Showing with 5 additions and 5 deletions.
  1. +1 −3 src/gc/dod.c
  2. +3 −0 src/inter_create.c
  3. +1 −2 src/pmc/scheduler.pmc
View
@@ -311,7 +311,6 @@ Parrot_dod_trace_root(PARROT_INTERP, int trace_stack)
if (interp->scheduler)
pobject_lives(interp, (PObj *)interp->scheduler);
-
/* s. packfile.c */
mark_const_subs(interp);
@@ -1108,8 +1107,7 @@ Parrot_dod_ms_run(PARROT_INTERP, int flags)
* the live bits are cleared
*/
if (flags & DOD_finish_FLAG) {
- /* XXX */
- Parrot_dod_clear_live_bits(interp);
+ clear_live_bits(interp->arena_base->pmc_pool);
clear_live_bits(interp->arena_base->constant_pmc_pool);
Parrot_dod_sweep(interp, interp->arena_base->pmc_pool);
View
@@ -341,6 +341,9 @@ Parrot_really_destroy(PARROT_INTERP, SHIM(int exit_code), SHIM(void *arg))
/* Destroys all PMCs, even constants and the ParrotIO objects for
* std{in, out, err}, so don't be verbose about DOD'ing. */
+ if (interp->thread_data)
+ interp->thread_data->state |= THREAD_STATE_SUSPENDED_GC;
+
Parrot_do_dod_run(interp, DOD_finish_FLAG);
#if STM_PROFILE
View
@@ -51,7 +51,6 @@ Initialize a concurrency scheduler object.
core_struct->interp = INTERP;
COND_INIT(core_struct->condition);
MUTEX_INIT(core_struct->lock);
-
}
/*
@@ -242,7 +241,7 @@ Free the scheduler's underlying struct.
Parrot_Scheduler * const core_struct = PARROT_SCHEDULER(SELF);
COND_DESTROY(core_struct->condition);
MUTEX_DESTROY(core_struct->lock);
- mem_sys_free(PMC_data(SELF));
+ mem_sys_free(core_struct);
}
/*

0 comments on commit a61e8b1

Please sign in to comment.