From 161986fc56bc951eb193c4c669b3e7b5c2a317ae Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Thu, 4 Jul 2013 09:41:30 -0600 Subject: [PATCH] fix GC bug GC during allocation of a pair, weak box, ephemeron, or weak array went wrong if the GC-notification callback allocated any of those kinds of things. (Bug found by running tests in GC-stress mode.) (cherry picked from commit 49fbca5b1830bc4bddb8522d7647518227a32dd0) --- src/racket/gc2/newgc.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/racket/gc2/newgc.c b/src/racket/gc2/newgc.c index d48d9649a6..6f12a37ff6 100644 --- a/src/racket/gc2/newgc.c +++ b/src/racket/gc2/newgc.c @@ -4788,10 +4788,25 @@ 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; + 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; } #ifdef MZ_USE_PLACES if (lmi) {