summaryrefslogtreecommitdiff
path: root/rts/Interpreter.c
diff options
context:
space:
mode:
authorSimon Marlow <marlowsd@gmail.com>2008-06-02 14:37:26 +0000
committerSimon Marlow <marlowsd@gmail.com>2008-06-02 14:37:26 +0000
commita8c3a7ccaf3e1d820a7902a478948a55f5324f50 (patch)
tree84284eadbe12bc8fa73c4e9405afedd86822564e /rts/Interpreter.c
parent8250d2d68d6c82aa5ab5bfe10a1b0b8efa6f55f8 (diff)
downloadhaskell-a8c3a7ccaf3e1d820a7902a478948a55f5324f50.tar.gz
FIX #2231: add missing stack check when applying a PAP
This program makes a PAP with 203 arguments :-)
Diffstat (limited to 'rts/Interpreter.c')
-rw-r--r--rts/Interpreter.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/rts/Interpreter.c b/rts/Interpreter.c
index ab59533666..d541dfc409 100644
--- a/rts/Interpreter.c
+++ b/rts/Interpreter.c
@@ -63,6 +63,7 @@
SpLim = cap->r.rCurrentTSO->stack + RESERVED_STACK_WORDS;
#define SAVE_STACK_POINTERS \
+ ASSERT(Sp > SpLim); \
cap->r.rCurrentTSO->sp = Sp
#define RETURN_TO_SCHEDULER(todo,retcode) \
@@ -549,6 +550,16 @@ do_apply:
goto defer_apply_to_sched;
}
+ // Stack check: we're about to unpack the PAP onto the
+ // stack. The (+1) is for the (arity < n) case, where we
+ // also need space for an extra info pointer.
+ if (Sp - (pap->n_args + 1) < SpLim) {
+ Sp -= 2;
+ Sp[1] = (W_)tagged_obj;
+ Sp[0] = (W_)&stg_enter_info;
+ RETURN_TO_SCHEDULER(ThreadInterpret, StackOverflow);
+ }
+
Sp++;
arity = pap->arity;
ASSERT(arity > 0);