summaryrefslogtreecommitdiff
path: root/cont.c
diff options
context:
space:
mode:
authornagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2019-01-14 09:23:45 +0000
committernagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2019-01-14 09:23:45 +0000
commitb9f11b128f92048c034bb7307413d5577ca110da (patch)
treedb2fd7e4ac052b1615f6ce008caf36c7cdeb2a7f /cont.c
parent06c9877346fd88279ab664ea56e8b970667cdaa2 (diff)
merge revision(s) 64589,64593: [Backport #15041]
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] cont.c (rb_fiber_atfork): th->root_fiber may not exist Otherwise, bootstraptest/test_fork.rb fails with -DVM_CHECK_MODE=2 [Bug #15041] Fixes: r64589 "cont.c: set th->root_fiber to current fiber at fork" git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_5@66818 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'cont.c')
-rw-r--r--cont.c14
1 files changed, 14 insertions, 0 deletions
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
*