diff options
author | Étienne Barrié <[email protected]> | 2025-03-24 12:17:58 +0100 |
---|---|---|
committer | Jean Boussier <[email protected]> | 2025-03-27 17:54:56 +0100 |
commit | 6ecfe643b5d8d64682c6f6bce5b27db5c007331d (patch) | |
tree | 3e509be8f58cf5a3fcbc4485db33e9e2b032b5a8 /ruby.c | |
parent | 49d49d5985fa22d6f283e1f0e5299d18dd94e77d (diff) |
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 <[email protected]>
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/12975
Diffstat (limited to 'ruby.c')
-rw-r--r-- | ruby.c | 4 |
1 files changed, 2 insertions, 2 deletions
@@ -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; } |