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 678015 - gst-rtsp-server: issues found with valgrind
gst-rtsp-server: issues found with valgrind
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-rtsp-server
git master
Other Linux
: Normal normal
: 0.11.x
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2012-06-13 12:59 UTC by David Svensson Fors
Modified: 2012-06-14 08:25 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
factory: plug pad leak in collect_streams (1.11 KB, patch)
2012-06-13 13:00 UTC, David Svensson Fors
none Details | Review
rtsp-client: don't use g_object_unref on GstRTSPSessionMedia (825 bytes, patch)
2012-06-13 13:01 UTC, David Svensson Fors
none Details | Review
rtsp-client: changed session media iteration (1.43 KB, patch)
2012-06-13 13:02 UTC, David Svensson Fors
none Details | Review
rtsp-client: free transport on no_stream in SETUP handler (730 bytes, patch)
2012-06-13 13:02 UTC, David Svensson Fors
none Details | Review
rtsp-media: don't collect media stats when going to NULL (861 bytes, patch)
2012-06-13 13:03 UTC, David Svensson Fors
none Details | Review

Description David Svensson Fors 2012-06-13 12:59:52 UTC
When running gst-rtsp-server in valgrind, I've found some memory issues (leaks etc), which are explained below. 5 patches will be attached that are suggested fixes for those issues.

PATCH #1: In gst_rtsp_media_factory_collect_streams: unref the srcpad that was retrieved using gst_element_get_static_pad. gst_ghost_pad_new will take one reference, and the other reference will otherwise give a memory leak.

PATCH #2: Don't use g_object_unref on GstRTSPSessionMedia. GstRTSPSessionMedia is not a GObject type. When the GstRTSPSession is freed, it will free the media.

PATCH #3: Changed session media iteration in rtsp-client.c, client_unlink_session: now don't iterate in session->medias list where items are removed by gst_rtsp_session_release_media. Instead, repeatedly remove the first item.

PATCH #4: rtsp-client.c: free transport on no_stream in SETUP handler.

PATCH #5: Avoid calling collect_media_stats from gst_rtsp_media_set_state when going to state GST_STATE_NULL. The motivation is a leak that can occur if a TEARDOWN request is handled right before shutting down and unreffing the GstRTSPServer.

For the TEARDOWN, we have the following calls:

handle_teardown_request
gst_rtsp_session_media_set_state (GST_STATE_NULL)
gst_rtsp_media_set_state (GST_STATE_NULL)
collect_media_stats
gst_element_query_duration

The duration query can lead to a cached GST_QUERY_DURATION message in the pipeline GstBin. That message holds a reference to the pipeline, which gets a ref count of 2.

Then, when the server is shut down, gst_rtsp_media_finalize gets called. Here, the media pipeline is unreffed. But the pipeline ref count is 2, so the pipeline is not freed.

Patch #5 avoids this by not collecting media stats when going to GST_STATE_NULL. If I understand correctly, it is not an error to not collect media stats in this case.
Comment 1 David Svensson Fors 2012-06-13 13:00:53 UTC
Created attachment 216271 [details] [review]
factory: plug pad leak in collect_streams
Comment 2 David Svensson Fors 2012-06-13 13:01:36 UTC
Created attachment 216273 [details] [review]
rtsp-client: don't use g_object_unref on GstRTSPSessionMedia
Comment 3 David Svensson Fors 2012-06-13 13:02:14 UTC
Created attachment 216274 [details] [review]
rtsp-client: changed session media iteration
Comment 4 David Svensson Fors 2012-06-13 13:02:52 UTC
Created attachment 216275 [details] [review]
rtsp-client: free transport on no_stream in SETUP handler
Comment 5 David Svensson Fors 2012-06-13 13:03:28 UTC
Created attachment 216276 [details] [review]
rtsp-media: don't collect media stats when going to NULL
Comment 6 Wim Taymans 2012-06-14 08:25:04 UTC
pushed