libsdl-org / SDL

Simple Directmedia Layer
https://libsdl.org
zlib License
9.57k stars 1.77k forks source link

[sdl2, wayland] segfault on every SDL2 program quit (commit bisect inside) #9086

Closed vanfanel closed 7 months ago

vanfanel commented 7 months ago

Hi,

Every SDL2 program segfaults on quit on Wayland (built without XWayland support, latest stable MESA 24.0.1, latest stable wlroots 0.17.1, simple wlroots-based compositors labwc/sway/cage).

It happens since exactly this commit:

https://github.com/libsdl-org/SDL/commit/271df2fdd8f611bde4b36ed82e8289e8ff2506b6

Still happens on current GIT code.

GDB backtrace (it's from DoomRetro, but any SDL2 game I have tried does the same, including SDLPop, CrispyDoom, Scummvm...):

Thread 1 "doomretro" received signal SIGSEGV, Segmentation fault.
0x00007ffff7a95627 in ?? () from /lib/x86_64-linux-gnu/libc.so.6
(gdb) bt
#0  0x00007ffff7a95627 in ?? () from /lib/x86_64-linux-gnu/libc.so.6
#1  0x00007ffff7f16908 in wl_cursor_theme_get_cursor () from /usr/local/lib/x86_64-linux-gnu/libwayland-cursor.so.0
#2  0x00007ffff7de7fbd in wayland_get_system_cursor (vdata=0x5555606f05b0, cdata=0x5555606f3280, scale=0x7fffffffdab4)
    at /root/src/sdl/ssss/SDL/src/video/wayland/SDL_waylandmouse.c:283
#3  0x00007ffff7de8703 in Wayland_ShowCursor (cursor=0x5555606f5130) at /root/src/sdl/ssss/SDL/src/video/wayland/SDL_waylandmouse.c:527
#4  0x00007ffff7c5f9d5 in SDL_SetCursor_REAL (cursor=0x5555606f5130) at /root/src/sdl/ssss/SDL/src/events/SDL_mouse.c:1417
#5  0x00007ffff7c5fbb7 in SDL_ShowCursor_REAL (toggle=1) at /root/src/sdl/ssss/SDL/src/events/SDL_mouse.c:1498
#6  0x00007ffff7c5ec18 in SDL_MouseQuit () at /root/src/sdl/ssss/SDL/src/events/SDL_mouse.c:935
#7  0x00007ffff7d59c32 in SDL_VideoQuit_REAL () at /root/src/sdl/ssss/SDL/src/video/SDL_video.c:3399
#8  0x00007ffff7c27448 in SDL_QuitSubSystem_REAL (flags=62001) at /root/src/sdl/ssss/SDL/src/SDL.c:440
#9  0x00007ffff7c27600 in SDL_Quit_REAL () at /root/src/sdl/ssss/SDL/src/SDL.c:505
#10 0x00007ffff7c4a321 in SDL_Quit () at /root/src/sdl/ssss/SDL/src/dynapi/SDL_dynapi_procs.h:92
#11 0x00005555555ed7e3 in I_Quit ()
#12 0x000055555562452e in M_Responder ()
#13 0x00005555555d6039 in D_PostEvent ()
#14 0x00005555555f14ad in I_StartTic ()
#15 0x0000555555618823 in TryRunTics ()
#16 0x00005555555d6a8d in D_DoomLoop ()
#17 0x00005555555da00e in D_DoomMain ()
#18 0x0000555555599c66 in main ()
Kontrabant commented 7 months ago

Can you test this pull to see if it fixes your issue?

Kontrabant commented 7 months ago

Actually, this has to go in anyways, as the check is in SDL3, but was missed in the SDL2 version. Please reopen this if it didn't fix the problem.

vanfanel commented 7 months ago

Can you test this pull to see if it fixes your issue?

Yes, that fixes it, no more segfaults in quit. Thanks!