GC bug fix

Replicate 4266e60 for the v5.3.6 release.

This repair omits one part of the original commit,
which is the `gc->dumping_avoid_collection' test
in check_used_against_max(). It's unlikely to matter,
and I'm not sure that check is correct without some
additional changes that seem too complex to try to
include the release.
This commit is contained in:
Matthew Flatt 2013-07-16 14:26:46 -06:00 committed by Ryan Culpepper
parent 0ef2c645a5
commit e3e65a9cdf
2 changed files with 29 additions and 15 deletions

View File

@ -2839,6 +2839,7 @@ static NewGC *init_type_tags_worker(NewGC *inheritgc, NewGC *parentgc,
initialize_signal_handler(gc);
GC_add_roots(&gc->park, (char *)&gc->park + sizeof(gc->park) + 1);
GC_add_roots(&gc->park_save, (char *)&gc->park_save + sizeof(gc->park_save) + 1);
GC_add_roots(&gc->park_isave, (char *)&gc->park_isave + sizeof(gc->park_isave) + 1);
return gc;
}
@ -4544,6 +4545,29 @@ void print_debug_stats(NewGC *gc) {
}
#endif
static void park_for_inform_callback(NewGC *gc)
{
/* Avoid nested collections, which would need
nested parking spaces: */
gc->dumping_avoid_collection++;
/* Inform might allocate, which might need park: */
gc->park_isave[0] = gc->park[0];
gc->park_isave[1] = gc->park[1];
gc->park[0] = NULL;
gc->park[1] = NULL;
}
static void unpark_for_inform_callback(NewGC *gc)
{
gc->park[0] = gc->park_isave[0];
gc->park[1] = gc->park_isave[1];
gc->park_isave[0] = NULL;
gc->park_isave[1] = NULL;
--gc->dumping_avoid_collection;
}
#if 0
extern double scheme_get_inexact_milliseconds(void);
# define TIME_DECLS() double start, task_start
@ -4788,25 +4812,12 @@ static void garbage_collect(NewGC *gc, int force_full, int switching_master, Log
#ifdef MZ_USE_PLACES
is_master = (gc == MASTERGC);
#endif
gc->dumping_avoid_collection++;
/* Inform might allocate, which might need park: */
gc->park_save[0] = gc->park[0];
gc->park_save[1] = gc->park[1];
gc->park[0] = NULL;
gc->park[1] = NULL;
park_for_inform_callback(gc);
gc->GC_collect_inform_callback(is_master, gc->gc_full,
old_mem_use + old_gen0, gc->memory_in_use,
old_mem_allocated, mmu_memory_allocated(gc->mmu),
gc->child_gc_total);
gc->park[0] = gc->park_save[0];
gc->park[1] = gc->park_save[1];
gc->park_save[0] = NULL;
gc->park_save[1] = NULL;
--gc->dumping_avoid_collection;
unpark_for_inform_callback(gc);
}
#ifdef MZ_USE_PLACES
if (lmi) {
@ -4880,10 +4891,12 @@ static void garbage_collect(NewGC *gc, int force_full, int switching_master, Log
wait_if_master_in_progress(gc, &sub_lmi);
if (sub_lmi.ran) {
if (gc->GC_collect_inform_callback) {
park_for_inform_callback(gc);
gc->GC_collect_inform_callback(1, sub_lmi.full,
sub_lmi.pre_used, sub_lmi.post_used,
sub_lmi.pre_admin, sub_lmi.post_admin,
0);
unpark_for_inform_callback(gc);
}
}
}

View File

@ -226,6 +226,7 @@ typedef struct NewGC {
void *park[2];
void *park_save[2];
void *park_isave[2];
unsigned short weak_array_tag;
unsigned short weak_box_tag;