[Ruby 1.9-Bug#4019][Open] root fiber allows double resume

Bug #4019: root fiber allows double resume
http://redmine.ruby-lang.org/issues/show/4019

$B5/I<<T(B: Yusuke E.
$B%9%F!<%?%9(B: Open, $BM%@john(B: Normal
$B%+%F%4%j(B: core
ruby -v: ruby 1.9.3dev (2010-11-03 trunk 29679) [i686-linux]

$B1sF#$G$9!#(B

Fiber $B$O<+J,<+?H$r(B ($BD>@$^[email protected]\E*$K(B) resume
$B$7$h$&$H$9$k$H(B
double resume $B$H$$$&Nc30$rEj$2$^$9$,(B

require “fiber”
Fiber.new do
Fiber.current.resume #=> double resume (FiberError)
end

root fiber $B$N>l9g$O(B 1 [email protected][email protected]$$$^$;$s!#(B

require “fiber”
Fiber.current.resume #=> nil
Fiber.current.resume #=> double resume (FiberError)

diff --git a/cont.c b/cont.c
index b0b3f41…b0defca 100644
— a/cont.c
+++ b/cont.c
@@ -1292,7 +1292,7 @@ rb_fiber_resume(VALUE fibval, int argc, VALUE
*argv)
rb_fiber_t *fib;
GetFiberPtr(fibval, fib);

  • if (fib->prev != Qnil) {
  • if (fib->prev != Qnil || fib->cont.type == ROOT_FIBER_CONTEXT) {
    rb_raise(rb_eFiberError, “double resume”);
    }

diff --git a/test/ruby/test_fiber.rb b/test/ruby/test_fiber.rb
index edfe55a…ec64f98 100644
— a/test/ruby/test_fiber.rb
+++ b/test/ruby/test_fiber.rb
@@ -189,5 +189,13 @@ class TestFiber < Test::Unit::TestCase
f1.transfer
}, ‘[ruby-dev:40833]’
end
+

  • def test_resume_root_fiber
  • assert_raise(FiberError) do
  •  Thread.new do
    
  •    Fiber.current.resume
    
  •  end.join
    
  • end
  • end
    end


Yusuke E. [email protected]

[email protected]$G$9!#(B

(2010/11/03 16:00), Yusuke E. wrote:

Fiber $B$O<+J,<+?H$r(B ($BD>@$^[email protected]\E*$K(B) resume $B$7$h$&$H$9$k$H(B
double resume $B$H$$$&Nc30$rEj$2$^$9$,(B

require “fiber”
Fiber.new do
Fiber.current.resume #=> double resume (FiberError)
end

root fiber $B$N>l9g$O(B 1 [email protected][email protected]$$$^$;$s!#(B

$B!!$4;XE&$"$j$,$H$&$4$6$$$^$9!#%3%_%C%H$b$*4j$$$7$^$9!#(B

$B%A%1%C%H(B #4019 $B$,99?7$5$l$^$7$?!#(B (by Yusuke E.)

$B%9%F!<%?%9(B Open$B$+$i(BClosed$B$KJQ99(B
$B?JD=(B % 0$B$+$i(B100$B$KJQ99(B

This issue was solved with changeset r29680.
Yusuke, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.