summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2019-08-26 15:10:32 +0000
committerusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2019-08-26 15:10:32 +0000
commit6e5e5df1bfd971687cb370c4f42226a5fc255dfc (patch)
tree854ff91628279842795fee523b83afa66f42be2e
parent522bc8ade996b59a0bfca85cf448a065a37a4777 (diff)
merge revision(s) ea42423908ed055f9039b1dce6e9a232a3b2dd90: [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
-rw-r--r--test/ruby/test_process.rb8
-rw-r--r--version.h2
-rw-r--r--vm.c1
3 files changed, 10 insertions, 1 deletions
diff --git a/test/ruby/test_process.rb b/test/ruby/test_process.rb
index eb114dbebb..ba7b0f1177 100644
--- a/test/ruby/test_process.rb
+++ b/test/ruby/test_process.rb
@@ -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")
diff --git a/version.h b/version.h
index d80632ce74..f9096b5537 100644
--- a/version.h
+++ b/version.h
@@ -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
diff --git a/vm.c b/vm.c
index 5d15734055..bf7bbbf43c 100644
--- a/vm.c
+++ b/vm.c
@@ -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);