Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 725950

Summary: memory leak when run virsh vol-upload command
Product: Red Hat Enterprise Linux 6 Reporter: Alex Jia <ajia>
Component: libvirtAssignee: Osier Yang <jyang>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: medium Docs Contact:
Priority: medium    
Version: 6.2CC: berrange, dallan, dyuan, jyang, mzhan, rwu, yupzhang
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: libvirt-0.9.4-rc2-1.el6 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2011-12-06 11:18:00 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-07-27 06:26:33 UTC
Description of problem:
As summary, this bug is only used for tracing issue for libvirt-0.9.3-8.el6.x86_64, in fact, it's okay for libvirt upstream and libvirt-0.9.4-0rc1.el6.x86_64.

Version-Release number of selected component (if applicable):
# uname -r
2.6.32-160.el6.x86_64

# rpm -q libvirt
libvirt-0.9.3-8.el6.x86_64


How reproducible:
always

Steps to Reproduce:
1.virsh pool-list and make sure default pool is active
2.dd if=/dev/zero of=/var/lib/libvirt/images/foo.img count=1 bs=10M
3.virsh pool-refresh default
4.virsh vol-list --pool default
5.echo "test" > test.txt
6.ll -h test.txt  (get length of file test.txt)
7.valgrind -v --leak-check=full virsh vol-upload --vol foo.img --file test.txt --pool default --offset 0 --length 5
  
Actual results:
==2765== 262,216 bytes in 1 blocks are definitely lost in loss record 21 of 23
==2765==    at 0x4A04A28: calloc (vg_replace_malloc.c:467)
==2765==    by 0x4C72A4D: virAlloc (in /usr/lib64/libvirt.so.0.9.3)
==2765==    by 0x4D0EA22: ??? (in /usr/lib64/libvirt.so.0.9.3)
==2765==    by 0x4D0AFCF: ??? (in /usr/lib64/libvirt.so.0.9.3)
==2765==    by 0x4CF640A: ??? (in /usr/lib64/libvirt.so.0.9.3)
==2765==    by 0x4CC8B8B: virStreamSend (in /usr/lib64/libvirt.so.0.9.3)
==2765==    by 0x4CD4CF7: virStreamSendAll (in /usr/lib64/libvirt.so.0.9.3)
==2765==    by 0x4191AC: cmdVolUpload (virsh.c:8015)
==2765==    by 0x410CC2: vshCommandRun (virsh.c:12758)
==2765==    by 0x41F286: main (virsh.c:14110)
==2765==
==2765== 262,216 bytes in 1 blocks are definitely lost in loss record 22 of 23
==2765==    at 0x4A04A28: calloc (vg_replace_malloc.c:467)
==2765==    by 0x4C72A4D: virAlloc (in /usr/lib64/libvirt.so.0.9.3)
==2765==    by 0x4D0EA22: ??? (in /usr/lib64/libvirt.so.0.9.3)
==2765==    by 0x4D0AFCF: ??? (in /usr/lib64/libvirt.so.0.9.3)
==2765==    by 0x4CF6323: ??? (in /usr/lib64/libvirt.so.0.9.3)
==2765==    by 0x4CC85AE: virStreamFinish (in /usr/lib64/libvirt.so.0.9.3)
==2765==    by 0x4191D4: cmdVolUpload (virsh.c:8026)
==2765==    by 0x410CC2: vshCommandRun (virsh.c:12758)
==2765==    by 0x41F286: main (virsh.c:14110)
==2765==
==2765== LEAK SUMMARY:
==2765==    definitely lost: 524,432 bytes in 2 blocks
==2765==    indirectly lost: 0 bytes in 0 blocks
==2765==      possibly lost: 0 bytes in 0 blocks
==2765==    still reachable: 331,501 bytes in 61 blocks
==2765==         suppressed: 0 bytes in 0 blocks


Expected results:
Fix these 2 memory leak.

Additional info:
I haven't found which commit fix this issue.

Comment 1 Alex Jia 2011-07-27 06:28:58 UTC
Osier, if you know which commit fixes this issue, please paste it in here.

Thanks,
Alex

