From: simonmar Date: Mon, 10 Mar 2003 13:27:34 +0000 (+0000) Subject: [project @ 2003-03-10 13:27:34 by simonmar] X-Git-Tag: Approx_11550_changesets_converted~1079 X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=bda047d0f4dce1de599938457d8f31a97cb36f5b;p=ghc-hetmet.git [project @ 2003-03-10 13:27:34 by simonmar] Use STK_CHK_NP rather than STK_CHK_GEN in the entry code for AP and AP_STACK thunks. The reason is that if the check fails, on return the closure might have been blackholed (perhaps due to lazy blackholing, or even because another thread has entered it), so we *must* enter the closure to continue, rather than just continuing at the original entry point. All compiler-generated thunks do this anyway, I think these are the only cases of thunks which don't follow the rule. Thanks to Robert Ennals for spotting, and correctly diagnosing, the bug. --- diff --git a/ghc/rts/Apply.hc b/ghc/rts/Apply.hc index d8999f1..30fbb50 100644 --- a/ghc/rts/Apply.hc +++ b/ghc/rts/Apply.hc @@ -163,8 +163,11 @@ STGFUN(stg_AP_entry) Words = ap->n_args; - // Check for stack overflow. - STK_CHK_GEN(Words+sizeofW(StgUpdateFrame), R1_PTR, stg_AP_entry); + // Check for stack overflow. IMPORTANT: use a _NP check here, + // because if the check fails, we might end up blackholing this very + // closure, in which case we must enter the blackhole on return rather + // than continuing to evaluate the now-defunct closure. + STK_CHK_NP(Words+sizeofW(StgUpdateFrame),); PUSH_UPD_FRAME(R1.p, 0); Sp -= sizeofW(StgUpdateFrame) + Words; @@ -230,8 +233,11 @@ STGFUN(stg_AP_STACK_entry) Words = ap->size; - // Check for stack overflow. - STK_CHK_GEN(Words+sizeofW(StgUpdateFrame), R1_PTR, stg_AP_STACK_entry); + // Check for stack overflow. IMPORTANT: use a _NP check here, + // because if the check fails, we might end up blackholing this very + // closure, in which case we must enter the blackhole on return rather + // than continuing to evaluate the now-defunct closure. + STK_CHK_NP(Words+sizeofW(StgUpdateFrame),); PUSH_UPD_FRAME(R1.p, 0); Sp -= sizeofW(StgUpdateFrame) + Words;