In 2.7 or earlier, bf3b2a43741e or the following patch is also needed.
diff --git a/cont.c b/cont.c
index 7f971a9e9d5..50403b8258d 100644
--- a/cont.c
+++ b/cont.c
@@ -1930,7 +1930,7 @@ fiber_current(void)
}
static inline rb_fiber_t*
-return_fiber(void)
+return_fiber(bool terminate)
{
rb_fiber_t *fiber = fiber_current();
rb_fiber_t *prev = fiber->prev;
@@ -1941,7 +1941,7 @@ return_fiber(void)
VM_ASSERT(root_fiber != NULL);
- if (root_fiber == fiber) {
+ if (!terminate && root_fiber == fiber) {
rb_raise(rb_eFiberError, "can't yield from root fiber");
}
return root_fiber;
@@ -2087,7 +2087,7 @@ rb_fiber_terminate(rb_fiber_t *fiber, int need_interrupt)
fiber->cont.machine.stack = NULL;
fiber->cont.machine.stack_size = 0;
- next_fiber = return_fiber();
+ next_fiber = return_fiber(true);
if (need_interrupt) RUBY_VM_SET_INTERRUPT(&next_fiber->cont.saved_ec);
fiber_switch(next_fiber, 1, &value, 0, RB_NO_KEYWORDS);
}
@@ -2121,13 +2121,13 @@ rb_fiber_resume(VALUE fiber_value, int argc, const VALUE *argv)
VALUE
rb_fiber_yield_kw(int argc, const VALUE *argv, int kw_splat)
{
- return fiber_switch(return_fiber(), argc, argv, 0, kw_splat);
+ return fiber_switch(return_fiber(false), argc, argv, 0, kw_splat);
}
VALUE
rb_fiber_yield(int argc, const VALUE *argv)
{
- return fiber_switch(return_fiber(), argc, argv, 0, RB_NO_KEYWORDS);
+ return fiber_switch(return_fiber(false), argc, argv, 0, RB_NO_KEYWORDS);
}
void