Prior to this update, the libvirtd daemon leaked memory in the virCgroupMoveTask() function. A fix has been provided which prevents libvirtd from incorrect management of memory allocations.
Description of problem:
libvirtd leaks memory in virCgroupMoveTask
Version-Release number of selected component (if applicable):
Steps to Reproduce:
1. run libvirtd under valgrind:
valgrind --leak-check=full libvirtd
2. create a domain:
virsh create /dev/stdin <<EOF
<type arch='x86_64' machine='pc'>hvm</type>
Domain duck created from /dev/stdin
Valgrind shows a memory leak:
==4945== 16,386 bytes in 2 blocks are definitely lost in loss record 715 of 722
==4945== at 0x4A069EE: malloc (vg_replace_malloc.c:270)
==4945== by 0x4A06B62: realloc (vg_replace_malloc.c:662)
==4945== by 0x4E787CB: virReallocN (memory.c:160)
==4945== by 0x4E87A89: virFileReadLimFD (util.c:400)
==4945== by 0x4E87BF7: virFileReadAll (util.c:461)
==4945== by 0x4E6D140: virCgroupGetValueStr (cgroup.c:363)
==4945== by 0x4E6DD7D: virCgroupMoveTask (cgroup.c:897)
==4945== by 0x471328: qemuSetupCgroupForEmulator (qemu_cgroup.c:695)
==4945== by 0x48648E: qemuProcessStart (qemu_process.c:3965)
==4945== by 0x461678: qemudDomainCreate (qemu_driver.c:1595)
==4945== by 0x4F0A580: virDomainCreateXML (libvirt.c:1954)
==4945== by 0x43FBD0: remoteDispatchDomainCreateXMLHelper (remote_dispatch.h:1172)
libvirtd frees the memory.
Author: Ján Tomko <email@example.com>
AuthorDate: 2013-06-26 14:55:27 +0200
Commit: Ján Tomko <firstname.lastname@example.org>
CommitDate: 2013-06-26 15:38:01 +0200
Plug leak in virCgroupMoveTask
We only break out of the while loop if *content is an empty string.
However the buffer has been allocated to BUFSIZ + 1 (8193 in my case),
but it gets overwritten in the next for iteration.
Move VIR_FREE right before we overwrite it to avoid the leak.
==5777== 16,386 bytes in 2 blocks are definitely lost in loss record 1,022 of 1,027
==5777== by 0x5296E28: virReallocN (viralloc.c:184)
==5777== by 0x52B0C66: virFileReadLimFD (virfile.c:1137)
==5777== by 0x52B0E1A: virFileReadAll (virfile.c:1199)
==5777== by 0x529B092: virCgroupGetValueStr (vircgroup.c:534)
==5777== by 0x529AF64: virCgroupMoveTask (vircgroup.c:1079)
Introduced by 83e4c77.
git describe: v1.1.0-rc1-26-g5bc8ecb
Downstream patch posted too:
Created attachment 773495 [details]
(In reply to zhpeng from comment #9)
None of the leaks in there seem important to me.
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.