ruby-changes:15784
From: mame <ko1@a...>
Date: Mon, 10 May 2010 02:33:02 +0900 (JST)
Subject: [ruby-changes:15784] Ruby:r27713 (trunk): * cont.c (fiber_switch): raise FiberError when returning to dead
mame 2010-05-10 02:32:45 +0900 (Mon, 10 May 2010) New Revision: 27713 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=27713 Log: * cont.c (fiber_switch): raise FiberError when returning to dead fiber. [ruby-dev:40833] Modified files: trunk/ChangeLog trunk/cont.c trunk/test/ruby/test_fiber.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 27712) +++ ChangeLog (revision 27713) @@ -1,3 +1,8 @@ +Mon May 10 02:29:51 2010 Yusuke Endoh <mame@t...> + + * cont.c (fiber_switch): raise FiberError when returning to dead + fiber. [ruby-dev:40833] + Mon May 10 02:07:20 2010 Yusuke Endoh <mame@t...> * lib/thread.rb (ConditionVariable#wait): ensure to remove the current Index: cont.c =================================================================== --- cont.c (revision 27712) +++ cont.c (revision 27713) @@ -1239,9 +1239,15 @@ } else if (fib->status == TERMINATED) { value = rb_exc_new2(rb_eFiberError, "dead fiber called"); - if (th->fiber != fibval) rb_exc_raise(value); - fibval = fib->prev; - if (NIL_P(fibval)) fibval = th->root_fiber; + if (th->fiber != fibval) { + GetFiberPtr(th->fiber, fib); + if (fib->status != TERMINATED) rb_exc_raise(value); + fibval = th->root_fiber; + } + else { + fibval = fib->prev; + if (NIL_P(fibval)) fibval = th->root_fiber; + } GetFiberPtr(fibval, fib); cont = &fib->cont; cont->argc = -1; Index: test/ruby/test_fiber.rb =================================================================== --- test/ruby/test_fiber.rb (revision 27712) +++ test/ruby/test_fiber.rb (revision 27713) @@ -1,6 +1,7 @@ require 'test/unit' require 'fiber' require 'continuation' +require_relative './envutil' class TestFiber < Test::Unit::TestCase def test_normal @@ -178,5 +179,15 @@ f = Fiber.new {f.resume} assert_raise(FiberError, '[ruby-core:23651]') {f.transfer} end + + def test_fiber_transfer_segv + assert_normal_exit %q{ + require 'fiber' + f2 = nil + f1 = Fiber.new{ f2.resume } + f2 = Fiber.new{ f1.resume } + f1.transfer + } + end end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/