Bug 761345

Summary: memory leak on cmdDomIfGetLink sucessful path
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, 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:13 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 06:09:16 UTC
Description of problem:
Plug memory leak on cmdDomIfGetLink() sucessful path.

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 domif-getlink <domain name> <invalid mac>

Note: for instance, give a invalid mac address '0' and guest name 'demo', then
run 'valgrind -v --leak-check=full virsh domif-getlink demo 0'.
  
Actual results:

==13102== 18 bytes in 1 blocks are definitely lost in loss record 9 of 47
==13102==    at 0x4A05FDE: malloc (vg_replace_malloc.c:236)
==13102==    by 0x322A6A67DD: xmlStrndup (in /usr/lib64/libxml2.so.2.7.6)
==13102==    by 0x414892: cmdDomIfGetLink (virsh.c:1538)
==13102==    by 0x4136A2: vshCommandRun (virsh.c:16363)
==13102==    by 0x4253FB: main (virsh.c:17865)
==13102==
==13102== LEAK SUMMARY:
==13102==    definitely lost: 18 bytes in 1 blocks
==13102==    indirectly lost: 0 bytes in 0 blocks
==13102==      possibly lost: 0 bytes in 0 blocks
==13102==    still reachable: 127,888 bytes in 1,361 blocks
==13102==         suppressed: 0 bytes in 0 blocks


Expected results:
avoid memory leak.

Additional info:

Comment 1 Alex Jia 2011-12-08 06:12:51 UTC
Patch for upstream:

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

Comment 2 Alex Jia 2011-12-09 02:27:18 UTC
Patch has been ACKed and pushed on upstream, but need a devel_ack+.

commit f582199e60cb090c1267aa310d361a22ab8e6484
Author: Alex Jia <ajia>
Date:   Thu Dec 8 14:09:57 2011 +0800

    virsh: plug memory leak on cmdDomIfGetLink() sucessful path
    
    Detected by valgrind. Leak introduced in commit dc675f3:
    
    * tools/virsh.c: fix memory leak on cmdDomIfGetLink.
    
    * how to reproduce?
      % valgrind -v --leak-check=full virsh domif-getlink <domain name> 0
    
    * actual valgrind result:
    
    ==13102== 18 bytes in 1 blocks are definitely lost in loss record 9 of 47
    ==13102==    at 0x4A05FDE: malloc (vg_replace_malloc.c:236)
    ==13102==    by 0x322A6A67DD: xmlStrndup (in /usr/lib64/libxml2.so.2.7.6)
    ==13102==    by 0x414892: cmdDomIfGetLink (virsh.c:1538)
    ==13102==    by 0x4136A2: vshCommandRun (virsh.c:16363)
    ==13102==    by 0x4253FB: main (virsh.c:17865)
    ==13102==
    ==13102== LEAK SUMMARY:
    ==13102==    definitely lost: 18 bytes in 1 blocks
    ==13102==    indirectly lost: 0 bytes in 0 blocks
    ==13102==      possibly lost: 0 bytes in 0 blocks
    ==13102==    still reachable: 127,888 bytes in 1,361 blocks
    ==13102==         suppressed: 0 bytes in 0 blocks

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

Comment 5 xhu 2012-01-10 08:17:56 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:13 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