GNOME Bugzilla – Bug 761844
rtsp-server: tls client socket leaks when using new main context
Last modified: 2018-11-03 15:39:43 UTC
Created attachment 320835 [details] [review] test-video with different main context I've updated our streaming server to use GStreamer 1.6.3 (gst-rtsp-server 1.6.2), glib 2.46.2 and glib-networking 2.46.1. There's an RTSP TLS socket leak for the socket used to communicate back with the client. The leak only happens occurs if a different GMainContext is used. I'm attaching a patch for the examples/test-video.c. Once the server is running just run a client with: $ gst-launch-1.0 rtspsrc location=rtsps://user:password@127.0.0.1:8554/test tls-validation-flags=0 ! fakesink silent=false -v lsof will show the leaks. This worked before with GStreamer 1.4.5, glib 2.42.0 and glib-networking 2.42.0
Created attachment 320836 [details] no socket leak ref/unref stack traces Stack traces for all the g_object_ref/unref. This is with the problem fixed (using main context).
Created attachment 320837 [details] socket leak ref/unref stack traces Stack traces for all the g_object_ref/unref. One g_object_unref missing.
Also, this is from valgrind with --track-fds=yes. It is from my application but it shows where the socket leak comes from. ==29769== Open AF_INET socket 16: 127.0.0.1:8554 <-> unbound ==29769== at 0x566E05D: ??? (syscall-template.S:81) ==29769== by 0x7A6FD0F: g_socket_accept (gsocket.c:2258) ==29769== by 0x74B46DE: gst_rtsp_connection_accept (gstrtspconnection.c:446) ==29769== by 0x728CFC6: gst_rtsp_server_io_func (rtsp-server.c:1169) ==29769== by 0x7A6DD70: socket_source_dispatch (gsocket.c:3284) ==29769== by 0x8036B19: g_main_dispatch (gmain.c:3154) ==29769== by 0x8036B19: g_main_context_dispatch (gmain.c:3769) ==29769== by 0x8036EDF: g_main_context_iterate.isra.29 (gmain.c:3840) ==29769== by 0x8037201: g_main_loop_run (gmain.c:4034) ==29769== by 0x4E9CD29: thread_func(void*) (XXXXXXXX.C:374) ==29769== by 0x56656A9: start_thread (pthread_create.c:333) ==29769== by 0x5982EEC: clone (clone.S:109) ==29769==
Aleix, did you succeed with creating a patch for this?
(In reply to Sebastian Dröge (slomo) from comment #4) > Aleix, did you succeed with creating a patch for this? No, what I did is use the default main context in my server instead of using a new one. I'll try to find some time to debug this. I'm curious to see where the problem is. My guts tell me it's in glib, but it's just a guess.
Aleix, did you have any chance to look into this again?
No, no time. We are swamped. Last week we made it pushing the srtp related ones, even not planned. Yesterday, I flew to Barcelona so I'm going to spend a few weeks working with Josep. Not sure if we will have time for this though. May be there's even a chance that something got fixed in glib.... ? I'll at least try it in a few days and see if it's still reproducible.
This still seems to be a problem. I can reproduce this. The test example is leaking some things that should be unrefed (server, loop, context) as well, but even then I get this socket fd leak. Strangely enough it seems to only leak the fd itself but I don't get leaks for any socket objects/structs reported in valgrind.
-- GitLab Migration Automatic Message -- This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/gstreamer/gst-rtsp-server/issues/20.