Bug 738948

Summary: Memory leak on virDomainDefParseXML
Product: Red Hat Enterprise Linux 6 Reporter: Alex Jia <ajia>
Component: libvirtAssignee: Libvirt Maintainers <libvirt-maint>
Status: CLOSED UPSTREAM QA Contact: Virtualization Bugs <virt-bugs>
Severity: medium Docs Contact:
Priority: high    
Version: 6.2CC: acathrow, dyuan, eblake, mzhan, rwu
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2011-09-16 14:15:34 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description Alex Jia 2011-09-16 05:52:59 UTC
Description of problem:
Allocate memory to def->redirdevs in virDomainDefParseXML function such as VIR_ALLOC_N(def->redirdevs, n), however, virDomainDefFree(def) function hasn't released these memory.

Version-Release number of selected component (if applicable):
Libvirt upstream.

How reproducible:
Always.

Steps to Reproduce:
1. ./configure && make && make check all
2. valgrind -v --leak-check=full ./tests/qemuxml2xmltest
  
Actual results:

Detected in valgrind run:

==19820== 209 (16 direct, 193 indirect) bytes in 1 blocks are definitely lost in loss record 25 of 26
==19820==    at 0x4A04A28: calloc (vg_replace_malloc.c:467)
==19820==    by 0x4A13AF: virAllocN (memory.c:129)
==19820==    by 0x4D4A0E: virDomainDefParseXML (domain_conf.c:7258)
==19820==    by 0x4D4C93: virDomainDefParseNode (domain_conf.c:7512)
==19820==    by 0x4D562F: virDomainDefParse (domain_conf.c:7465)
==19820==    by 0x415863: testCompareXMLToXMLFiles (qemuxml2xmltest.c:35)
==19820==    by 0x415982: testCompareXMLToXMLHelper (qemuxml2xmltest.c:80)
==19820==    by 0x416D31: virtTestRun (testutils.c:140)
==19820==    by 0x415604: mymain (qemuxml2xmltest.c:192)
==19820==    by 0x416437: virtTestMain (testutils.c:689)
==19820==    by 0x3CA7A1ECDC: (below main) (in /lib64/libc-2.12.so)
==19820==
==19820== LEAK SUMMARY:
==19820==    definitely lost: 16 bytes in 1 blocks
==19820==    indirectly lost: 193 bytes in 5 blocks
==19820==      possibly lost: 0 bytes in 0 blocks
==19820==    still reachable: 1,054 bytes in 21 blocks


Expected results:
Avoid memory leak.

Additional info:

Comment 1 Alex Jia 2011-09-16 05:54:59 UTC
Patch for upstream:
http://www.redhat.com/archives/libvir-list/2011-September/msg00625.html

Alex

Comment 2 Eric Blake 2011-09-16 14:15:34 UTC
This leak is not present in RHEL 6.2, since we did not backport redirdevs there.  RHEL 6.3 will rebase, and pick up the upstream patch; so I'm closing this now.