aboutsummaryrefslogtreecommitdiffstats
path: root/test/ripper
diff options
context:
space:
mode:
authorPeter Zhu <peter@peterzhu.ca>2023-08-09 12:18:28 -0400
committerPeter Zhu <peter@peterzhu.ca>2023-08-09 14:06:58 -0400
commit0b8f15575a440f85ac686f5b0eae8f8b7c2b72e7 (patch)
treef0435bad733992270e673308cd59a04d0373e895 /test/ripper
parent5bc8fceca8d47ed1ef9c603c6531a408de36b60c (diff)
downloadruby-0b8f15575a440f85ac686f5b0eae8f8b7c2b72e7.tar.gz
Fix memory leak for incomplete lambdas
[Bug #19836] The parser does not free the chain of `struct vtable`, which causes memory leaks. The following script reproduces this issue: ``` 10.times do 100_000.times do Ripper.parse("-> {") end puts `ps -o rss= -p #{$$}` end ```
Diffstat (limited to 'test/ripper')
-rw-r--r--test/ripper/test_ripper.rb7
1 files changed, 7 insertions, 0 deletions
diff --git a/test/ripper/test_ripper.rb b/test/ripper/test_ripper.rb
index 25ddc381cc..9adfd97dfd 100644
--- a/test/ripper/test_ripper.rb
+++ b/test/ripper/test_ripper.rb
@@ -161,6 +161,13 @@ end
Ripper.parse("class Foo")
end
end;
+
+ # [Bug #19836]
+ assert_no_memory_leak(%w(-rripper), "", "#{<<~'end;'}", rss: true)
+ 1_000_000.times do
+ Ripper.parse("-> {")
+ end
+ end;
end
class TestInput < self