Clear c->prev on fiber termination.

This commit is contained in:
Yukihiro "Matz" Matsumoto
2017-11-29 20:25:55 +09:00
parent b746a0f0d2
commit 5f7cdecdc9
+6 -2
View File
@@ -1968,6 +1968,8 @@ RETRY_TRY_BLOCK:
case OP_R_NORMAL:
NORMAL_RETURN:
if (ci == mrb->c->cibase) {
struct mrb_context *c;
if (!mrb->c->prev) { /* toplevel return */
localjump_error(mrb, LOCALJUMP_ERROR_RETURN);
goto L_RAISE;
@@ -1981,8 +1983,10 @@ RETRY_TRY_BLOCK:
ecall(mrb);
}
/* automatic yield at the end */
mrb->c->status = MRB_FIBER_TERMINATED;
mrb->c = mrb->c->prev;
c = mrb->c;
c->status = MRB_FIBER_TERMINATED;
mrb->c = c->prev;
c->prev = NULL;
mrb->c->status = MRB_FIBER_RUNNING;
ci = mrb->c->ci;
}