X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Ftests%2Fleak_finder.pl;h=45d221161bf18ac6f59863095477a28ff1b37eb5;hb=5c2e140ae225bdfcff679c95af00d3a98116df74;hp=fbf1d00a1d198eed8fc271522bf1f34e07ec7ed9;hpb=4b28597565a5e732e1bb2b6aecf25e71bfeacccc;p=fs%2Flustre-release.git diff --git a/lustre/tests/leak_finder.pl b/lustre/tests/leak_finder.pl index fbf1d00..45d2211 100644 --- a/lustre/tests/leak_finder.pl +++ b/lustre/tests/leak_finder.pl @@ -8,30 +8,50 @@ STDERR->autoflush(1); my ($line, $memory); my $debug_line = 0; +my $total = 0; +my $max = 0; + while ($line = <>) { $debug_line++; my ($file, $func, $lno, $name, $size, $addr, $type); - if ($line =~ m/^.*\((.*):(\d+):(.*)\(\) (\d+ \| )?\d+\+\d+\): [vk](.*) '(.*)': (\d+) at (.*) \(tot .*$/) { - $file = $1; - $lno = $2; - $func = $3; - $type = $5; - $name = $6; - $size = $7; - $addr = $8; + if ($line =~ m/^.*(\.).*\((.*):(\d+):(.*)\(\)\) (k|v|slab-)(.*) '(.*)': (\d+) at ([\da-f]+)/){ + $file = $2; + $lno = $3; + $func = $4; + $type = $6; + $name = $7; + $size = $8; + $addr = $9; + + # we can't dump the log after portals has exited, so skip "leaks" + # from memory freed in the portals module unloading. + if ($func eq 'portals_handle_init') { + next; + } printf("%8s %6d bytes at %s called %s (%s:%s:%d)\n", $type, $size, $addr, $name, $file, $func, $lno); } else { next; } - if ($type eq 'malloced') { + if (index($type, 'alloced') >= 0) { + if (defined($memory->{$addr})) { + print STDERR "*** Two allocs with the same address ($size bytes at $addr, $file:$func:$lno)\n"; + print STDERR " first malloc at $memory->{$addr}->{file}:$memory->{$addr}->{func}:$memory->{$addr}->{lno}, second at $file:$func:$lno\n"; + next; + } + $memory->{$addr}->{name} = $name; $memory->{$addr}->{size} = $size; $memory->{$addr}->{file} = $file; $memory->{$addr}->{func} = $func; $memory->{$addr}->{lno} = $lno; $memory->{$addr}->{debug_line} = $debug_line; + + $total += $size; + if ($total > $max) { + $max = $total; + } } else { if (!defined($memory->{$addr})) { print STDERR "*** Free without malloc ($size bytes at $addr, $file:$func:$lno)\n"; @@ -46,6 +66,7 @@ while ($line = <>) { } delete $memory->{$addr}; + $total -= $size; } } @@ -60,4 +81,4 @@ foreach $key (@sorted) { print STDERR "*** Leak: $memory->{$key}->{size} bytes allocated at $key ($memory->{$key}->{file}:$memory->{$key}->{func}:$memory->{$key}->{lno}, debug file line $memory->{$key}->{debug_line})\n"; } -print "Done.\n"; +print STDERR "maximum used: $max, amount leaked: $total\n";