From 2910f6736e09d1faa3b06db65e44193bdd2077c0 Mon Sep 17 00:00:00 2001 From: nagachika Date: Wed, 15 Feb 2012 14:00:11 +0000 Subject: * cont.c (rb_fiber_reset_root_local_storage): add a new function to restore rb_thread_t::local_storage. * cont.c (rb_obj_is_fiber): add a new function to tell finalizer to prevent fibers from destroy. * gc.c (rb_objspace_call_finalizer): don't sweep fibers at finalizing objspace. * internal.h (rb_fiber_reset_root_local_storage, rb_obj_is_fiber): add prototypes. * vm.c (ruby_vm_destruct): reset main thread's local_storage before free main thread. rb_thread_t::local_storage is replaced by fiber's local storage when forked from fiber, and it should be already freed when the fiber was destroyed. * test/ruby/test_fiber.rb (test_fork_from_fiber): add test for fork from fiber. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34629 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_fiber.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'test') diff --git a/test/ruby/test_fiber.rb b/test/ruby/test_fiber.rb index 7127a9cb12..9bac234252 100644 --- a/test/ruby/test_fiber.rb +++ b/test/ruby/test_fiber.rb @@ -248,5 +248,21 @@ class TestFiber < Test::Unit::TestCase f.transfer } end + + def test_fork_from_fiber + begin + Process.fork{} + rescue NotImplementedError + return + end + bug5700 = '[ruby-core:41456]' + pid = nil + assert_nothing_raised(bug5700) do + Fiber.new{ pid = fork {} }.resume + end + pid, status = Process.waitpid2(pid) + assert_equal(0, status.exitstatus, bug5700) + assert_equal(false, status.signaled?, bug5700) + end end -- cgit v1.2.3