Check for switching to uninitialized fiber; fix
The problem was caused by `Fiber.current.resume'.
MODIFY
mrbgems/mruby-fiber/src/fiber.c
mrbgems/mruby-fiber/src/fiber.c
@@ -196,7 +196,7 @@ fiber_switch(mrb_state *mrb, mrb_value self, mrb_int len, const mrb_value *a, mr
mrb_raise(mrb, E_FIBER_ERROR, "resuming transferred fiber");
}
if (status == MRB_FIBER_RUNNING || status == MRB_FIBER_RESUMED) {
- mrb_raise(mrb, E_FIBER_ERROR, "double resume (fib)");
+ mrb_raise(mrb, E_FIBER_ERROR, "double resume");
}
if (status == MRB_FIBER_TERMINATED) {
mrb_raise(mrb, E_FIBER_ERROR, "resuming dead fiber");
@@ -207,6 +207,9 @@ fiber_switch(mrb_state *mrb, mrb_value self, mrb_int len, const mrb_value *a, mr
if (status == MRB_FIBER_CREATED) {
mrb_value *b, *e;
+ if (!c->ci->proc) {
+ mrb_raise(mrb, E_FIBER_ERROR, "double resume (current)");
+ }
mrb_stack_extend(mrb, len+2); /* for receiver and (optional) block */
b = c->stack+1;
e = b + len;

Check for switching to uninitialized fiber; fix #4041

The problem was caused by `Fiber.current.resume'.