mruby-fiber/fiber.c: detect resume/transfer mixture; fix #5905

Also, transferred fibers should kick the root fiber at termination.
This commit is contained in:
Yukihiro "Matz" Matsumoto
2023-01-12 07:23:35 +09:00
parent 9211bf0950
commit a96a9f2c2b
2 changed files with 34 additions and 15 deletions
+10 -11
View File
@@ -2170,19 +2170,18 @@ RETRY_TRY_BLOCK:
}
pc = ci[0].pc;
}
else if (mrb->c == mrb->root_c) {
mrb->c->ci->stack = mrb->c->stbase;
goto L_STOP;
}
else {
if (mrb->c == mrb->root_c) {
mrb->c->ci->stack = mrb->c->stbase;
goto L_STOP;
}
else {
struct mrb_context *c = mrb->c;
struct mrb_context *c = mrb->c;
c->status = MRB_FIBER_TERMINATED;
mrb->c = c->prev;
c->prev = NULL;
goto L_RAISE;
}
c->status = MRB_FIBER_TERMINATED;
mrb->c = c->prev;
c->prev = NULL;
if (!mrb->c) mrb->c = mrb->root_c;
goto L_RAISE;
}
}