Bugzilla will be upgraded to version 5.0. The upgrade date is tentatively scheduled for 2 December 2018, pending final testing and feedback.
Bug 761453 - memory leak on remoteDomainScreenshot function
memory leak on remoteDomainScreenshot function
Status: CLOSED ERRATA
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: libvirt (Show other bugs)
6.3
x86_64 Linux
high Severity high
: rc
: ---
Assigned To: Michal Privoznik
Virtualization Bugs
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2011-12-08 06:09 EST by Alex Jia
Modified: 2012-06-20 02:38 EDT (History)
7 users (show)

See Also:
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 02:38:22 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)


External Trackers
Tracker ID Priority Status Summary Last Updated
Red Hat Product Errata RHSA-2012:0748 normal SHIPPED_LIVE Low: libvirt security, bug fix, and enhancement update 2012-06-19 15:31:38 EDT

  None (edit)
Description Alex Jia 2011-12-08 06:09:33 EST
Description of problem:
Plug memory leak on remoteDomainScreenshot function.

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

How reproducible:
always

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

==17665== 24 bytes in 1 blocks are definitely lost in loss record 4 of 28
==17665==    at 0x4A05FDE: malloc (vg_replace_malloc.c:236)
==17665==    by 0x321FB1497D: xdr_string (in /lib64/libc-2.12.so)
==17665==    by 0x3238AFA2AD: xdr_remote_nonnull_string (remote_protocol.c:30)
==17665==    by 0x321FB15F4F: xdr_reference (in /lib64/libc-2.12.so)
==17665==    by 0x321FB15F10: xdr_pointer (in /lib64/libc-2.12.so)
==17665==    by 0x3238AF9E04: xdr_remote_string (remote_protocol.c:39)
==17665==    by 0x3238AFA068: xdr_remote_domain_screenshot_ret (remote_protocol.c:1398)
==17665==    by 0x3238B09EB2: virNetMessageDecodePayload (virnetmessage.c:382)
==17665==    by 0x3238B023FC: virNetClientProgramCall (virnetclientprogram.c:382)
==17665==    by 0x3238AE34BD: callWithFD (remote_driver.c:4333)
==17665==    by 0x3238AE353B: call (remote_driver.c:4354)
==17665==    by 0x3238AF5410: remoteDomainScreenshot (remote_client_bodies.h:1839)
==17665==
==17665== LEAK SUMMARY:
==17665==    definitely lost: 24 bytes in 1 blocks
==17665==    indirectly lost: 0 bytes in 0 blocks
==17665==      possibly lost: 0 bytes in 0 blocks
==17665==    still reachable: 126,936 bytes in 1,340 blocks

Expected results:
avoid memory leak.

Additional info:

Should add 'xdr_free((xdrproc_t)xdr_remote_domain_screenshot_ret, (char *)&ret)' to free allocated memory, it needs to change src/rpc/gendispatch.pl,
I'm not familiar with this.
Comment 1 Michal Privoznik 2011-12-12 10:56:37 EST
Actually, as we want to keep return value of call(remote_driver.c:4354) and pass it to caller, we don't want to free it completely.

Moreover, the documentation to virDomainScreenshot() says, caller MUST free return value (=mime type of screenshot). And virsh was not doing that. However, was fixed:

commit 0fe2b40d5a1858f7eb0d42f46393e566b6d60812
Author:     Michal Privoznik <mprivozn@redhat.com>
AuthorDate: Mon Dec 12 15:57:28 2011 +0100
Commit:     Michal Privoznik <mprivozn@redhat.com>
CommitDate: Mon Dec 12 15:57:28 2011 +0100

    virsh: Free returned MIME type string
    
    In terms of documentation to virDomainScreenshot, caller MUST free
    returned value. But virsh was not.


Therefore moving to POST.
Comment 3 zhpeng 2011-12-13 05:11:01 EST
I can reproduce this with libvirt-0.9.8-1.el6.x86_64
Comment 5 xhu 2012-01-10 03:25:54 EST
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 02:38:22 EDT
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

Note You need to log in before you can comment on or make changes to this bug.