summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2017-11-22 14:05:11 +0900
committerYukihiro "Matz" Matsumoto <[email protected]>2017-11-22 14:05:11 +0900
commit0ab21a9a5e487a0d50988adb5d6c4114364acd3d (patch)
tree2b1d826bd6d489cd24a2822cd56042be5c47ba53 /src
parentfbafa780983d2e37b2563f52aa068614fdf0bedc (diff)
downloadmruby-0ab21a9a5e487a0d50988adb5d6c4114364acd3d.tar.gz
mruby-0ab21a9a5e487a0d50988adb5d6c4114364acd3d.zip
Stack adjustment should be based on `p->upper`; fix #3857
It used to be based on `ci->proc` but the callinfo position may be wrong when `ecall()` is called during stack rewinding from `OP_RETURN`.
Diffstat (limited to 'src')
-rw-r--r--src/vm.c4
1 files changed, 1 insertions, 3 deletions
diff --git a/src/vm.c b/src/vm.c
index 5a472c1e2..90941bcfe 100644
--- a/src/vm.c
+++ b/src/vm.c
@@ -309,7 +309,6 @@ static void
ecall(mrb_state *mrb)
{
struct RProc *p;
- int nregs;
struct mrb_context *c = mrb->c;
mrb_callinfo *ci = c->ci;
struct RObject *exc;
@@ -325,7 +324,6 @@ ecall(mrb_state *mrb)
p = c->ensure[i];
if (!p) return;
mrb_assert(!MRB_PROC_CFUNC_P(p));
- nregs = ci->proc->body.irep->nregs;
c->ensure[i] = NULL;
cioff = ci - c->cibase;
ci = cipush(mrb);
@@ -338,7 +336,7 @@ ecall(mrb_state *mrb)
ci->target_class = MRB_PROC_TARGET_CLASS(p);
env = MRB_PROC_ENV(p);
mrb_assert(env);
- c->stack += nregs;
+ c->stack += p->upper->body.irep->nregs;
exc = mrb->exc; mrb->exc = 0;
if (exc) {
mrb_gc_protect(mrb, mrb_obj_value(exc));