From 1c160e588706f4ff6b4e391602e38f0a2044ec13 Mon Sep 17 00:00:00 2001 From: Simon Marlow Date: Mon, 5 Nov 2012 16:06:24 +0000 Subject: ASSERT(HpAlloc==0) in the update code, to catch HpAlloc bugs --- rts/Updates.cmm | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'rts/Updates.cmm') diff --git a/rts/Updates.cmm b/rts/Updates.cmm index 53b2cbaa61..b3b6b20ef3 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. + */ -- cgit v1.2.1