diff options
-rw-r--r-- | string.c | 1 | ||||
-rw-r--r-- | test/ruby/test_string.rb | 11 |
2 files changed, 12 insertions, 0 deletions
@@ -10191,6 +10191,7 @@ Init_String(void) rb_fs = Qnil; rb_define_hooked_variable("$;", &rb_fs, 0, rb_fs_setter); rb_define_hooked_variable("$-F", &rb_fs, 0, rb_fs_setter); + rb_gc_register_address(&rb_fs); rb_cSymbol = rb_define_class("Symbol", rb_cObject); rb_include_module(rb_cSymbol, rb_mComparable); diff --git a/test/ruby/test_string.rb b/test/ruby/test_string.rb index 39cfc9a220..7dbf27e552 100644 --- a/test/ruby/test_string.rb +++ b/test/ruby/test_string.rb @@ -1451,6 +1451,17 @@ CODE assert_raise_with_message(TypeError, /\$;/) { $; = [] } + + assert_separately([], "#{<<~"begin;"}\n#{<<~'end;'}") + bug = '[ruby-core:79582] $; must not be GCed' + begin; + $; = " " + $a = nil + alias $; $a + alias $-F $a + GC.start + assert_equal([], "".split, bug) + end; end def test_split_encoding |