ruby-changes:53892
From: samuel <ko1@a...>
Date: Sat, 1 Dec 2018 12:49:56 +0900 (JST)
Subject: [ruby-changes:53892] samuel:r66111 (trunk): Avoid GCing dead stack after switching away from a fiber
samuel 2018-12-01 12:49:52 +0900 (Sat, 01 Dec 2018) New Revision: 66111 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=66111 Log: Avoid GCing dead stack after switching away from a fiber Fixes <https://bugs.ruby-lang.org/issues/14561> and discussed <https://bugs.ruby-lang.org/issues/15362>. Modified files: trunk/cont.c trunk/test/ruby/test_fiber.rb Index: test/ruby/test_fiber.rb =================================================================== --- test/ruby/test_fiber.rb (revision 66110) +++ test/ruby/test_fiber.rb (revision 66111) @@ -398,4 +398,14 @@ class TestFiber < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_fiber.rb#L398 }.value assert_equal :ok, ret, '[Bug #14642]' end + + def test_machine_stack_gc + assert_normal_exit <<-RUBY, '[Bug #14561]', timeout: 10 + enum = Enumerator.new { |y| y << 1 } + thread = Thread.new { enum.peek } + thread.join + sleep 5 # pause until thread cache wait time runs out. Native thread exits. + GC.start + RUBY + end end Index: cont.c =================================================================== --- cont.c (revision 66110) +++ cont.c (revision 66111) @@ -1747,6 +1747,7 @@ fiber_store(rb_fiber_t *next_fib, rb_thr https://github.com/ruby/ruby/blob/trunk/cont.c#L1747 return fib->cont.value; #else /* FIBER_USE_NATIVE */ + fib->cont.saved_ec.machine.stack_end = NULL; if (ruby_setjmp(fib->cont.jmpbuf)) { /* restored */ fib = th->ec->fiber_ptr; -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/