examples/glupload: Segfault on close with Wayland backend
Code in question can be found here: https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/blob/bf96e264c933acadbd00e846f4184e7b9ec9b309/examples/src/bin/glupload.rs
Segfault happens in the finalize
function of GstGLDisplayWayland
in
g_clear_pointer (&display_wayland->shell, wl_shell_destroy);
Leaking the display from the example code works around this:
diff --git a/examples/src/bin/glupload.rs b/examples/src/bin/glupload.rs
index 4c5deb4..462ee8e 100644
--- a/examples/src/bin/glupload.rs
+++ b/examples/src/bin/glupload.rs
@@ -418,6 +418,8 @@ impl App {
let gl_context = shared_context.clone();
let events_proxy = events_loop.create_proxy();
+ std::mem::forget(gl_display.clone());
+
#[allow(clippy::single_match)]
bus.set_sync_handler(move |_, msg| {
match msg.view() {
My guess is that the problem here is that glutin is disconnecting the wayland display before the last reference to the GstGLDisplayWayland
is released. We then destroy those interfaces without the underlying display still being there and that simply crashes.
Or maybe we're not supposed to keep/destroy these interfaces if it is a foreign display?
How do lifetimes work in Wayland for these things? :)