From ac543abe91d7325ace7254f635f34e71e1faaf2e Mon Sep 17 00:00:00 2001 From: normal Date: Wed, 29 Aug 2018 08:04:09 +0000 Subject: cont.c: set th->root_fiber to current fiber at fork Otherwise, th->root_fiber can point to an invalid Fiber, because Fibers do not live across fork. So consider whatever Fiber is running the root fiber. [ruby-core:88723] [Bug #15041] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64589 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- cont.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'cont.c') diff --git a/cont.c b/cont.c index c400640dc4..3f0a5cb45f 100644 --- a/cont.c +++ b/cont.c @@ -1977,6 +1977,18 @@ 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->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 * -- cgit v1.2.3