diff options
| author | Peter Zhu <peter@peterzhu.ca> | 2024-07-24 15:16:16 -0400 |
|---|---|---|
| committer | Peter Zhu <peter@peterzhu.ca> | 2024-07-25 09:23:49 -0400 |
| commit | 10574857ce167869524b97ee862b610928f6272f (patch) | |
| tree | 5aaafb2164a82087ef87d2be12a5183d2fab8348 /test/ruby/test_thread_queue.rb | |
| parent | 53f0d3b1f7ee9d1f1068b44ef856c557177704a5 (diff) | |
Fix memory leak in Regexp capture group when timeout
[Bug #20650]
The capture group allocates memory that is leaked when it times out.
For example:
re = Regexp.new("^#{"(a*)" * 10_000}x$", timeout: 0.000001)
str = "a" * 1000000 + "x"
10.times do
100.times do
re =~ str
rescue Regexp::TimeoutError
end
puts `ps -o rss= -p #{$$}`
end
Before:
34688
56416
78288
100368
120784
140704
161904
183568
204320
224800
After:
16288
16288
16880
16896
16912
16928
16944
17184
17184
17200
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/11238
Diffstat (limited to 'test/ruby/test_thread_queue.rb')
0 files changed, 0 insertions, 0 deletions
