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 688703 - rtsp-stream: socket leak
rtsp-stream: socket leak
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-rtsp-server
git master
Other Linux
: Normal normal
: 1.2.3
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2012-11-20 07:52 UTC by David Svensson Fors
Modified: 2014-02-25 22:28 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Plug rtsp-stream socket leak (1.14 KB, patch)
2012-11-20 07:54 UTC, David Svensson Fors
committed Details | Review

Description David Svensson Fors 2012-11-20 07:52:48 UTC
In gst-rtsp-server, I run a unit test in Valgrind:

GST_CHECKS=test_describe make -C tests/check gst/rtspserver.valgrind

I get several leaks. One of them looks like this:

==1069== Thread 1:
==1069== 240 bytes in 3 blocks are definitely lost in loss record 3,342 of 3,477
==1069==    at 0x4C28BED: malloc (vg_replace_malloc.c:263)
==1069==    by 0x6A5AF30: g_malloc (gmem.c:159)
==1069==    by 0x6A6F322: g_slice_alloc (gslice.c:1003)
==1069==    by 0x6A6F875: g_slice_alloc0 (gslice.c:1029)
==1069==    by 0x61DD9F9: g_type_create_instance (gtype.c:1872)
==1069==    by 0x61C2817: g_object_constructor (gobject.c:1849)
==1069==    by 0x61C3DE0: g_object_newv (gobject.c:1713)
==1069==    by 0x61C45CF: g_object_new_valist (gobject.c:1830)
==1069==    by 0x572A8CD: g_initable_new_valist (ginitable.c:224)
==1069==    by 0x572A9C8: g_initable_new (ginitable.c:148)
==1069==    by 0x5740135: g_socket_new (gsocket.c:1010)
==1069==    by 0xB25D4A8: gst_udpsrc_start (gstudpsrc.c:770)
==1069==    by 0x508662D: gst_base_src_start (gstbasesrc.c:3123)
==1069==    by 0x5086A07: gst_base_src_activate_mode (gstbasesrc.c:3491)
==1069==    by 0x5C97B32: gst_pad_activate_mode (gstpad.c:1060)
==1069==    by 0x5C98380: gst_pad_set_active (gstpad.c:936)
==1069==    by 0x5C7B8A2: activate_pads (gstelement.c:2679)
==1069==    by 0x5C8AED3: gst_iterator_fold (gstiterator.c:614)
==1069==    by 0x5C7BAA4: iterator_activate_fold_with_resync.constprop.2 (gstelement.c:2699)
==1069==    by 0x5C7D8E8: gst_element_pads_activate (gstelement.c:2735)

A socket, that is created in gst_udpsrc_start, leaks. It turns out that this leak is in alloc_ports in rtsp-stream.c. A GSocket is fetched from a GstUDPSrc using g_object_get and set in a GstUPDSink using g_object_set. g_object_get gives an extra reference, and this reference is not taken back by g_object_set. (gst_multiudpsink_set_property uses g_value_dup_object for saving the socket in the GstUDPSink.)

The attached patch is a suggested fix for the leak. GSocket references are unreffed in two places with similar code.
Comment 1 David Svensson Fors 2012-11-20 07:54:11 UTC
Created attachment 229442 [details] [review]
Plug rtsp-stream socket leak
Comment 2 Wim Taymans 2012-11-20 08:27:28 UTC
commit 0996266342aa486d7680ccb9f414fa9c08fa42aa
Author: David Svensson Fors <davidsf@axis.com>
Date:   Mon Nov 19 15:44:27 2012 +0100

    rtsp-stream: plug socket leak
    
    Fixes https://bugzilla.gnome.org/show_bug.cgi?id=688703