aboutsummaryrefslogtreecommitdiffstats
path: root/tool/lib/leakchecker.rb
diff options
context:
space:
mode:
authorYusuke Endoh <mame@ruby-lang.org>2019-11-12 01:30:42 +0900
committerYusuke Endoh <mame@ruby-lang.org>2019-11-12 01:47:18 +0900
commitc02de30efbca2a2d89cdf188a27991f7ae15b9da (patch)
tree66735080c3d7197339087a996867a2449b88322e /tool/lib/leakchecker.rb
parentb72eda3c59cd0a15ed3536a3c0cd8aebd225f16b (diff)
downloadruby-c02de30efbca2a2d89cdf188a27991f7ae15b9da.tar.gz
tool/lib/leakchecker.rb: show the code location that allocated leaked fd
by using ObjectSpace.trace_object_allocations. `make test-all LEAK_CHECKER_TRACE_OBJECT_ALLOCATION=true` will print not only leaked fds but also where it was created.
Diffstat (limited to 'tool/lib/leakchecker.rb')
-rw-r--r--tool/lib/leakchecker.rb5
1 files changed, 5 insertions, 0 deletions
diff --git a/tool/lib/leakchecker.rb b/tool/lib/leakchecker.rb
index af9200bf77..26ece9340f 100644
--- a/tool/lib/leakchecker.rb
+++ b/tool/lib/leakchecker.rb
@@ -75,9 +75,13 @@ class LeakChecker
}
fd_leaked.each {|fd|
str = ''.dup
+ pos = nil
if h[fd]
str << ' :'
h[fd].map {|io, autoclose, inspect|
+ if ENV["LEAK_CHECKER_TRACE_OBJECT_ALLOCATION"]
+ pos = "#{ObjectSpace.allocation_sourcefile(io)}:#{ObjectSpace.allocation_sourceline(io)}"
+ end
s = ' ' + inspect
s << "(not-autoclose)" if !autoclose
s
@@ -86,6 +90,7 @@ class LeakChecker
}
end
puts "Leaked file descriptor: #{test_name}: #{fd}#{str}"
+ puts " The IO was created at #{pos}" if pos
}
#system("lsof -p #$$") if !fd_leaked.empty?
h.each {|fd, list|