1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Do not modify shared array

[Bug #15821]
This commit is contained in:
Nobuyoshi Nakada 2019-05-20 18:10:35 +09:00
parent f9696ca6cb
commit ac00bdc8a8
No known key found for this signature in database
GPG key ID: 4BC7D6DF58D8DF60
2 changed files with 12 additions and 2 deletions

13
ruby.c
View file

@ -1713,8 +1713,12 @@ process_options(int argc, char **argv, ruby_cmdline_options_t *opt)
rb_obj_freeze(opt->script_name); rb_obj_freeze(opt->script_name);
if (IF_UTF8_PATH(uenc != lenc, 1)) { if (IF_UTF8_PATH(uenc != lenc, 1)) {
long i; 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; 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) { for (i = 0; i < RARRAY_LEN(load_path); ++i) {
VALUE path = RARRAY_AREF(load_path, i); VALUE path = RARRAY_AREF(load_path, i);
int mark = rb_attr_get(path, id_initial_load_path_mark) == path; 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)
path = rb_enc_associate(rb_str_dup(path), lenc); path = rb_enc_associate(rb_str_dup(path), lenc);
#endif #endif
if (mark) rb_ivar_set(path, id_initial_load_path_mark, path); 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); 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 */ Init_ext(); /* load statically linked extensions before rubygems */
if (opt->features.set & FEATURE_BIT(gems)) { if (opt->features.set & FEATURE_BIT(gems)) {

View file

@ -385,7 +385,6 @@ class TestGc < Test::Unit::TestCase
end end
def test_gc_stress_at_startup def test_gc_stress_at_startup
skip
assert_in_out_err([{"RUBY_DEBUG"=>"gc_stress"}], '', [], [], '[Bug #15784]', success: true) assert_in_out_err([{"RUBY_DEBUG"=>"gc_stress"}], '', [], [], '[Bug #15784]', success: true)
end end