Repository : ssh://darcs.haskell.org//srv/darcs/ghc

On branch  : master

http://hackage.haskell.org/trac/ghc/changeset/1c160e588706f4ff6b4e391602e38f0a2044ec13

>---------------------------------------------------------------

commit 1c160e588706f4ff6b4e391602e38f0a2044ec13
Author: Simon Marlow <marlo...@gmail.com>
Date:   Mon Nov 5 16:06:24 2012 +0000

    ASSERT(HpAlloc==0) in the update code, to catch HpAlloc bugs

>---------------------------------------------------------------

 rts/Updates.cmm |   16 +++++++++++++++-
 1 files changed, 15 insertions(+), 1 deletions(-)

diff --git a/rts/Updates.cmm b/rts/Updates.cmm
index 53b2cba..b3b6b20 100644
--- a/rts/Updates.cmm
+++ b/rts/Updates.cmm
@@ -29,6 +29,8 @@ INFO_TABLE_RET ( stg_upd_frame, UPDATE_FRAME,
                  UPDATE_FRAME_FIELDS(W_,P_,info_ptr,_ccs,_unused,updatee) )
     return (P_ ret) /* the closure being returned */
 {
+    ASSERT(HpAlloc == 0); // Note [HpAlloc]
+
     /* ToDo: it might be a PAP, so we should check... */
     TICK_UPD_CON_IN_NEW(sizeW_fromITBL(%GET_STD_INFO(updatee)));
 
@@ -47,7 +49,7 @@ INFO_TABLE_RET ( stg_marked_upd_frame, UPDATE_FRAME,
 {
     W_ v;
 
-    if (HpAlloc != 0) { ccall barf("HpAlloc"); }
+    ASSERT(HpAlloc == 0); // Note [HpAlloc]
 
     // we know the closure is a BLACKHOLE
     v = StgInd_indirectee(updatee);
@@ -87,3 +89,15 @@ INFO_TABLE_RET ( stg_bh_upd_frame, UPDATE_FRAME,
         ( UPDATE_FRAME_FIELDS(,,info_ptr,ccs,_unused,updatee) )
         (ret);
 }
+
+/* Note [HpAlloc]
+ *
+ * HpAlloc is required to be zero unless we just bumped Hp and failed
+ * the heap check: see HeapStackCheck.cmm.  Failures that result from
+ * HpAlloc being non-zero are very hard to track down, because they
+ * manifest as spurious heap corruption that happens only with +RTS
+ * -N2 or greater (because then we have a lot more
+ * interruptCapability() calls happening).  Hence, we assert
+ * HpAlloc==0 as often as possible, and in the update code is a good
+ * place to do that.
+ */



_______________________________________________
Cvs-ghc mailing list
Cvs-ghc@haskell.org
http://www.haskell.org/mailman/listinfo/cvs-ghc

Reply via email to