зеркало из https://github.com/github/ruby.git
* 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:
Родитель
e2ab44ac40
Коммит
b664caeb78
|
@ -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>
|
||||
|
||||
* lib/thread.rb (ConditionVariable#wait): ensure to remove the current
|
||||
|
|
12
cont.c
12
cont.c
|
@ -1239,9 +1239,15 @@ fiber_switch(VALUE fibval, int argc, VALUE *argv, int is_resume)
|
|||
}
|
||||
else if (fib->status == TERMINATED) {
|
||||
value = rb_exc_new2(rb_eFiberError, "dead fiber called");
|
||||
if (th->fiber != fibval) rb_exc_raise(value);
|
||||
fibval = fib->prev;
|
||||
if (NIL_P(fibval)) fibval = th->root_fiber;
|
||||
if (th->fiber != fibval) {
|
||||
GetFiberPtr(th->fiber, fib);
|
||||
if (fib->status != TERMINATED) rb_exc_raise(value);
|
||||
fibval = th->root_fiber;
|
||||
}
|
||||
else {
|
||||
fibval = fib->prev;
|
||||
if (NIL_P(fibval)) fibval = th->root_fiber;
|
||||
}
|
||||
GetFiberPtr(fibval, fib);
|
||||
cont = &fib->cont;
|
||||
cont->argc = -1;
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
require 'test/unit'
|
||||
require 'fiber'
|
||||
require 'continuation'
|
||||
require_relative './envutil'
|
||||
|
||||
class TestFiber < Test::Unit::TestCase
|
||||
def test_normal
|
||||
|
@ -178,5 +179,15 @@ class TestFiber < Test::Unit::TestCase
|
|||
f = Fiber.new {f.resume}
|
||||
assert_raise(FiberError, '[ruby-core:23651]') {f.transfer}
|
||||
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
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче