mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
Fix CI misalignment between Fiber#resume and Fiber.yield
When a fiber switched by `Fiber.yield` is resumed by `Fiber#resume` by C, it is necessary to pop CI with `fiber_switch()`. Previously, CI misalignment caused inconsistencies, including crashes, on the next `Fiber#resume`.
This commit is contained in:
@@ -272,6 +272,7 @@ fiber_switch(mrb_state *mrb, mrb_value self, mrb_int len, const mrb_value *a, mr
|
||||
else {
|
||||
value = fiber_result(mrb, a, len);
|
||||
if (vmexec) {
|
||||
if (c->ci > c->cibase) c->ci--; /* pop dummy callinfo */
|
||||
c->ci[1].stack[0] = value;
|
||||
}
|
||||
}
|
||||
@@ -412,7 +413,6 @@ mrb_fiber_yield(mrb_state *mrb, mrb_int len, const mrb_value *a)
|
||||
if (c->vmexec) {
|
||||
c->vmexec = FALSE;
|
||||
mrb->c->ci->cci = CINFO_RESUMED;
|
||||
c->ci--; /* pop callinfo for yield */
|
||||
}
|
||||
MARK_CONTEXT_MODIFY(mrb->c);
|
||||
return fiber_result(mrb, a, len);
|
||||
|
||||
Reference in New Issue
Block a user