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: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.0 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 8E6FB202A4; Fri, 8 Sep 2017 06:28:17 +0000 (UTC) Date: Fri, 8 Sep 2017 06:28:17 +0000 From: Eric Wong To: spew@80x24.org Subject: [PATCH v2] fiber: fix machine stack marking when FIBER_USE_NATIVE is 0 Message-ID: <20170908062817.GA9144@dcvr> References: <20170907193559.27639-1-e@80x24.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <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 abfc1c384c..b942e30b7f 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 @@ 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