App using gstwaylandsink leaks fds

Guillermo Rodriguez Garcia guille.rodriguez at gmail.com
Thu Mar 26 12:38:12 UTC 2020


Hi,

El jue., 26 mar. 2020 a las 11:28, Guillermo Rodriguez Garcia
(<guille.rodriguez at gmail.com>) escribió:
>
> Hi,
>
> El mié., 25 mar. 2020 a las 22:50, Nicolas Dufresne
> (<nicolas at ndufresne.ca>) escribió:
> >
> > Le mercredi 25 mars 2020 à 20:28 +0100, Guillermo Rodriguez Garcia a
> > écrit :
> > > Hello all,
> > >
> > > I have a minimal app using gstwaylandsink to show video from IP
> > > cameras. I found that every time the pipeline is stopped and
> > > destroyed, fds are leaked. After some time the application cannot
> > > create any fds and fails with a trace similar to this:
> > >
> > > ERROR> 0:41:16.094958597   584 0xb3ef5b20 ERROR            waylandsink
> > > wlshmallocator.c:59:gst_wl_shm_allocator_alloc:<wlshmallocator0>
> > > opening temp file /run/xdg/wayland-shm-1644-51WWXP failed: Too many
> > > open files
> > > ERROR> 0:41:16.095183222   584 0xb3ef5b20 WARN              GST_BUFFER
> > > gstbuffer.c:907:gst_buffer_new_allocate: failed to allocate 4 bytes
> > > ERROR> (gstplayer:584): GStreamer-CRITICAL **: gst_buffer_memset:
> > > assertion 'GST_IS_BUFFER (buffer)' failed
> > > ERROR> (gstplayer:584): GStreamer-CRITICAL **: gst_buffer_peek_memory:
> > > assertion 'GST_IS_BUFFER (buffer)' failed
> > > ERROR> ** (gstplayer:584): CRITICAL **: gst_fd_memory_get_fd:
> > > assertion 'mem != NULL' failed
> > > ERROR> 0:41:16.095766306   584 0xb3ef5b20 ERROR            waylandsink
> > > wlshmallocator.c:211:gst_wl_shm_memory_construct_wl_buffer:<GstWlDisplay at 0xb3e55210>
> > > wl_shm_memory: dup failed for fd=-1 (err=-1) mem=(nil)
> > >
> > > From a quick look at the source code I see that the fds are being
> > > allocated in gst_wl_shm_allocator_alloc [1]. But where are they being
> > > (/should they be) released?
> >
> > We do 'gst_buffer_replace (&sink->last_buffer, to_render);' which drop
> > reference on last_buffer, and take ownerhsip of to_render.
>
> I see, thank you for the hint!
>
> >
> > What GStreamer version is this ? Do you have some information on how to
> > reproduce ? I don't face this issue here.
>
> I saw this with 1.14.4. I will try to reproduce it with a more recent
> version, and also will try to come up with a minimal sample
> reproducing the issue.
> Best case I will find the problem during the process. Worst case I
> will have something to post here and ask for further help.

Ok, I found something. The problem is not directly related to waylandsink.

Every time I create a pipeline I am attaching a bus watch as follows:

GstBus *bus = gst_pipeline_get_bus(GST_PIPELINE(pipeline));
gst_bus_add_watch(bus, bus_error_handler, NULL);
gst_object_unref(bus);

Later when I'm done with the pipeline it is destroyed as follows:

gst_element_set_state(GST_ELEMENT(pipeline), GST_STATE_NULL);
gst_object_unref(GST_OBJECT(pipeline));

I understood that I didn't need to explicitly remove the bus watch when
destroying the pipeline, from this earlier reply from Sebastian Dröge:

https://lists.freedesktop.org/archives/gstreamer-devel/2015-August/054038.html

However this results in fd leaks as described.
If I explicitly remove the bus watch when the pipeline is destroyed:

g_source_remove (bus_watch_id);

then the leaks are gone.

Does this make sense?

Guillermo Rodriguez Garcia
guille.rodriguez at gmail.com


More information about the gstreamer-devel mailing list