diff options
author | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-11-20 21:17:57 +0000 |
---|---|---|
committer | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-11-20 21:17:57 +0000 |
commit | 81bedc68ac9786004d304e2431897a07b8d26000 (patch) | |
tree | 83f9846f6be07462ff158982bad5df59a87fe892 | |
parent | ee98d19128d0c12fcc469490269efccfe80f0984 (diff) | |
download | ruby-81bedc68ac9786004d304e2431897a07b8d26000.tar.gz |
* 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
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | cont.c | 7 | ||||
-rw-r--r-- | test/ruby/test_fiber.rb | 5 |
3 files changed, 19 insertions, 0 deletions
@@ -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 @@ -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"); } diff --git a/test/ruby/test_fiber.rb b/test/ruby/test_fiber.rb index 7cf4a6b119..7127a9cb12 100644 --- a/test/ruby/test_fiber.rb +++ b/test/ruby/test_fiber.rb @@ -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 |