From a9afb7e5c6c608ba8e996dd5771b1da38ef8a9b3 Mon Sep 17 00:00:00 2001 From: mame Date: Wed, 3 Nov 2010 17:08:25 +0000 Subject: [PATCH] * cont.c (rb_fiber_resume): raise an "double resume" error when root fiber is going to be resumed. [ruby-dev:42523] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29680 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ cont.c | 2 +- test/ruby/test_fiber.rb | 8 ++++++++ 3 files changed, 14 insertions(+), 1 deletion(-) 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