From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS49981 109.236.80.0/20 X-Spam-Status: No, score=-1.8 required=3.0 tests=BAYES_00,RCVD_IN_XBL, RDNS_NONE,SPF_FAIL,SPF_HELO_FAIL,TO_EQ_FM_DOM_SPF_FAIL shortcircuit=no autolearn=no autolearn_force=no version=3.4.0 Received: from 80x24.org (unknown [109.236.90.209]) by dcvr.yhbt.net (Postfix) with ESMTP id 718FB20286 for ; Thu, 7 Sep 2017 19:36:04 +0000 (UTC) From: Eric Wong To: spew@80x24.org Subject: [PATCH] fiber: fix machine stack marking when FIBER_USE_NATIVE is 0 Date: Thu, 7 Sep 2017 19:35:59 +0000 Message-Id: <20170907193559.27639-1-e@80x24.org> List-Id: * 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") --- cont.c | 2 +- test/ruby/test_fiber.rb | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/cont.c b/cont.c index b27afc2158..424d6282cb 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->fiber != fib) && FIBER_SUSPENDED_P(fib)) { + if ((th->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 @@ def test_gc_root_fiber }, 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) -- EW