ruby-changes:54397
From: samuel <ko1@a...>
Date: Fri, 28 Dec 2018 22:03:17 +0900 (JST)
Subject: [ruby-changes:54397] samuel:r66611 (trunk): Don't allow rb_fiber_resume to raise exception on unborn fiber.
samuel 2018-12-28 22:03:14 +0900 (Fri, 28 Dec 2018) New Revision: 66611 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=66611 Log: Don't allow rb_fiber_resume to raise exception on unborn fiber. Modified files: trunk/cont.c trunk/test/ruby/test_fiber.rb Index: cont.c =================================================================== --- cont.c (revision 66610) +++ cont.c (revision 66611) @@ -1896,9 +1896,14 @@ rb_fiber_resume(VALUE fibval, int argc, https://github.com/ruby/ruby/blob/trunk/cont.c#L1896 { rb_fiber_t *fib = fiber_ptr(fibval); + if (argc == -1 && FIBER_CREATED_P(fib)) { + rb_raise(rb_eFiberError, "cannot raise exception on unborn fiber"); + } + if (fib->prev != 0 || fiber_is_root_p(fib)) { rb_raise(rb_eFiberError, "double resume"); } + if (fib->transferred != 0) { rb_raise(rb_eFiberError, "cannot resume transferred Fiber"); } Index: test/ruby/test_fiber.rb =================================================================== --- test/ruby/test_fiber.rb (revision 66610) +++ test/ruby/test_fiber.rb (revision 66611) @@ -144,6 +144,7 @@ class TestFiber < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_fiber.rb#L144 } assert_raise(RuntimeError){ fib = Fiber.new{ Fiber.yield } + fib.resume fib.raise "raise and propagate" } assert_nothing_raised{ -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/