[libvirt] libvirt-python: memory leak after GetXMLDesc?

Michal Privoznik mprivozn at redhat.com
Fri Sep 12 07:44:44 UTC 2014


On 12.09.2014 08:56, Junichi Nomura wrote:
> Hello,
>
> I've observed memory leak in long-running python program and
> suspects a bug in libvirt-python.
>
> libvirt-python contains auto-generated code like this:
>
>    libvirt_virDomainGetXMLDesc(...) {
>      ...
>      LIBVIRT_BEGIN_ALLOW_THREADS;
>      c_retval = virDomainGetXMLDesc(domain, flags);
>      LIBVIRT_END_ALLOW_THREADS;
>      py_retval = libvirt_charPtrWrap((char *) c_retval);
>      return py_retval;
>    }
>
> virDomainGetXMLDesc() expects the caller to free c_retval.
>
> Though it used to be freed in libvirt_charPtrWrap(), commit bb3301ba
> ("Don't free passed in args in libvirt_charPtrWrap /
> libvirt_charPtrSizeWrap") has moved the responsibility to the outside.
>
> So, it seems either GetXMLDesc should not depend on auto-generation or
> the generator should be fixed.
>
> Any comments?
>

Yes, this is a libvirt-python bug. And it's there since 1.2.1! We need 
to fix our generator. Patch on way.

Michal




More information about the libvir-list mailing list