From e94a2f691d67ad98be9036e76c765fcfa7d22552 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Tue, 14 Oct 2025 12:38:52 +0900 Subject: [PATCH] [Bug #21638] Mark ractor-local `$VERBOSE` and `$DEBUG` https://github.com/sampersand/blog/blob/master/the%20-s%20flag.md#the-segfault --- ractor.c | 2 ++ test/ruby/test_rubyoptions.rb | 2 ++ 2 files changed, 4 insertions(+) diff --git a/ractor.c b/ractor.c index 43a7f6c140e11d..8e7f7d6497fb44 100644 --- a/ractor.c +++ b/ractor.c @@ -216,6 +216,8 @@ ractor_mark(void *ptr) rb_gc_mark(r->r_stdin); rb_gc_mark(r->r_stdout); rb_gc_mark(r->r_stderr); + rb_gc_mark(r->verbose); + rb_gc_mark(r->debug); rb_hook_list_mark(&r->pub.hooks); if (r->threads.cnt > 0) { diff --git a/test/ruby/test_rubyoptions.rb b/test/ruby/test_rubyoptions.rb index 8126cb3c268b37..527208cee5219d 100644 --- a/test/ruby/test_rubyoptions.rb +++ b/test/ruby/test_rubyoptions.rb @@ -530,6 +530,8 @@ def test_sflag assert_in_out_err(%w(- -#=foo), "#!ruby -s\n", [], /invalid name for global variable - -# \(NameError\)/) + + assert_in_out_err(['-s', '-e', 'GC.start; p $DEBUG', '--', '-DEBUG=x'], "", ['"x"']) end def test_option_missing_argument