Project

General

Profile

Actions

Bug #19970

closed

Eval leaks callcache and callinfo objects on arm32 (linux)

Bug #19970: Eval leaks callcache and callinfo objects on arm32 (linux)
1

Added by larsin (Lars Ingjer) almost 3 years ago. Updated 10 days ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 3.2.2 (2023-03-30 revision e51014f9c0) [armv7l-linux-eabihf]
[ruby-core:115143]

Description

The following script demonstrates a memory leak on arm 32 (linux):

def gcdiff(n)
  GC.start
  if @last_gc_stat
     puts "GC.stat #{n} diff old_objects: #{GC.stat(:old_objects) - @last_gc_stat}"
  end
  
  @last_gc_stat = GC.stat(:old_objects)
end

def foo
end

10.times do |i|
  10_000.times do
    eval 'foo'
  end

  gcdiff(i)
  puts "Number of live objects: #{GC.stat(:heap_live_slots)}"
  puts "Memory usage: #{`ps -o rss= -p #{$$}`}"
  puts
end

Output:

Number of live objects: 41303
Memory usage: 11900

GC.stat 1 diff old_objects: 20037
Number of live objects: 61317
Memory usage: 13604

GC.stat 2 diff old_objects: 20001
Number of live objects: 81317
Memory usage: 14880

GC.stat 3 diff old_objects: 20000
Number of live objects: 101317
Memory usage: 16596

GC.stat 4 diff old_objects: 20000
Number of live objects: 121317
Memory usage: 17248

GC.stat 5 diff old_objects: 20000
Number of live objects: 141317
Memory usage: 18760

GC.stat 6 diff old_objects: 20000
Number of live objects: 161317
Memory usage: 19540

GC.stat 7 diff old_objects: 20000
Number of live objects: 181317
Memory usage: 21752

GC.stat 8 diff old_objects: 20000
Number of live objects: 201317
Memory usage: 21828

GC.stat 9 diff old_objects: 20000
Number of live objects: 221317
Memory usage: 24896

ObjectSpace.count_imemo_objects shows that imemo_callcache and imemo_callinfo are leaking.

The issue does not occur on arm64 mac or x86_64 linux with the same ruby version.
The issue has also been reproduced with the latest 3.2.2 snapshot (2023-09-30).


Related issues 1 (0 open1 closed)

Related to Ruby - Bug #19907: Method calls with keyword arguments in eval leaks callcache and callinfo objectsClosedActions

Updated by larsin (Lars Ingjer) almost 3 years ago Actions #1 [ruby-core:115160]

The issue has also been reproduced on master (ruby 3.3.0dev (2023-10-24 master 60196b4780) [armv7l-linux-eabihf]).

Updated by jhawthorn (John Hawthorn) over 2 years ago Actions #2 [ruby-core:116671]

I suspect this is the same underlying issue as #19907, but on wider platforms it only occurs with kwargs.

Updated by jhawthorn (John Hawthorn) over 2 years ago Actions #3

  • Related to Bug #19907: Method calls with keyword arguments in eval leaks callcache and callinfo objects added

Updated by wanabe (_ wanabe) 10 days ago Actions #4 [ruby-core:126479]

  • Status changed from Open to Closed

It has been fixed at 1c97abaabae6844c861705fd07f532292dcffa74 == https://bugs.ruby-lang.org/issues/19907.
I confirmed it with arm32v7/ubuntu:noble docker image on qemu-user-static.

root@1294e0e49506:/ruby/tmp/master# for commit in 1c97abaabae6844c861705fd07f532292dcffa74~ 1c97abaabae6844c861705fd07f532292dcffa74; do git checkout $commit &
& make -j miniruby >/dev/null 2>&1 && ./miniruby -v && ./miniruby ../a.rb|grep "diff old_objects"; done
Previous HEAD position was 081ee3d3550 Add memory leak test for eval kwargs
HEAD is now at 2a6917b463f Fix string value in hash literal being forced frozen
ruby 3.4.0dev (2024-02-21T02:00:54Z v3_4_0_preview1~1777 2a6917b463) [armv7l-linux-eabihf]
GC.stat 1 diff old_objects: 19667
GC.stat 2 diff old_objects: 15357
GC.stat 3 diff old_objects: 23028
GC.stat 4 diff old_objects: 14128
GC.stat 5 diff old_objects: 9381
GC.stat 6 diff old_objects: 20000
GC.stat 7 diff old_objects: 20000
GC.stat 8 diff old_objects: 20000
GC.stat 9 diff old_objects: 20000
Previous HEAD position was 2a6917b463f Fix string value in hash literal being forced frozen
HEAD is now at 1c97abaabae De-dup identical callinfo objects
ruby 3.4.0dev (2024-02-21T02:55:00Z v3_4_0_preview1~1776 1c97abaaba) [armv7l-linux-eabihf]
GC.stat 1 diff old_objects: 85
GC.stat 2 diff old_objects: 41
GC.stat 3 diff old_objects: 42
GC.stat 4 diff old_objects: 42
GC.stat 5 diff old_objects: 42
GC.stat 6 diff old_objects: 42
GC.stat 7 diff old_objects: 42
GC.stat 8 diff old_objects: 42
GC.stat 9 diff old_objects: 42

And the strange “42” no longer appears in the latest version.

root@1294e0e49506:/ruby/tmp/master# git checkout origin/master && make -j miniruby >/dev/null 2>&1 && ./miniruby -v && ./miniruby ../a.rb|grep "diff old_object
s"
HEAD is now at 7282adc5a5f [DOC] Doc for File::unlink
ruby 4.1.0dev (2026-08-24T00:50:46Z :detached: 7282adc5a5) +PRISM [armv7l-linux-eabihf]
GC.stat 1 diff old_objects: 0
GC.stat 2 diff old_objects: 7061
GC.stat 3 diff old_objects: 45
GC.stat 4 diff old_objects: 1
GC.stat 5 diff old_objects: 0
GC.stat 6 diff old_objects: 0
GC.stat 7 diff old_objects: 0
GC.stat 8 diff old_objects: 0
GC.stat 9 diff old_objects: 0
Actions

Also available in: PDF Atom