aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-09-08 23:51:14 +0000
committernormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-09-08 23:51:14 +0000
commitf07bcd3d136bd2751111839a4f88985c5bcf6b2c (patch)
treeb047b20a2e723aa27b8ad9ffb043ecc0a15e3886
parentf8545265650328820e6405724371bc7b3781f2cd (diff)
downloadruby-f07bcd3d136bd2751111839a4f88985c5bcf6b2c.tar.gz
fiber: fix machine stack marking when FIBER_USE_NATIVE is 0
* cont.c (cont_mark): mark Fiber machine stack correctly when FIBER_USE_NATIVE is 0 * test/ruby/test_fiber.rb (test_mark_fiber): new test [Bug #13875] [ruby-core:82681] This bug appears to be introduced with r59557. ("refactoring Fiber status") git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59785 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--cont.c2
-rw-r--r--test/ruby/test_fiber.rb11
2 files changed, 12 insertions, 1 deletions
diff --git a/cont.c b/cont.c
index f49ed2bde5..c89f7404f6 100644
--- a/cont.c
+++ b/cont.c
@@ -248,7 +248,7 @@ cont_mark(void *ptr)
const rb_thread_t *th = rb_thread_ptr(cont->saved_thread.self);
const rb_fiber_t *fib = (rb_fiber_t*)cont;
- if ((th->ec.fiber != fib) && FIBER_SUSPENDED_P(fib)) {
+ if ((th->ec.fiber != fib) && !FIBER_TERMINATED_P(fib)) {
rb_gc_mark_locations(cont->machine.stack,
cont->machine.stack + cont->machine.stack_size);
}
diff --git a/test/ruby/test_fiber.rb b/test/ruby/test_fiber.rb
index 59290545f6..c9a0b58d70 100644
--- a/test/ruby/test_fiber.rb
+++ b/test/ruby/test_fiber.rb
@@ -217,6 +217,17 @@ class TestFiber < Test::Unit::TestCase
}, bug4612
end
+ def test_mark_fiber
+ bug13875 = '[ruby-core:82681]'
+
+ assert_normal_exit %q{
+ GC.stress = true
+ up = 1.upto(10)
+ down = 10.downto(1)
+ up.zip(down) {|a, b| a + b == 11 or fail 'oops'}
+ }, bug13875
+ end
+
def test_no_valid_cfp
bug5083 = '[ruby-dev:44208]'
assert_equal([], Fiber.new(&Module.method(:nesting)).resume, bug5083)