* cont.c (fiber_switch): ignore fiber context switch

because destination fiber is same as current fiber.
  With out this, it may segv on FreeBSD 9.
  patched by Koichi Sasada.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33804 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
naruse 2011-11-20 21:17:57 +00:00
parent ee98d19128
commit 81bedc68ac
3 changed files with 19 additions and 0 deletions

View File

@ -1,3 +1,10 @@
Mon Nov 21 06:16:24 2011 NARUSE, Yui <naruse@ruby-lang.org>
* cont.c (fiber_switch): ignore fiber context switch
because destination fiber is same as current fiber.
With out this, it may segv on FreeBSD 9.
patched by Koichi Sasada.
Sun Nov 20 23:22:42 2011 Nobuyoshi Nakada <nobu@ruby-lang.org>
* ext/extmk.rb (extract_makefile, extmake): regenerate makefiles

7
cont.c
View File

@ -1260,6 +1260,13 @@ fiber_switch(VALUE fibval, int argc, VALUE *argv, int is_resume)
GetFiberPtr(fibval, fib);
cont = &fib->cont;
if (th->fiber == fibval) {
/* ignore fiber context switch
* because destination fiber is same as current fiber
*/
return make_passing_arg(argc, argv);
}
if (cont->saved_thread.self != th->self) {
rb_raise(rb_eFiberError, "fiber called across threads");
}

View File

@ -188,6 +188,11 @@ class TestFiber < Test::Unit::TestCase
f2 = Fiber.new{ f1.resume }
f1.transfer
}, '[ruby-dev:40833]'
assert_normal_exit %q{
require 'fiber'
Fiber.new{}.resume
1.times{Fiber.current.transfer}'
}
end
def test_resume_root_fiber