Skip to content

Commit

Permalink
merge revision(s) 66111: [Backport #14561]
Browse files Browse the repository at this point in the history
	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>.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_5@66777 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
nagachika committed Jan 10, 2019
1 parent e804822 commit 0e0d0c4
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
1 change: 1 addition & 0 deletions cont.c
Expand Up @@ -1616,6 +1616,7 @@ fiber_store(rb_fiber_t *next_fib, rb_thread_t *th)
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;
Expand Down
10 changes: 10 additions & 0 deletions test/ruby/test_fiber.rb
Expand Up @@ -378,4 +378,14 @@ def test_to_s
assert_match(/terminated/, f.to_s)
assert_match(/resumed/, Fiber.current.to_s)
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
6 changes: 3 additions & 3 deletions version.h
@@ -1,10 +1,10 @@
#define RUBY_VERSION "2.5.4"
#define RUBY_RELEASE_DATE "2019-01-07"
#define RUBY_PATCHLEVEL 125
#define RUBY_RELEASE_DATE "2019-01-10"
#define RUBY_PATCHLEVEL 126

#define RUBY_RELEASE_YEAR 2019
#define RUBY_RELEASE_MONTH 1
#define RUBY_RELEASE_DAY 7
#define RUBY_RELEASE_DAY 10

#include "ruby/version.h"

Expand Down

0 comments on commit 0e0d0c4

Please sign in to comment.