After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 554545 - gst.Pad methods that return a new buffer as function argument leaks it
gst.Pad methods that return a new buffer as function argument leaks it
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-python
git master
Other All
: Normal normal
: 0.10.14
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2008-10-01 10:14 UTC by Stefan Wehner
Modified: 2008-12-06 15:52 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Testcase (2.88 KB, text/plain)
2008-10-01 10:25 UTC, Stefan Wehner
Details
Incomplete debug output (11.16 KB, text/plain)
2008-10-01 10:27 UTC, Stefan Wehner
Details

Description Stefan Wehner 2008-10-01 10:14:44 UTC
Please describe the problem:
It looks like when using a python element driving the pipeline in pull-mode the call to sinkpad.pull_range(..) leaks memory (all buffers are leaked).



Steps to reproduce:
The setup is as follows:

fakesrc | puller | fakesink

The puller element is written in Python (I'll attach code).

This only happens when the puller element calls pull_range() - python sources with a pulling fakesink work correctly and pullers that don't call pull_range() (but instanaiate buffers themselves) work perfectly, too.

Actual results:
When executing with GST_DEBUG=5 one can that the buffers don't get unreffed enough and don't get freed, thus leaking a lot of memory.


Expected results:


Does this happen every time?
Yes

Other information:
Comment 1 Stefan Wehner 2008-10-01 10:25:10 UTC
Created attachment 119716 [details]
Testcase

Test case
Comment 2 Stefan Wehner 2008-10-01 10:27:41 UTC
Created attachment 119717 [details]
Incomplete debug output

A snippet from the debug output
Comment 3 Stefan Wehner 2008-10-01 10:33:07 UTC
I have also observed that the python Pullsource with a pulling fakesink also leaks memeory when allocating the buffer via pad.alloc_buffer_and_set_caps(...) (see code)
Comment 4 Stefan Wehner 2008-10-01 10:51:58 UTC
We've observed that when creating events, after creating the pygstminiobject_new, the original object is unreffed.
Shouldn't this be also done in the functions in gstpad.override - like this:
%%
override gst_pad_pull_range kwargs
static PyObject *
_wrap_gst_pad_pull_range (PyGObject *self, PyObject * args, PyObject *kwargs)
{
    static char *kwlist[] = {"offset", "size", NULL};
    guint64    offset;
    gint    size;
    PyObject    *ret;
    GstBuffer    *buf;
    GstFlowReturn    res;

    if (!PyArg_ParseTupleAndKeywords(args, kwargs,
                     "Ki:GstPad.pull_range",
                     kwlist, &offset, &size))
    return NULL;
    res = gst_pad_pull_range (GST_PAD(pygobject_get(self)),
                  offset, size, &buf);
    ret = PyList_New(2);
    PyList_SetItem(ret, 0, pyg_enum_from_gtype(GST_TYPE_FLOW_RETURN, res));
    if (res != GST_FLOW_OK) {
        PyList_SetItem(ret, 1, Py_None);
    } else {
        PyList_SetItem(ret, 1, pygstminiobject_new(GST_MINI_OBJECT(buf)));


        //unreffing original object like it is
        //done e.g. in _wrap_gst_event_new_custom
	gst_mini_object_unref(GST_MINI_OBJECT(buf));
    }
    return ret;
}


When we unref this object, the memory leaks disappear.
%%
Comment 5 Edward Hervey 2008-12-06 15:50:48 UTC
confirmed, and we also have the same issue with the other gst_pad_get_range/gst_pad_alloc_buffer/... overrides that return a newly created buffer as a function argument.
Comment 6 Edward Hervey 2008-12-06 15:52:46 UTC
2008-12-06  Edward Hervey  <edward.hervey@collabora.co.uk>

	* gst/gstpad.override:
	Fix memory leak for functions that return a newly created buffer as
	a function argument.
	Fixes #554545