[前][次][番号順一覧][スレッド一覧]

ruby-changes:55765

From: Nobuyoshi <ko1@a...>
Date: Tue, 21 May 2019 14:19:24 +0900 (JST)
Subject: [ruby-changes:55765] Nobuyoshi Nakada: ac00bdc8a8 (trunk): Do not modify shared array

https://git.ruby-lang.org/ruby.git/commit/?id=ac00bdc8a8

From ac00bdc8a8ac2c62a94dd36a7784d15bbcb7df19 Mon Sep 17 00:00:00 2001
From: Nobuyoshi Nakada <nobu@r...>
Date: Mon, 20 May 2019 18:10:35 +0900
Subject: Do not modify shared array

[Bug #15821]

diff --git a/ruby.c b/ruby.c
index bf94b8e..944b6c7 100644
--- a/ruby.c
+++ b/ruby.c
@@ -1713,8 +1713,12 @@ process_options(int argc, char **argv, ruby_cmdline_options_t *opt) https://github.com/ruby/ruby/blob/trunk/ruby.c#L1713
     rb_obj_freeze(opt->script_name);
     if (IF_UTF8_PATH(uenc != lenc, 1)) {
 	long i;
-	VALUE load_path = GET_VM()->load_path;
+        rb_vm_t *vm = GET_VM();
+        VALUE load_path = vm->load_path;
 	const ID id_initial_load_path_mark = INITIAL_LOAD_PATH_MARK;
+        int modifiable = FALSE;
+
+        rb_get_expanded_load_path();
 	for (i = 0; i < RARRAY_LEN(load_path); ++i) {
 	    VALUE path = RARRAY_AREF(load_path, i);
 	    int mark = rb_attr_get(path, id_initial_load_path_mark) == path;
@@ -1726,8 +1730,15 @@ process_options(int argc, char **argv, ruby_cmdline_options_t *opt) https://github.com/ruby/ruby/blob/trunk/ruby.c#L1730
 	    path = rb_enc_associate(rb_str_dup(path), lenc);
 #endif
 	    if (mark) rb_ivar_set(path, id_initial_load_path_mark, path);
+            if (!modifiable) {
+                rb_ary_modify(load_path);
+                modifiable = TRUE;
+            }
 	    RARRAY_ASET(load_path, i, path);
 	}
+        if (modifiable) {
+            rb_ary_replace(vm->load_path_snapshot, load_path);
+        }
     }
     Init_ext();		/* load statically linked extensions before rubygems */
     if (opt->features.set & FEATURE_BIT(gems)) {
diff --git a/test/ruby/test_gc.rb b/test/ruby/test_gc.rb
index d59bdfd..5dea1b2 100644
--- a/test/ruby/test_gc.rb
+++ b/test/ruby/test_gc.rb
@@ -385,7 +385,6 @@ class TestGc < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_gc.rb#L385
   end
 
   def test_gc_stress_at_startup
-    skip
     assert_in_out_err([{"RUBY_DEBUG"=>"gc_stress"}], '', [], [], '[Bug #15784]', success: true)
   end
 
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]