From 6ecfe643b5d8d64682c6f6bce5b27db5c007331d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89tienne=20Barri=C3=A9?= Date: Mon, 24 Mar 2025 12:17:58 +0100 Subject: Freeze $/ and make it ractor safe [Feature #21109] By always freezing when setting the global rb_rs variable, we can ensure it is not modified and can be accessed from a ractor. We're also making sure it's an instance of String and does not have any instance variables. Of course, if $/ is changed at runtime, it may cause surprising behavior but doing so is deprecated already anyway. Co-authored-by: Jean Boussier --- ruby.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'ruby.c') diff --git a/ruby.c b/ruby.c index 4dbd5909c8..49d6b3d091 100644 --- a/ruby.c +++ b/ruby.c @@ -1325,11 +1325,11 @@ proc_0_option(ruby_cmdline_options_t *opt, const char *s) if (v > 0377) rb_rs = Qnil; else if (v == 0 && numlen >= 2) { - rb_rs = rb_str_new2(""); + rb_rs = rb_fstring_lit(""); } else { c = v & 0xff; - rb_rs = rb_str_new(&c, 1); + rb_rs = rb_str_freeze(rb_str_new(&c, 1)); } return s; } -- cgit v1.2.3