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 760982 - adaptivedemux: memory leak of stream->internal_pad
adaptivedemux: memory leak of stream->internal_pad
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-bad
git master
Other All
: Normal normal
: 1.7.2
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2016-01-22 11:24 UTC by A Ashley
Modified: 2016-01-22 17:08 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
adaptivedemux: fix leak of stream->internal_pad (1.81 KB, patch)
2016-01-22 16:50 UTC, A Ashley
committed Details | Review

Description A Ashley 2016-01-22 11:24:59 UTC
The function gst_adaptive_demux_stream_update_source() function creates a new GstPad called internal_pad. This pad is not freed when releasing the stream.
You can reproduce this by running the dash_demux test under Valgrind.

==2414== 930 (528 direct, 402 indirect) bytes in 1 blocks are definitely lost in loss record 2,109 of 2,139
==2414==    at 0x5619493: g_type_create_instance (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.4600.1)
==2414==    by 0x55FB38A: ??? (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.4600.1)
==2414==    by 0x55FD224: g_object_new_valist (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.4600.1)
==2414==    by 0x55FD590: g_object_new (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.4600.1)
==2414==    by 0xA4F8E72: gst_adaptive_demux_stream_update_source (gstadaptivedemux.c:2292)
==2414==    by 0xA4F8E72: gst_adaptive_demux_stream_download_uri (gstadaptivedemux.c:2326)
==2414==    by 0xA4FA16E: gst_adaptive_demux_stream_download_header_fragment (gstadaptivedemux.c:2451)
==2414==    by 0xA4FA16E: gst_adaptive_demux_stream_download_fragment (gstadaptivedemux.c:2495)
==2414==    by 0xA4FA16E: gst_adaptive_demux_stream_download_loop (gstadaptivedemux.c:2738)
==2414==    by 0x535D550: gst_task_func (gsttask.c:331)
==2414==    by 0x58AA2FD: ??? (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4600.1)
==2414==    by 0x58A9964: ??? (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4600.1)
==2414==    by 0x5D5D6A9: start_thread (pthread_create.c:333)

This code was added in commit b7a0be23c6865286674ecac127bc4a1603437ee9
(https://bugzilla.gnome.org/show_bug.cgi?id=757951).

Adding a free of internal_pad in gst_adaptive_demux_stream_free() does not work because the internal_pad has adaptivedemux set as its parent. I also tried removing the call to set the pad's parent, but that didn't work because that ended up with the chain function being called with freed data.
Comment 1 Sebastian Dröge (slomo) 2016-01-22 15:49:12 UTC
You could use GST_PAD_FLAG_NEED_PARENT on the pad, and unparent the pad before freeing. Would that help?
Comment 2 A Ashley 2016-01-22 16:50:09 UTC
Created attachment 319562 [details] [review]
adaptivedemux: fix leak of stream->internal_pad

The function gst_adaptive_demux_stream_update_source() function creates a new GstPad called internal_pad. This pad is not freed when releasing the stream.
    
My solution is to set GST_PAD_FLAG_NEED_PARENT so that the chain functions do not get called when the pad has no parent and then remove the parent in the gst_adaptive_demux_stream_free() function. This causes the refcount of the pad to be decremented to zero.
Comment 3 Sebastian Dröge (slomo) 2016-01-22 17:06:19 UTC
Attachment 319562 [details] pushed as cfb1b79 - adaptivedemux: fix leak of stream->internal_pad
Comment 4 A Ashley 2016-01-22 17:08:41 UTC
(In reply to Sebastian Dröge (slomo) from comment #1)
> You could use GST_PAD_FLAG_NEED_PARENT on the pad, and unparent the pad
> before freeing. Would that help?

Thanks Sebastian, that did indeed fix the problem.