From 44379805b0859179ed4c9fb68bb2e5e95720cc3a Mon Sep 17 00:00:00 2001 From: Peter Zhu Date: Tue, 4 Jan 2022 13:54:21 -0500 Subject: [PATCH] Fix crash on bootup when RGENGC_CHECK_MODE=2 with GC stress We need to unshare the array loaded_features because the shared root could be old gen (while loaded_features is young) which causes a WB miss. --- ruby.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ruby.c b/ruby.c index f63cecdb98..b17c29a526 100644 --- a/ruby.c +++ b/ruby.c @@ -2062,7 +2062,10 @@ process_options(int argc, char **argv, ruby_cmdline_options_t *opt) for (long i = loaded_before_enc; i < RARRAY_LEN(loaded_features); ++i) { VALUE path = RARRAY_AREF(loaded_features, i); if (!(path = copy_str(path, IF_UTF8_PATH(uenc, lenc), true))) continue; - modified = true; + if (!modified) { + rb_ary_modify(loaded_features); + modified = true; + } RARRAY_ASET(loaded_features, i, path); } if (modified) {