diff options
author | Nobuyoshi Nakada <[email protected]> | 2022-01-19 16:01:45 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <[email protected]> | 2022-01-19 19:57:16 +0900 |
commit | d650b17686d49c2ce8e6a87039861154e93d4621 () | |
tree | d118492480903dfa666ca3c407cc0e6c9698c8aa | |
parent | 5c7af72304d0ad33cd3f21b24a4bc44e8acd5b2c (diff) |
`rb_fiber_terminate` must not return [Bug #18497]
In a forked process from a fiber, the fiber becomes the only fiber, `fiber_switch` does nothing as there is no other fibers, `rb_fiber_terminate` does not terminate the fiber. In that case, reaches the end of `fiber_entry` finaly, which is declared as "COROUTINE" and should never return.
Notes: Merged: https://.com/ruby/ruby/pull/5468
-rw-r--r-- | cont.c | 3 | ||||
-rw-r--r-- | eval_intern.h | 2 | ||||
-rw-r--r-- | test/fiber/test_process.rb | 15 | ||||
-rw-r--r-- | test/ruby/test_fiber.rb | 5 |
4 files changed, 23 insertions, 2 deletions
@@ -2039,7 +2039,7 @@ rb_fiber_set_scheduler(VALUE klass, VALUE scheduler) return rb_fiber_scheduler_set(scheduler); } -static void rb_fiber_terminate(rb_fiber_t *fiber, int need_interrupt, VALUE err); void rb_fiber_start(rb_fiber_t *fiber) @@ -2408,6 +2408,7 @@ rb_fiber_terminate(rb_fiber_t *fiber, int need_interrupt, VALUE error) fiber_switch(next_fiber, -1, &error, RB_NO_KEYWORDS, NULL, false); else fiber_switch(next_fiber, 1, &value, RB_NO_KEYWORDS, NULL, false); } static VALUE @@ -287,7 +287,7 @@ VALUE rb_make_exception(int argc, const VALUE *argv); NORETURN(void rb_method_name_error(VALUE, VALUE)); -void rb_fiber_start(rb_fiber_t*); NORETURN(void rb_print_undef(VALUE, ID, rb_method_visibility_t)); NORETURN(void rb_print_undef_str(VALUE, VALUE)); @@ -33,4 +33,19 @@ class TestFiberProcess < Test::Unit::TestCase end end.join end end @@ -407,6 +407,11 @@ class TestFiber < Test::Unit::TestCase pid, status = Process.waitpid2(pid) assert_not_predicate(status, :signaled?, bug5700) assert_predicate(status, :success?, bug5700) end def test_exit_in_fiber |