[ruby-core:117227] [Ruby master Bug#20348] Memory leak with method kwargs in ERB template

Issue #20348 has been reported by davidtaylorhq (David Taylor). ---------------------------------------- Bug #20348: Memory leak with method kwargs in ERB template https://bugs.ruby-lang.org/issues/20348 * Author: davidtaylorhq (David Taylor) * Status: Open * ruby -v: ruby 3.3.0 (2023-12-25 revision 5124f9ac75) [arm64-darwin23] * Backport: 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN ---------------------------------------- Evaluating ERB templates with kwarg method calls leads to unbounded growth in memory use. Example script: ```ruby require "erb" def noop(kwarg1:); end template = ERB.new("<%= noop kwarg1: false %>") 50.times do 10_000.times do template.result(binding) end GC.start; puts "Object Count: #{ObjectSpace.count_objects[:TOTAL]}" end ``` When run, this script will print something like: ``` Object Count: 53825 Object Count: 80432 Object Count: 105811 Object Count: 137331 Object Count: 179491 Object Count: 179491 Object Count: 236389 ... ``` This issue does not occur when the keyword argument is replaced with a positional argument. I can reproduce the issue using Ruby 3.0.6, 3.1.4, 3.2.3 and 3.3.0. The issue does not reproduce using Ruby 2.7.8. -- https://bugs.ruby-lang.org/

Issue #20348 has been updated by jeremyevans0 (Jeremy Evans). This has been fixed in the master branch. However, I'm not sure which commit fixed it. ---------------------------------------- Bug #20348: Memory leak with method kwargs in ERB template https://bugs.ruby-lang.org/issues/20348#change-107319 * Author: davidtaylorhq (David Taylor) * Status: Open * ruby -v: ruby 3.3.0 (2023-12-25 revision 5124f9ac75) [arm64-darwin23] * Backport: 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN ---------------------------------------- Evaluating ERB templates with kwarg method calls leads to unbounded growth in memory use. Example script: ```ruby require "erb" def noop(kwarg1:); end template = ERB.new("<%= noop kwarg1: false %>") 50.times do 10_000.times do template.result(binding) end GC.start; puts "Object Count: #{ObjectSpace.count_objects[:TOTAL]}" end ``` When run, this script will print something like: ``` Object Count: 53825 Object Count: 80432 Object Count: 105811 Object Count: 137331 Object Count: 179491 Object Count: 179491 Object Count: 236389 ... ``` This issue does not occur when the keyword argument is replaced with a positional argument. I can reproduce the issue using Ruby 3.0.6, 3.1.4, 3.2.3 and 3.3.0. The issue does not reproduce using Ruby 2.7.8. -- https://bugs.ruby-lang.org/

Issue #20348 has been updated by byroot (Jean Boussier). I suspect it's https://github.com/ruby/ruby/pull/9973, trying to confirm. ---------------------------------------- Bug #20348: Memory leak with method kwargs in ERB template https://bugs.ruby-lang.org/issues/20348#change-107338 * Author: davidtaylorhq (David Taylor) * Status: Open * ruby -v: ruby 3.3.0 (2023-12-25 revision 5124f9ac75) [arm64-darwin23] * Backport: 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN ---------------------------------------- Evaluating ERB templates with kwarg method calls leads to unbounded growth in memory use. Example script: ```ruby require "erb" def noop(kwarg1:); end template = ERB.new("<%= noop kwarg1: false %>") 50.times do 10_000.times do template.result(binding) end GC.start; puts "Object Count: #{ObjectSpace.count_objects[:TOTAL]}" end ``` When run, this script will print something like: ``` Object Count: 53825 Object Count: 80432 Object Count: 105811 Object Count: 137331 Object Count: 179491 Object Count: 179491 Object Count: 236389 ... ``` This issue does not occur when the keyword argument is replaced with a positional argument. I can reproduce the issue using Ruby 3.0.6, 3.1.4, 3.2.3 and 3.3.0. The issue does not reproduce using Ruby 2.7.8. -- https://bugs.ruby-lang.org/

Issue #20348 has been updated by byroot (Jean Boussier). Status changed from Open to Closed Confirmed, this is a duplicate of [Bug #19907]. I'll make that one for backport. ---------------------------------------- Bug #20348: Memory leak with method kwargs in ERB template https://bugs.ruby-lang.org/issues/20348#change-107339 * Author: davidtaylorhq (David Taylor) * Status: Closed * ruby -v: ruby 3.3.0 (2023-12-25 revision 5124f9ac75) [arm64-darwin23] * Backport: 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN ---------------------------------------- Evaluating ERB templates with kwarg method calls leads to unbounded growth in memory use. Example script: ```ruby require "erb" def noop(kwarg1:); end template = ERB.new("<%= noop kwarg1: false %>") 50.times do 10_000.times do template.result(binding) end GC.start; puts "Object Count: #{ObjectSpace.count_objects[:TOTAL]}" end ``` When run, this script will print something like: ``` Object Count: 53825 Object Count: 80432 Object Count: 105811 Object Count: 137331 Object Count: 179491 Object Count: 179491 Object Count: 236389 ... ``` This issue does not occur when the keyword argument is replaced with a positional argument. I can reproduce the issue using Ruby 3.0.6, 3.1.4, 3.2.3 and 3.3.0. The issue does not reproduce using Ruby 2.7.8. -- https://bugs.ruby-lang.org/
participants (3)
-
byroot (Jean Boussier)
-
davidtaylorhq (David Taylor)
-
jeremyevans0 (Jeremy Evans)