Bug 761402

Summary: memory leak on cmdDomblklist function
Product: Red Hat Enterprise Linux 6 Reporter: Alex Jia <ajia>
Component: libvirtAssignee: Alex Jia <ajia>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: high Docs Contact:
Priority: high    
Version: 6.3CC: acathrow, dallan, dyuan, mshao, mzhan, rwu, veillard, zhpeng
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: libvirt-0.9.9-1.el6 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-06-20 06:38:19 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Alex Jia 2011-12-08 09:11:20 UTC
Description of problem:
Plug memory leak on cmdDomblklist function.

Version-Release number of selected component (if applicable):
libvirt-0.9.8-0rc2.el6.x86_64

How reproducible:
always

Steps to Reproduce:
1. valgrind -v --leak-check=full virsh domblklist <guest name>
  
Actual results:

==6573== 1,836 bytes in 1 blocks are definitely lost in loss record 110 of 124
==6573==    at 0x4A05FDE: malloc (vg_replace_malloc.c:236)
==6573==    by 0x330D71497D: xdr_string (in /lib64/libc-2.12.so)
==6573==    by 0x4D26CED: xdr_remote_nonnull_string (remote_protocol.c:30)
==6573==    by 0x4D28138: xdr_remote_domain_get_xml_desc_ret (remote_protocol.c:1418)
==6573==    by 0x4D3C0C2: virNetMessageDecodePayload (virnetmessage.c:382)
==6573==    by 0x4D3279F: virNetClientProgramCall (virnetclientprogram.c:382)
==6573==    by 0x4D0D50B: callWithFD (remote_driver.c:4339)
==6573==    by 0x4D0D5AB: call (remote_driver.c:4360)
==6573==    by 0x4D16EAF: remoteDomainGetXMLDesc (remote_client_bodies.h:861)
==6573==    by 0x4CF9F4F: virDomainGetXMLDesc (libvirt.c:4098)
==6573==    by 0x4154D9: cmdDomblklist (virsh.c:1722)
==6573==    by 0x4149E2: vshCommandRun (virsh.c:16365)
==6573== 
==6573== 46,009 (352 direct, 45,657 indirect) bytes in 1 blocks are definitely lost in loss record 123 of 124
==6573==    at 0x4A05FDE: malloc (vg_replace_malloc.c:236)
==6573==    by 0x3318286DC6: xmlXPathNewContext (in /usr/lib64/libxml2.so.2.7.6)
==6573==    by 0x4C79AE2: virXMLParseHelper (xml.c:779)
==6573==    by 0x415512: cmdDomblklist (virsh.c:1726)
==6573==    by 0x4149E2: vshCommandRun (virsh.c:16365)
==6573==    by 0x427743: main (virsh.c:17867)
==6573== 
==6573== LEAK SUMMARY:
==6573==    definitely lost: 2,188 bytes in 2 blocks
==6573==    indirectly lost: 45,657 bytes in 332 blocks
==6573==      possibly lost: 0 bytes in 0 blocks
==6573==    still reachable: 128,034 bytes in 1,364 blocks
==6573==         suppressed: 0 bytes in 0 blocks

Expected results:
avoid memory leak.

Additional info:

Comment 1 Alex Jia 2011-12-08 09:12:52 UTC
Patch for upstream:

https://www.redhat.com/archives/libvir-list/2011-December/msg00381.html

Comment 2 Alex Jia 2011-12-10 03:15:16 UTC
Patch has been ACKed and pushed on upstream.

commit 9707c2a8bc5ea8a2a80628e92dbdc6a85ea3e22e
Author: Alex Jia <ajia>
Date:   Thu Dec 8 17:11:26 2011 +0800

    virsh: plug memory leak on cmdDomblklist
    
    Detected by valgrind. Leak introduced in commit 88a993b:
    
    * tools/virsh.c: fix memory leak on cmdDomblklist.
    
    * how to reproduce?
      % valgrind -v --leak-check=full virsh domblklist <domain name>

Comment 3 zhpeng 2011-12-13 09:59:09 UTC
I can reproduce this with libvirt-0.9.8-1.el6.x86_64

Comment 5 xhu 2012-01-10 08:27:49 UTC
Reproduce it with libvirt-0.9.8-0rc2.el6.x86_64.
Verify it with libvirt-0.9.9-1.el6 and it passed.

Comment 7 errata-xmlrpc 2012-06-20 06:38:19 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

http://rhn.redhat.com/errata/RHSA-2012-0748.html