[project @ 2000-11-07 18:00:26 by simonmar]
authorsimonmar <unknown>
Tue, 7 Nov 2000 18:00:26 +0000 (18:00 +0000)
committersimonmar <unknown>
Tue, 7 Nov 2000 18:00:26 +0000 (18:00 +0000)
URK!  when scanning the heap we might find a DEAD_WEAK that either (a)
is the size of a WEAK, because we just overwrote its info table, or
(b) is the size of a DEAD_WEAK, because its been around at least one
GC.  The code herein only accounted for case (a).

Fix: check the word at location p+sizeof(DEAD_WEAK), see whether it
looks like an info table ptr, and if so we're in case (b).  This is
guaranteed to work, because we know that in case (a) the appropriate
word will be a closure pointer.

ghc/rts/ProfHeap.c

index 82857f9..d69ac4b 100644 (file)
@@ -1,5 +1,5 @@
 /* -----------------------------------------------------------------------------
- * $Id: ProfHeap.c,v 1.16 2000/07/09 16:17:10 panne Exp $
+ * $Id: ProfHeap.c,v 1.17 2000/11/07 18:00:26 simonmar Exp $
  *
  * (c) The GHC Team, 1998-2000
  *
@@ -496,9 +496,10 @@ heapCensus(void)
        break;
        
       case CONSTR:
-       if (((StgClosure *)p)->header.info == &DEAD_WEAK_info) {
-         size = sizeofW(StgWeak);
-         break;
+       if (((StgClosure *)p)->header.info == &DEAD_WEAK_info
+           && !(LOOKS_LIKE_GHC_INFO(*(p + sizeW_fromITBL(info))))) {
+           size = sizeofW(StgWeak);
+           break;
        }
        /* else, fall through... */