Comment 2 Alex Jia 2011-07-27 06:40:12 UTC
(In reply to comment #0)

> Actual results:
> ==2765== 262,216 bytes in 1 blocks are definitely lost in loss record 21 of 23
> ==2765==    at 0x4A04A28: calloc (vg_replace_malloc.c:467)
> ==2765==    by 0x4C72A4D: virAlloc (in /usr/lib64/libvirt.so.0.9.3)
> ==2765==    by 0x4D0EA22: ??? (in /usr/lib64/libvirt.so.0.9.3)
> ==2765==    by 0x4D0AFCF: ??? (in /usr/lib64/libvirt.so.0.9.3)


Update actual results with debuginfo package:
==18995== 262,216 bytes in 1 blocks are definitely lost in loss record 21 of 23
==18995==    at 0x4A04A28: calloc (vg_replace_malloc.c:467)
==18995==    by 0x3DF8C43A4D: virAlloc (memory.c:101)
==18995==    by 0x3DF8CDFA42: virNetMessageNew (virnetmessage.c:39)
==18995==    by 0x3DF8CDBFCF: virNetClientStreamSendPacket
(virnetclientstream.c:331)
==18995==    by 0x3DF8CC740A: remoteStreamSend (remote_driver.c:3207)
==18995==    by 0x3DF8C99B8B: virStreamSend (libvirt.c:12966)
==18995==    by 0x3DF8CA5CF7: virStreamSendAll (libvirt.c:13166)
==18995==    by 0x4191AC: cmdVolUpload (virsh.c:8015)
==18995==    by 0x410CC2: vshCommandRun (virsh.c:12758)
==18995==    by 0x41F286: main (virsh.c:14110)
==18995== 
==18995== 262,216 bytes in 1 blocks are definitely lost in loss record 22 of 23
==18995==    at 0x4A04A28: calloc (vg_replace_malloc.c:467)
==18995==    by 0x3DF8C43A4D: virAlloc (memory.c:101)
==18995==    by 0x3DF8CDFA42: virNetMessageNew (virnetmessage.c:39)
==18995==    by 0x3DF8CDBFCF: virNetClientStreamSendPacket
(virnetclientstream.c:331)
==18995==    by 0x3DF8CC7323: remoteStreamFinish (remote_driver.c:3362)
==18995==    by 0x3DF8C995AE: virStreamFinish (libvirt.c:13442)
==18995==    by 0x4191D4: cmdVolUpload (virsh.c:8026)
==18995==    by 0x410CC2: vshCommandRun (virsh.c:12758)
==18995==    by 0x41F286: main (virsh.c:14110)
==18995== 
==18995== LEAK SUMMARY:
==18995==    definitely lost: 524,432 bytes in 2 blocks
==18995==    indirectly lost: 0 bytes in 0 blocks
==18995==      possibly lost: 0 bytes in 0 blocks
==18995==    still reachable: 331,494 bytes in 61 blocks
==18995==         suppressed: 0 bytes in 0 blocks

Comment 3 Daniel Berrangé 2011-07-27 07:33:34 UTC
Fixed in

commit 927dfcf693165f5b08efba0d031d4cc43e6f9c37
Author: Daniel P. Berrange <berrange>
Date:   Fri Jul 8 12:35:36 2011 +0100

    Fix leak of 'msg' object in client stream code
    
    In one exit path we forgot to free the virNetMessage object causing
    a large memory leak for streams which send a lot of data. Some other
    paths were calling VIR_FREE directly instead of virNetMessageFree
    although this was (currently) harmless.
    
    * src/rpc/virnetclientstream.c: Fix leak of msg object
    * src/rpc/virnetclientprogram.c: Call virNetMessageFree instead
      of VIR_FREE

Comment 5 Alex Jia 2011-08-01 02:34:50 UTC
This issue has been fixed on rhel6.2(2.6.32-160.el6.x86_64) with libvirt-0.9.4-0rc2.el6.x86_64 and qemu-kvm-0.12.1.2-2.169.el6.x86_64, the following is actual test result by valgrind, so change the bug status to VERIFIED.


Actual result:

Detected in valgrind run:

==1643== 
==1643== HEAP SUMMARY:
==1643==     in use at exit: 331,494 bytes in 61 blocks
==1643==   total heap usage: 1,150 allocs, 1,089 frees, 2,956,048 bytes allocated
==1643== 
==1643== Searching for pointers to 61 not-freed blocks
==1643== Checked 1,518,744 bytes
==1643== 
==1643== LEAK SUMMARY:
==1643==    definitely lost: 0 bytes in 0 blocks
==1643==    indirectly lost: 0 bytes in 0 blocks
==1643==      possibly lost: 0 bytes in 0 blocks
==1643==    still reachable: 331,494 bytes in 61 blocks

Comment 6 errata-xmlrpc 2011-12-06 11:18:00 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/RHBA-2011-1513.html