summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authornagachika <nagachika@ruby-lang.org>2023-08-13 13:35:25 +0900
committernagachika <nagachika@ruby-lang.org>2023-08-13 13:35:25 +0900
commit0c908fa681271f13750aa64420203f1a58fa03fe (patch)
treec481602fa506844e914b0e95353f11d73ec85386 /test
parent6898389a0f640c4155a7073579f43d1e16893698 (diff)
merge revision(s) 0b8f15575a440f85ac686f5b0eae8f8b7c2b72e7: [Backport #19836]
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 ``` --- parse.y | 24 ++++++++++++++---------- test/ripper/test_ripper.rb | 7 +++++++ 2 files changed, 21 insertions(+), 10 deletions(-)
Diffstat (limited to 'test')
-rw-r--r--test/ripper/test_ripper.rb29
1 files changed, 22 insertions, 7 deletions
diff --git a/test/ripper/test_ripper.rb b/test/ripper/test_ripper.rb
index a9773a89d8..83b43d67fe 100644
--- a/test/ripper/test_ripper.rb
+++ b/test/ripper/test_ripper.rb
@@ -120,13 +120,6 @@ class TestRipper::Ripper < Test::Unit::TestCase
END
assert_nil(Ripper.sexp(src), bug12651)
end;
-
- # [Bug #19835]
- assert_no_memory_leak(%w(-rripper), "", "#{<<~'end;'}", rss: true)
- 1_000_000.times do
- Ripper.parse("class Foo")
- end
- end;
end
# https://bugs.jruby.org/4176
@@ -148,6 +141,28 @@ end
assert_nothing_raised { Ripper.lex src }
end
+ def test_no_memory_leak
+ assert_no_memory_leak(%w(-rripper), "", "#{<<~'end;'}", rss: true)
+ 2_000_000.times do
+ Ripper.parse("")
+ end
+ end;
+
+ # [Bug #19835]
+ assert_no_memory_leak(%w(-rripper), "", "#{<<~'end;'}", rss: true)
+ 1_000_000.times do
+ 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
Input = Struct.new(:lines) do
def gets