[libvirt] [ libvirt-python BUG ?] Memory leak in libvirt_virConnectDomainEventJobCompletedCallback
Michal Privoznik
mprivozn at redhat.com
Fri Jan 20 13:07:24 UTC 2017
On 01/18/2017 08:51 AM, Hailiang Zhang wrote:
> Hi all,
>
> It seems that, there is a memory leak bug in
> libvirt_virConnectDomainEventJobCompletedCallback()
> function of libvirt-override.c.
>
> We didn't decrease the reference of 'pyobj_dict' in this function or any
> other places
> while pyt0bj_ret is not zero.
>
> libvirt_virConnectDomainEventJobCompletedCallback()
> {
> ... ...
>
> pyobj_ret = PyObject_CallMethod(pyobj_conn,
>
> (char*)"_dispatchDomainEventJobCompletedCallback",
> (char*)"OOO",
> pyobj_dom, pyobj_dict, pyobj_cbData);
>
> Py_DECREF(pyobj_cbData);
> Py_DECREF(pyobj_dom);
>
> cleanup:
> if (!pyobj_ret) {
> DEBUG("%s - ret:%p\n", __FUNCTION__, pyobj_ret);
> PyErr_Print();
> Py_XDECREF(pyobj_dict);
> } else {
> Py_DECREF(pyobj_ret);
> ret = 0;
> }
>
> LIBVIRT_RELEASE_THREAD_STATE;
> return ret;
> }
>
> I don't think the reference of pyobj_dict will be stolen by
> PyObject_CallMethod
> when it is passed to the Python function
> _dispatchDomainEventJobCompletedCallback.
>
> In fact, we have a test which triggered lots of events and found that
> the memory
> of the test process will keep raising slowly and could not be reclaimed
> even we called gc.collect() explicitly in our codes.
>
> So, is it a bug ? Any comments ?
Yes. we need to decrement the reference counter. Wanna propose the patch
and have the first contribution to libvirt-python? :-)
Michal
More information about the libvir-list
mailing list