Red Hat Bugzilla – Bug 761453
memory leak on remoteDomainScreenshot function
Last modified: 2012-06-20 02:38:22 EDT
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.
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.
I can reproduce this with libvirt-0.9.8-1.el6.x86_64
Reproduce it with libvirt-0.9.8-0rc2.el6.x86_64. Verify it with libvirt-0.9.9-1.el6 and it passed.
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