On Wed, Jan 30, 2008 at 04:07:32PM +0100, Jim Meyering wrote:
with more than 20 domains, I get this:
$ valgrind --leak-check=full ./virsh --connect test://$PWD/../docs/testnode.xml list
...
error: failed to connect to the hypervisor
...
==13756== 5 bytes in 1 blocks are definitely lost in loss record 1 of 32
==13756== at 0x4A059F6: malloc (vg_replace_malloc.c:149)
==13756== by 0x387BC7CC11: strdup (strdup.c:43)
==13756== by 0x41D9F2: virXPathString (xml.c:486)
==13756== by 0x4174D3: testLoadDomain (test.c:248)
==13756== by 0x417BA4: testLoadDomainFromFile (test.c:401)
==13756== by 0x418E57: testOpenFromFile (test.c:797)
==13756== by 0x4192CE: testOpen (test.c:913)
==13756== by 0x40FA20: do_open (libvirt.c:572)
==13756== by 0x40FDE4: virConnectOpenAuth (libvirt.c:681)
==13756== by 0x40D5B1: vshInit (virsh.c:4464)
==13756== by 0x40E67C: main (virsh.c:4985)
==13756==
==13756==
==13756== 12,996 (352 direct, 12,644 indirect) bytes in 1 blocks are definitely lost in
loss record 31 of 32
==13756== at 0x4A059F6: malloc (vg_replace_malloc.c:149)
==13756== by 0x38864880E6: xmlXPathNewContext (in /usr/lib64/libxml2.so.2.6.31)
==13756== by 0x417494: testLoadDomain (test.c:242)
==13756== by 0x417BA4: testLoadDomainFromFile (test.c:401)
==13756== by 0x418E57: testOpenFromFile (test.c:797)
==13756== by 0x4192CE: testOpen (test.c:913)
==13756== by 0x40FA20: do_open (libvirt.c:572)
==13756== by 0x40FDE4: virConnectOpenAuth (libvirt.c:681)
==13756== by 0x40D5B1: vshInit (virsh.c:4464)
==13756== by 0x40E67C: main (virsh.c:4985)
==13756==
==13756== LEAK SUMMARY:
==13756== definitely lost: 357 bytes in 2 blocks.
==13756== indirectly lost: 12,644 bytes in 32 blocks.
==13756== possibly lost: 0 bytes in 0 blocks.
==13756== still reachable: 20,614 bytes in 362 blocks.
==13756== suppressed: 0 bytes in 0 blocks.
==13756== Reachable blocks (those to which a pointer was found) are not shown.
==13756== To see them, rerun with: --leak-check=full --show-reachable
Here's the fix:
* test.c (testLoadDomain): Avoid leaks upon failure.
ACK, to this & the other free/leak patches you've posted this morning.
Dan.
--
|=- Red Hat, Engineering, Emerging Technologies, Boston. +1 978 392 2496 -=|
|=- Perl modules:
http://search.cpan.org/~danberr/ -=|
|=- Projects:
http://freshmeat.net/~danielpb/ -=|
|=- GnuPG: 7D3B9505 F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 -=|