Commit a8c3a7cc authored by Simon Marlow's avatar Simon Marlow
Browse files

FIX #2231: add missing stack check when applying a PAP

This program makes a PAP with 203 arguments :-)
parent 8250d2d6
......@@ -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);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment