diff --git a/ChangeLog b/ChangeLog index 8d18179a40..c10ca38196 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Thu Nov 4 02:04:25 2010 Yusuke Endoh + + * cont.c (rb_fiber_resume): raise an "double resume" error when root + fiber is going to be resumed. [ruby-dev:42523] + Wed Nov 3 14:17:18 2010 Nobuyoshi Nakada * lib/ostruct.rb (OpenStruct#delete_field): also undefine diff --git a/cont.c b/cont.c index b0b3f41c7d..b0defcaeb7 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 edfe55a1d3..ec64f98229 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