Possible resource leak in Weston

Guillermo Rodriguez guillerodriguez.dev at gmail.com
Wed Apr 22 14:45:42 UTC 2020


Hi all,

I am investigating something that looks like a resource leak in
Weston. I first saw the problem in an application involving Gstreamer,
which would run out of fds after a number of iterations (~1000).
However I have also been able to reproduce it without using Gstreamer.

This is the scenario:

I have a wayland application that uses Gstreamer to display video. The
application creates the display connection (wl_display_connect) and a
top-level surface; these last for the lifetime of the application.
Every time the application needs to show a video fragment, it builds a
Gstreamer pipeline, and passes the display and surface handles to
Gstreamer's waylandsink.

This ends up calling the gst_wl_display_new_existing function [1],
which registers a listener for the wayland registry and binds to some
interfaces [2]. Binding to the wl_shell interface results in a call to
weston_desktop_wl_shell_bind -> weston_desktop_client_create where
some resources are created, including, among others, a ping timer.

When Gstreamer is done showing the video, it cleans up and releases
all resources. As part of this process it calls wl_shell_destroy [3],
however this does NOT result in a call to
weston_desktop_client_destroy, and so the associated resources are not
released. In fact, the resources are only released when the
application disconnects (wl_display_disconnect) and exits. At this
point, all "pending" calls to weston_desktop_client_destroy are made.

The original symptoms (application running out of fds) are only
visible with wayland < 1.18.0. This is because up to 1.18.0, one
timerfd was being used for each ping timer. This was changed in this
commit [4]. However even if the symptoms are less visible, the issue
still exists in Weston.

Does this make sense?

In case I am not overlooking something and this is indeed a Weston
issue, any hints on how to fix it?

Thank you,

Guillermo Rodriguez

 [1]: https://github.com/GStreamer/gst-plugins-bad/blob/master/ext/wayland/wldisplay.c#L295
 [2]: https://github.com/GStreamer/gst-plugins-bad/blob/master/ext/wayland/wldisplay.c#L204
 [3]: https://github.com/GStreamer/gst-plugins-bad/blob/master/ext/wayland/wldisplay.c#L91
 [4]: https://github.com/wayland-project/wayland/commit/60a8d29ad8526c18cc670612e2c94f443873011a


More information about the wayland-devel mailing list