[project @ 2002-11-01 11:05:46 by simonmar]
authorsimonmar <unknown>
Fri, 1 Nov 2002 11:05:47 +0000 (11:05 +0000)
committersimonmar <unknown>
Fri, 1 Nov 2002 11:05:47 +0000 (11:05 +0000)
commit6226441f08e278ec52d5e054768d9bb557ea7de7
tree3ad5a54b8ae49ada4f9c1ee953064dcda259875a
parent6ddd83ed3708374cdc06a6eafbb5714b5b8934b4
[project @ 2002-11-01 11:05:46 by simonmar]
Fix the heapCensus crash.

It turned out that after a GC, the small_alloc_list might be non-empty
if a new finalizer thread had been started.  The last block on
small_alloc_list doesn't have the free pointer set correctly (as a
small optimisation, we don't normally set the free pointer after each
allocation, only when the block is full).  The result was that the
free pointer contains the wrong value, and the heap census traverses
garbage.  The fix is to set the free pointer correctly before
traversing small_alloc_list.

The bug doesn't show up when DEBUG is on, because extra DEBUG checks
cause the free pointer to be initialised to a sensible(-ish) value.
Hence my difficulty in reproducing the bug.

To reproduce: compile ghc-regress/lib/should_run/memo002 with
profiling and run it with a sufficiently small sample interval (-i0.02
did it for me).

Thanks to the kind folks at ARM for helping out with the debugging of
this one.

MERGE TO STABLE
ghc/rts/ProfHeap.c
ghc/rts/Storage.c
ghc/rts/StoragePriv.h