vm.c: transferred fiber termination should kick root fiber; fix #5907

This commit is contained in:
Yukihiro "Matz" Matsumoto
2023-01-14 22:55:26 +09:00
parent 3f6fd994f0
commit 7a6d03f869
+11 -5
View File
@@ -2179,8 +2179,8 @@ RETRY_TRY_BLOCK:
c->status = MRB_FIBER_TERMINATED;
mrb->c = c->prev;
c->prev = NULL;
if (!mrb->c) mrb->c = mrb->root_c;
else c->prev = NULL;
goto L_RAISE;
}
}
@@ -2257,11 +2257,17 @@ RETRY_TRY_BLOCK:
struct mrb_context *c;
c = mrb->c;
if (!c->prev) { /* toplevel return */
regs[irep->nlocals] = v;
goto CHECKPOINT_LABEL_MAKE(RBREAK_TAG_STOP);
if (!c->prev) {
if (c != mrb->root_c) {
/* fiber termination should transfer to root */
c->prev = mrb->root_c;
}
else { /* toplevel return */
regs[irep->nlocals] = v;
goto CHECKPOINT_LABEL_MAKE(RBREAK_TAG_STOP);
}
}
if (!c->vmexec && c->prev->ci == c->prev->cibase) {
else if (!c->vmexec && c->prev->ci == c->prev->cibase) {
RAISE_LIT(mrb, E_FIBER_ERROR, "double resume");
}
CHECKPOINT_RESTORE(RBREAK_TAG_RETURN_TOPLEVEL) {