summaryrefslogtreecommitdiff
path: root/rts/Interpreter.c
diff options
context:
space:
mode:
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);