Comment 4 for bug 1844455

Revision history for this message
Guilherme G. Piccoli (gpiccoli) wrote : Re: Memory leak on libvirt 1.3.1

Leak #3
968 bytes in 1 blocks are definitely lost in loss record 1,313 of 1,405
at 0x4C2AB80: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
by 0x6D4BA21: xmlGetGlobalState (in /usr/lib/x86_64-linux-gnu/libxml2.so.2.9.3)
by 0x6D4B214: __xmlIndentTreeOutput (in /usr/lib/x86_64-linux-gnu/libxml2.so.2.9.3)
by 0x5149F7D: virDomainDefFormatInternal (domain_conf.c:21655)
by 0x514D0F2: virDomainDefFormat (domain_conf.c:22517)
by 0x515B93B: virDomainDefCopy (domain_conf.c:23041)
by 0x515B9FF: virDomainObjSetDefTransient (domain_conf.c:2818)
by 0x2B70CCD9: qemuProcessInit (qemu_process.c:4483)
by 0x2B70CFEE: qemuProcessStart (qemu_process.c:5150)
by 0x2B76D727: qemuDomainObjStart.constprop.47 (qemu_driver.c:7396)
by 0x2B76DE65: qemuDomainCreateWithFlags (qemu_driver.c:7450)
by 0x51CC7FB: virDomainCreate (libvirt-domain.c:6753)

I've checked the code in libxml2, and what is leaking is the struct _xmlGlobalState,
in function xmlNewGlobalState(), called from xmlGetGlobalState() - this is part
of thread orchestration mechanism in libxml. Using pahole I could check the struct
size, and it matches:

$ pahole --hex -C _xmlGlobalState <libxml_dbg_file> | grep size
/* size: 968, cachelines: 16, members: 33 */

The struct is freed in xmlFreeGlobalState(), when thread exits. This is again a case
when there's a cleanup routine that seems to be skipped; we need to understand really
if the process is being killed without having chance to run these cleanups.

I'm preparing a test package to validate the cleanups execution.