summaryrefslogtreecommitdiff
path: root/rts/sm/GC.c
diff options
context:
space:
mode:
authorSimon Marlow <marlowsd@gmail.com>2011-07-20 15:29:54 +0100
committerSimon Marlow <marlowsd@gmail.com>2011-07-20 16:23:29 +0100
commite903a09466c5a700baea8a34511cbdc2576b136e (patch)
treef3564334039591b62cc126960a2c1c6dd4c513f0 /rts/sm/GC.c
parent2c2a434f411029977992207a19245a24f942ff78 (diff)
downloadhaskell-e903a09466c5a700baea8a34511cbdc2576b136e.tar.gz
Move the call to heapCensus() into GarbageCollect(), just before
calling resurrectThreads() (fixes #5314). This avoids a lot of problems, because resurrectThreads() may overwrite some closures in the heap, leaving slop behind. The bug in instances, this fix avoids them all in one go.
Diffstat (limited to 'rts/sm/GC.c')
-rw-r--r--rts/sm/GC.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/rts/sm/GC.c b/rts/sm/GC.c
index 9f69a4c65a..396992ca01 100644
--- a/rts/sm/GC.c
+++ b/rts/sm/GC.c
@@ -171,6 +171,7 @@ StgPtr mark_sp; // pointer to the next unallocated mark stack entry
void
GarbageCollect (rtsBool force_major_gc,
+ rtsBool do_heap_census,
nat gc_type USED_IF_THREADS,
Capability *cap)
{
@@ -661,6 +662,15 @@ GarbageCollect (rtsBool force_major_gc,
// fill slop.
IF_DEBUG(sanity, checkSanity(rtsTrue /* after GC */, major_gc));
+ // If a heap census is due, we need to do it before
+ // resurrectThreads(), for the same reason as checkSanity above:
+ // resurrectThreads() will overwrite some closures and leave slop
+ // behind.
+ if (do_heap_census) {
+ debugTrace(DEBUG_sched, "performing heap census");
+ heapCensus();
+ }
+
// send exceptions to any threads which were about to die
RELEASE_SM_LOCK;
resurrectThreads(resurrected_threads);