merge revision(s) ea42423908: [Backport #15887]

Keep vm->orig_progname alive
	
	`vm->orig_progname` can be different from `vm->progname` when user
	code assigns to `$0`. While `vm->progname` is kept alive by the
	global table, nothing marked `vm->orig_progname`.
	
	[Bug #15887]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_5@67761 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
usa 2019-08-26 15:10:32 +00:00
parent 522bc8ade9
commit 6e5e5df1bf
3 changed files with 10 additions and 1 deletions

View file

@ -1373,6 +1373,14 @@ class TestProcess < Test::Unit::TestCase
}
end
def test_argv0_keep_alive
assert_in_out_err([], <<~REPRO, ['-'], [], "[Bug #15887]")
$0 = "diverge"
4.times { GC.start }
puts Process.argv0
REPRO
end
def test_status
with_tmpchdir do
s = run_in_child("exit 1")

View file

@ -1,6 +1,6 @@
#define RUBY_VERSION "2.5.6"
#define RUBY_RELEASE_DATE "2019-08-27"
#define RUBY_PATCHLEVEL 179
#define RUBY_PATCHLEVEL 180
#define RUBY_RELEASE_YEAR 2019
#define RUBY_RELEASE_MONTH 8

1
vm.c
View file

@ -2100,6 +2100,7 @@ rb_vm_mark(void *ptr)
rb_gc_mark(vm->loaded_features);
rb_gc_mark(vm->loaded_features_snapshot);
rb_gc_mark(vm->top_self);
rb_gc_mark(vm->orig_progname);
RUBY_MARK_UNLESS_NULL(vm->coverages);
rb_gc_mark(vm->defined_module_hash);