attackgoat / screen-13

Screen 13 is an easy-to-use Vulkan rendering engine in the spirit of QBasic.
Apache License 2.0
264 stars 13 forks source link

Racy SIGSEGV when closing window under Wayland #51

Open trevex opened 1 year ago

trevex commented 1 year ago

I recently started playing around with Screen 13 and quite like the API and how flexible and powerful it is.

Anyway I noticed under Wayland when the window is closed I often get the following log message:

wl_display@1: error 0: invalid object 17

Sometimes (seems to be racy) the application will SIGSEGV when closing the window, e.g. when running multipass-example:

Thread 50 "multipass" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7fffa773e640 (LWP 1489027)]
0x00007ffff7af4360 in wl_list_insert () from /nix/store/fs8vvfl6jgvzrjbgzbc7ysp1byw3n0w4-wayland-1.21.0/lib/libwayland-client.so
(gdb) bt full
#0  0x00007ffff7af4360 in wl_list_insert ()
   from /nix/store/fs8vvfl6jgvzrjbgzbc7ysp1byw3n0w4-wayland-1.21.0/lib/libwayland-client.so
No symbol table info available.
#1  0x00007ffff7af0f48 in wl_display_read_events ()
   from /nix/store/fs8vvfl6jgvzrjbgzbc7ysp1byw3n0w4-wayland-1.21.0/lib/libwayland-client.so
No symbol table info available.
#2  0x00007ffff7af1689 in wl_display_dispatch_queue ()
   from /nix/store/fs8vvfl6jgvzrjbgzbc7ysp1byw3n0w4-wayland-1.21.0/lib/libwayland-client.so
No symbol table info available.
#3  0x00007ffff7af195f in wl_display_roundtrip_queue ()
   from /nix/store/fs8vvfl6jgvzrjbgzbc7ysp1byw3n0w4-wayland-1.21.0/lib/libwayland-client.so
No symbol table info available.
#4  0x00007fffeba9054b in ?? () from /nix/store/pr7lp4lcsa6jskb7jc7hh0i9xrjlpq28-amdvlk-2022.Q2.2/lib/amdvlk64.so
No symbol table info available.
#5  0x00007fffeba96789 in ?? () from /nix/store/pr7lp4lcsa6jskb7jc7hh0i9xrjlpq28-amdvlk-2022.Q2.2/lib/amdvlk64.so
No symbol table info available.
#6  0x00007fffeb89e0ad in ?? () from /nix/store/pr7lp4lcsa6jskb7jc7hh0i9xrjlpq28-amdvlk-2022.Q2.2/lib/amdvlk64.so
No symbol table info available.
#7  0x00007ffff7c2de86 in start_thread ()
   from /nix/store/ayfr5l52xkqqjn3n4h9jfacgnchz1z7s-glibc-2.35-224/lib/libc.so.6
No symbol table info available.
#8  0x00007ffff7cb4ce0 in clone3 () from /nix/store/ayfr5l52xkqqjn3n4h9jfacgnchz1z7s-glibc-2.35-224/lib/libc.so.6
No symbol table info available.

A quick Google search revealed nothing, but I do not encounter these issues running bevy-, wgpu- or vulkano-examples, which effectively leverage winit and ash as well.

This is not a showstopper for me personally and can be circumvented by defining WINIT_UNIX_BACKEND=x11, but I felt the need to document this behaviour.

attackgoat commented 1 year ago

Interesting! I have not tested under wayland yet; and now that I do I am running into similar but different issues using Nvidia driver version 525 (proprietary version, not open). I'll be looking into this and #52 - I don't have an AMD iGPU but I do have an Intel iGPU and an AMD GPU that I can test with.

I will put a note on the README about what platforms are tested regularly.

trevex commented 1 year ago

As the stacktrace references amdvlk64.so my unfounded suspicion would be that resources are freed too early / in the wrong order.