mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* cont.c (fiber_switch): raise FiberError when returning to dead
fiber. [ruby-dev:40833] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27713 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
e2ab44ac40
commit
b664caeb78
3 changed files with 25 additions and 3 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
Mon May 10 02:29:51 2010 Yusuke Endoh <mame@tsg.ne.jp>
|
||||||
|
|
||||||
|
* cont.c (fiber_switch): raise FiberError when returning to dead
|
||||||
|
fiber. [ruby-dev:40833]
|
||||||
|
|
||||||
Mon May 10 02:07:20 2010 Yusuke Endoh <mame@tsg.ne.jp>
|
Mon May 10 02:07:20 2010 Yusuke Endoh <mame@tsg.ne.jp>
|
||||||
|
|
||||||
* lib/thread.rb (ConditionVariable#wait): ensure to remove the current
|
* lib/thread.rb (ConditionVariable#wait): ensure to remove the current
|
||||||
|
|
8
cont.c
8
cont.c
|
@ -1239,9 +1239,15 @@ fiber_switch(VALUE fibval, int argc, VALUE *argv, int is_resume)
|
||||||
}
|
}
|
||||||
else if (fib->status == TERMINATED) {
|
else if (fib->status == TERMINATED) {
|
||||||
value = rb_exc_new2(rb_eFiberError, "dead fiber called");
|
value = rb_exc_new2(rb_eFiberError, "dead fiber called");
|
||||||
if (th->fiber != fibval) rb_exc_raise(value);
|
if (th->fiber != fibval) {
|
||||||
|
GetFiberPtr(th->fiber, fib);
|
||||||
|
if (fib->status != TERMINATED) rb_exc_raise(value);
|
||||||
|
fibval = th->root_fiber;
|
||||||
|
}
|
||||||
|
else {
|
||||||
fibval = fib->prev;
|
fibval = fib->prev;
|
||||||
if (NIL_P(fibval)) fibval = th->root_fiber;
|
if (NIL_P(fibval)) fibval = th->root_fiber;
|
||||||
|
}
|
||||||
GetFiberPtr(fibval, fib);
|
GetFiberPtr(fibval, fib);
|
||||||
cont = &fib->cont;
|
cont = &fib->cont;
|
||||||
cont->argc = -1;
|
cont->argc = -1;
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
require 'test/unit'
|
require 'test/unit'
|
||||||
require 'fiber'
|
require 'fiber'
|
||||||
require 'continuation'
|
require 'continuation'
|
||||||
|
require_relative './envutil'
|
||||||
|
|
||||||
class TestFiber < Test::Unit::TestCase
|
class TestFiber < Test::Unit::TestCase
|
||||||
def test_normal
|
def test_normal
|
||||||
|
@ -178,5 +179,15 @@ class TestFiber < Test::Unit::TestCase
|
||||||
f = Fiber.new {f.resume}
|
f = Fiber.new {f.resume}
|
||||||
assert_raise(FiberError, '[ruby-core:23651]') {f.transfer}
|
assert_raise(FiberError, '[ruby-core:23651]') {f.transfer}
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue