From 12409ad28cf909f84ccae8096bba2beb442266df Mon Sep 17 00:00:00 2001 From: normal Date: Wed, 12 Sep 2018 20:49:24 +0000 Subject: fiber: fix crash on GC after forking Remove the remainder of ROOT_FIBER_CONTEXT use and unnecessary differences between the root and non-root fiber. This makes it easier to follow new root fiber at fork time. Multiple sources of truth often leads to bugs, as in this case. We can determinte root fiber by checking a fiber against the root_fiber of its owner thread. The new `fiber_is_root_p' function supports that. Now, we can care only about free-ing/recycling/munmap-ing stacks as appropriate. [Bug #15050] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64706 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_fiber.rb | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) (limited to 'test/ruby') diff --git a/test/ruby/test_fiber.rb b/test/ruby/test_fiber.rb index c835246fda..1729147d5e 100644 --- a/test/ruby/test_fiber.rb +++ b/test/ruby/test_fiber.rb @@ -260,18 +260,25 @@ class TestFiber < Test::Unit::TestCase end def test_fork_from_fiber - begin - pid = Process.fork{} - rescue NotImplementedError - return - else - Process.wait(pid) - end + skip 'fork not supported' unless Process.respond_to?(:fork) + pid = nil bug5700 = '[ruby-core:41456]' assert_nothing_raised(bug5700) do Fiber.new do pid = fork do - Fiber.new {}.transfer + xpid = nil + Fiber.new { + xpid = fork do + # enough to trigger GC on old root fiber + 10000.times do + Fiber.new {}.transfer + Fiber.new { Fiber.yield } + end + exit!(0) + end + }.transfer + _, status = Process.waitpid2(xpid) + exit!(status.success?) end end.resume end -- cgit v1.2.3