diff --git a/cont.c b/cont.c index 558d35c4bd..539d1f48cc 100644 --- a/cont.c +++ b/cont.c @@ -1932,6 +1932,20 @@ fiber_to_s(VALUE fibval) return rb_block_to_s(fibval, &proc->block, status_info); } +#ifdef HAVE_WORKING_FORK +void +rb_fiber_atfork(rb_thread_t *th) +{ + if (th->root_fiber) { + if (&th->root_fiber->cont.saved_ec != th->ec) { + th->root_fiber = th->ec->fiber_ptr; + th->root_fiber->cont.type = ROOT_FIBER_CONTEXT; + } + th->root_fiber->prev = 0; + } +} +#endif + /* * Document-class: FiberError * diff --git a/test/ruby/test_fiber.rb b/test/ruby/test_fiber.rb index 4ad0767ccf..0d070dcbc4 100644 --- a/test/ruby/test_fiber.rb +++ b/test/ruby/test_fiber.rb @@ -269,7 +269,11 @@ class TestFiber < Test::Unit::TestCase end bug5700 = '[ruby-core:41456]' assert_nothing_raised(bug5700) do - Fiber.new{ pid = fork {} }.resume + Fiber.new do + pid = fork do + Fiber.new {}.transfer + end + end.resume end pid, status = Process.waitpid2(pid) assert_equal(0, status.exitstatus, bug5700) diff --git a/thread.c b/thread.c index 9d9e9639ee..20e3deacdd 100644 --- a/thread.c +++ b/thread.c @@ -4231,6 +4231,7 @@ terminate_atfork_i(rb_thread_t *th, const rb_thread_t *current_th) } } +void rb_fiber_atfork(rb_thread_t *); void rb_thread_atfork(void) { @@ -4238,6 +4239,7 @@ rb_thread_atfork(void) rb_thread_atfork_internal(th, terminate_atfork_i); th->join_list = NULL; rb_mutex_cleanup_keeping_mutexes(th); + rb_fiber_atfork(th); /* We don't want reproduce CVE-2003-0900. */ rb_reset_random_seed(); diff --git a/version.h b/version.h index b9b5c22ac4..b6b67e1432 100644 --- a/version.h +++ b/version.h @@ -1,10 +1,10 @@ #define RUBY_VERSION "2.5.4" -#define RUBY_RELEASE_DATE "2019-01-11" -#define RUBY_PATCHLEVEL 128 +#define RUBY_RELEASE_DATE "2019-01-14" +#define RUBY_PATCHLEVEL 129 #define RUBY_RELEASE_YEAR 2019 #define RUBY_RELEASE_MONTH 1 -#define RUBY_RELEASE_DAY 11 +#define RUBY_RELEASE_DAY 14 #include "ruby/version.h"