From 94015e0dce38d238d428b60b46dcb9f3caef445f Mon Sep 17 00:00:00 2001 From: Peter Zhu Date: Mon, 27 Nov 2023 14:45:47 -0500 Subject: Guard match from GC when scanning string We need to guard match from GC because otherwise it could end up being reclaimed or moved in compaction. --- test/ruby/test_string.rb | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'test/ruby') diff --git a/test/ruby/test_string.rb b/test/ruby/test_string.rb index 22bec09855..fdf23ad90b 100644 --- a/test/ruby/test_string.rb +++ b/test/ruby/test_string.rb @@ -1622,6 +1622,10 @@ CODE assert_equal(%w[1 2 3], S("a1 a2 a3").scan(/a\K./)) end + def test_scan_gc_compact_stress + EnvUtil.under_gc_compact_stress { assert_equal([["1a"], ["2b"], ["3c"]], S("1a2b3c").scan(/(\d.)/)) } + end + def test_scan_segv bug19159 = '[Bug #19159]' assert_nothing_raised(Exception, bug19159) do -- cgit v1.2.3