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 760289 - rtpvrawdepay : memory leak
rtpvrawdepay : memory leak
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-good
git master
Other All
: Normal critical
: 1.6.3
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2016-01-07 19:28 UTC by chamois94
Modified: 2016-01-11 23:12 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
rtpvrawdepay: fix major memory leak and performance issue (1.85 KB, patch)
2016-01-07 20:31 UTC, Tim-Philipp Müller
committed Details | Review
patches for some other rtp depayloaders (7.65 KB, patch)
2016-01-08 01:00 UTC, Tim-Philipp Müller
committed Details | Review

Description chamois94 2016-01-07 19:28:30 UTC
Using gstvraw pay/depay cause a huge memory leak.

Source : 
gst-launch-1.0 videotestsrc ! video/x-raw, width=320, height=240, format=I420 ! rtpvrawpay ! udpsink port=1234

Sink:
gst-launch-1.0 udpsrc port=1234 caps="application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)RAW, sampling=(string)YCbCr-4:2:0, depth=(string)8, width=(string)320, height=(string)240, colorimetry=(string)BT601-5, payload=(int)96" ! rtpvrawdepay ! videoconvert ! xvimagesink

Valgrind gives error in gst_rtp_vraw_depay_process_packet in gstvrawdepay.c

==12273== 27,141,368 (3,665,200 direct, 23,476,168 indirect) bytes in 13,475 blocks are definitely lost in loss record 2,518 of 2,518
==12273==    at 0x4C2AB80: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==12273==    by 0x53F9610: g_malloc (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4002.0)
==12273==    by 0x540F22D: g_slice_alloc (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4002.0)
==12273==    by 0x4E7081E: gst_buffer_new (in /usr/lib/x86_64-linux-gnu/libgstreamer-1.0.so.0.701.0)
==12273==    by 0x4E735D3: gst_buffer_copy_region (in /usr/lib/x86_64-linux-gnu/libgstreamer-1.0.so.0.701.0)
==12273==    by 0x8ADF43B: gst_rtp_vraw_depay_process_packet (in /usr/lib/x86_64-linux-gnu/gstreamer-1.0/libgstrtp.so)
==12273==    by 0x941674E: gst_rtp_base_depayload_handle_buffer.isra.4 (in /usr/lib/x86_64-linux-gnu/libgstrtp-1.0.so.0.701.0)
==12273==    by 0x4EA5406: gst_pad_push_data (in /usr/lib/x86_64-linux-gnu/libgstreamer-1.0.so.0.701.0)
==12273==    by 0x4EAD3AD: gst_pad_push (in /usr/lib/x86_64-linux-gnu/libgstreamer-1.0.so.0.701.0)
==12273==    by 0x7C860A4: gst_base_src_loop (in /usr/lib/x86_64-linux-gnu/libgstbase-1.0.so.0.701.0)
==12273==    by 0x4ED7320: gst_task_func (in /usr/lib/x86_64-linux-gnu/libgstreamer-1.0.so.0.701.0)
==12273==    by 0x541988B: ??? (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4002.0)

I could solve problem adding gst_buffer_unref (buf) before each return
Comment 1 Tim-Philipp Müller 2016-01-07 20:31:05 UTC
Created attachment 318440 [details] [review]
rtpvrawdepay: fix major memory leak and performance issue

Oops, nice catch. This should fix it. Was caused by the meta-copying code. The code is still a bit puzzling in that respect, need to check with Sebastian what the intention here was.
Comment 2 Tim-Philipp Müller 2016-01-08 01:00:38 UTC
Created attachment 318448 [details] [review]
patches for some other rtp depayloaders
Comment 3 Sebastian Dröge (slomo) 2016-01-08 14:42:14 UTC
Tim, you're working on this, right?
Comment 4 Tim-Philipp Müller 2016-01-08 14:49:03 UTC
yes.
Comment 5 Tim-Philipp Müller 2016-01-08 17:15:36 UTC
commit a8b864397764af49aa7827056e6c799175b38f39
Author: Tim-Philipp Müller <tim@centricular.com>
Date:   Thu Jan 7 20:27:29 2016 +0000

    rtpvrawdepay: fix major memory leak and performance issue
    
    We call gst_rtp_buffer_get_payload() which creates a sub-buffer
    of each input buffer, just to copy over metas, and then leak it.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=760289