GNOME Bugzilla – Bug 688703
rtsp-stream: socket leak
Last modified: 2014-02-25 22:28:53 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.
Created attachment 229442 [details] [review] Plug rtsp-stream socket leak
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