Bug 770943

Summary: memory leaks on libvirt_virNodeGetCPUStats
Product: Red Hat Enterprise Linux 6 Reporter: Alex Jia <ajia>
Component: libvirtAssignee: Michal Privoznik <mprivozn>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: high Docs Contact:
Priority: high    
Version: 6.3CC: acathrow, dallan, dyuan, gsun, jdenemar, jgalipea, mzhan, rwu
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: libvirt-0.9.10-7.el6 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-06-20 06:40:44 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-30 11:46:50 UTC
Description of problem:
Memory leak on libvirt_virNodeGetCPUStats API.

Version-Release number of selected component (if applicable):
libvirt-python-0.9.9-0rc1.el6.x86_64.rpm

How reproducible:
always

Steps to Reproduce:
1. Paste the following codes into test.py:

import libvirt
con = libvirt.open(None)
dom = con.lookupByName('foo')
con.getCPUStats(0, 0)

2. valgrind -v --leak-check=full python test.py
  
Actual results:

==15786== 160 bytes in 4 blocks are definitely lost in loss record 1,525 of 2,083
==15786==    at 0x4A05FDE: malloc (vg_replace_malloc.c:236)
==15786==    by 0x39E1A85EC3: PyObject_Malloc (obmalloc.c:935)
==15786==    by 0x39E1A77831: _PyLong_New (longobject.c:75)
==15786==    by 0x39E1A79E2E: PyLong_FromUnsignedLongLong (longobject.c:892)
==15786==    by 0xB8FC2B4: libvirt_virNodeGetCPUStats (libvirt-override.c:2323)
==15786==    by 0x39E1ADE7F3: PyEval_EvalFrameEx (ceval.c:3794)
==15786==    by 0x39E1ADF99E: PyEval_EvalFrameEx (ceval.c:3880)
==15786==    by 0x39E1AE0466: PyEval_EvalCodeEx (ceval.c:3044)
==15786==    by 0x39E1AE0541: PyEval_EvalCode (ceval.c:545)
==15786==    by 0x39E1AFB88B: run_mod (pythonrun.c:1351)
==15786==    by 0x39E1AFB95F: PyRun_FileExFlags (pythonrun.c:1337)
==15786==    by 0x39E1AFCE4B: PyRun_SimpleFileExFlags (pythonrun.c:941)
==15786==
==15786== 180 bytes in 4 blocks are definitely lost in loss record 1,536 of 2,083
==15786==    at 0x4A05FDE: malloc (vg_replace_malloc.c:236)
==15786==    by 0x39E1A85EC3: PyObject_Malloc (obmalloc.c:935)
==15786==    by 0x39E1A9053C: PyString_FromString (stringobject.c:138)
==15786==    by 0xB8FC2C3: libvirt_virNodeGetCPUStats (libvirt-override.c:2323)
==15786==    by 0x39E1ADE7F3: PyEval_EvalFrameEx (ceval.c:3794)
==15786==    by 0x39E1ADF99E: PyEval_EvalFrameEx (ceval.c:3880)
==15786==    by 0x39E1AE0466: PyEval_EvalCodeEx (ceval.c:3044)
==15786==    by 0x39E1AE0541: PyEval_EvalCode (ceval.c:545)
==15786==    by 0x39E1AFB88B: run_mod (pythonrun.c:1351)
==15786==    by 0x39E1AFB95F: PyRun_FileExFlags (pythonrun.c:1337)
==15786==    by 0x39E1AFCE4B: PyRun_SimpleFileExFlags (pythonrun.c:941)
==15786==    by 0x39E1B094CE: Py_Main (main.c:577)

Expected results:
Fix memory leaks.

Additional info:

Comment 1 Alex Jia 2012-02-17 10:00:43 UTC
The Patch has been sent to upstream and wait for review:
https://www.redhat.com/archives/libvir-list/2012-February/msg00764.html

Comment 2 Alex Jia 2012-03-22 02:26:52 UTC
Moving to POST:
http://www.redhat.com/archives/libvir-list/2012-March/msg00895.html

Comment 3 Michal Privoznik 2012-03-22 08:55:03 UTC
In fact, now we can move to POST:

http://post-office.corp.redhat.com/archives/rhvirt-patches/2012-March/msg02003.html

Comment 5 Wayne Sun 2012-03-28 05:46:13 UTC
packages:
libvirt-0.9.10-8.el6.x86_64
qemu-kvm-0.12.1.2-2.265.el6rhev.x86_64
kernel-2.6.32-252.el6.x86_64
libvirt-python-0.9.10-8.el6.x86_64


Follow the steps in description.
result:
==8464== LEAK SUMMARY:
==8464==    definitely lost: 0 bytes in 0 blocks
==8464==    indirectly lost: 0 bytes in 0 blocks
==8464==      possibly lost: 6,152 bytes in 13 blocks
==8464==    still reachable: 1,243,298 bytes in 10,245 blocks
==8464==         suppressed: 0 bytes in 0 blocks

So, this is fixed now.

Comment 7 errata-xmlrpc 2012-06-20 06:40:44 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