8000 Add memory leak test for Regexp timeout · ruby/ruby@0f3dc8f · GitHub
[go: up one dir, main page]

Skip to content

Commit 0f3dc8f

Browse files
committed
Add memory leak test for Regexp timeout
[Bug #20228]
1 parent a7e7718 commit 0f3dc8f

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

test/ruby/test_regexp.rb

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1807,6 +1807,23 @@ def test_s_timeout_corner_cases
18071807
end;
18081808
end
18091809

1810+
def test_s_timeout_memory_leak
1811+
assert_no_memory_leak([], "#{<<~"begin;"}", "#{<<~"end;"}", "[Bug #20228]", rss: true)
1812+
Regexp.timeout = 0.001
1813+
regex = /^(a*)*$/
1814+
str = "a" * 1000000 + "x"
1815+
1816+
code = proc do
1817+
regex =~ str
1818+
rescue
1819+
end
1820+
1821+
10.times(&code)
1822+
begin;
1823+
1_000.times(&code)
1824+
end;
1825+
end
1826+
18101827
def per_instance_redos_test(global_timeout, per_instance_timeout, expected_timeout)
18111828
assert_separately([], "#{<<-"begin;"}\n#{<<-'end;'}")
18121829
global_timeout = #{ EnvUtil.apply_timeout_scale(global_timeout).inspect }

0 commit comments

Comments
 (0)
0