qemu 11.0: SDL UI crashes in X11-only environments when gl is enabled
Yocto project is using a X11-only environment, e.g. DISPLAY is set, but not WAYLAND_DISPLAY. With qemu 11.x we started seeing the following crash: ``` #0 0x00007ffff721b4f4 in pthread_mutex_lock () from /home/akanavin/bitbake-builds/poky-master/build/tmp/sysroots-uninative/x86_64-linux/lib/libc.so.6 #1 0x00007ffff5a9a9e6 in wl_proxy_create_wrapper (proxy=0x5555583f2940) at ../sources/wayland-1.25.0/src/wayland-client.c:2800 #2 0x00007ffff58bf994 in dri2_initialize_wayland_drm (disp=0x555559548070) at ../sources/mesa-26.0.6/src/egl/drivers/dri2/platform_wayland.c:2680 #3 0x00007ffff58c0e7e in dri2_initialize_wayland (disp=disp@entry=0x555559548070) at ../sources/mesa-26.0.6/src/egl/drivers/dri2/platform_wayland.c:3288 #4 0x00007ffff58b899d in dri2_initialize (disp=disp@entry=0x555559548070) at ../sources/mesa-26.0.6/src/egl/drivers/dri2/egl_dri2.c:895 #5 0x00007ffff58abc3b in eglInitialize (dpy=<optimized out>, major=0x0, minor=0x0) at ../sources/mesa-26.0.6/src/egl/main/eglapi.c:697 #6 0x00007ffff7cc77f5 in SDL_EGL_LoadLibrary (_this=_this@entry=0x5555584054a0, egl_path=egl_path@entry=0x0, native_display=0x5555583f2940, platform=platform@entry=0) at /home/akanavin/bitbake-builds/poky-master/build/tmp/work/x86_64-linux/libsdl2-native/2.32.10/sources/SDL2-2.32.10/src/video/SDL_egl.c:547 #7 0x00007ffff7cf4695 in X11_GLES_LoadLibrary (_this=_this@entry=0x5555584054a0, path=path@entry=0x0) at /home/akanavin/bitbake-builds/poky-master/build/tmp/work/x86_64-linux/libsdl2-native/2.32.10/sources/SDL2-2.32.10/src/video/x11/SDL_x11opengles.c:56 #8 0x00007ffff7cf3ec8 in X11_GL_LoadLibrary (_this=0x5555584054a0, path=<optimized out>) at /home/akanavin/bitbake-builds/poky-master/build/tmp/work/x86_64-linux/libsdl2-native/2.32.10/sources/SDL2-2.32.10/src/video/x11/SDL_x11opengl.c:270 #9 0x00007ffff7cd4734 in SDL_GL_LoadLibrary_REAL (path=path@entry=0x0) at /home/akanavin/bitbake-builds/poky-master/build/tmp/work/x86_64-linux/libsdl2-native/2.32.10/sources/SDL2-2.32.10/src/video/SDL_video.c:3493 #10 0x00007ffff7cd66c3 in SDL_CreateWindow_REAL (title=0x555556029e87 "", x=536805376, y=536805376, w=1, h=1, flags=42) at /home/akanavin/bitbake-builds/poky-master/build/tmp/work/x86_64-linux/libsdl2-native/2.32.10/sources/SDL2-2.32.10/src/video/SDL_video.c:1717 #11 0x00007ffff7c52688 in SDL_CreateWindow (a=a@entry=0x555556029e87 "", b=b@entry=536805376, c=c@entry=536805376, d=<optimized out>, e=e@entry=1, f=f@entry=42) at /home/akanavin/bitbake-builds/poky-master/build/tmp/work/x86_64-linux/libsdl2-native/2.32.10/sources/SDL2-2.32.10/src/dynapi/SDL_dynapi_procs.h:545 #12 0x0000555555be7b04 in sdl2_window_create (scon=scon@entry=0x5555584240f0) at ../sources/qemu-11.0.0/ui/sdl2.c:106 #13 0x0000555555be92de in sdl2_gl_console_init (scon=0x5555584240f0) at ../sources/qemu-11.0.0/ui/sdl2-gl.c:306 #14 0x0000555555be78e9 in sdl2_display_init (ds=<optimized out>, o=0x555557124140 <dpy>) at ../sources/qemu-11.0.0/ui/sdl2.c:957 #15 0x0000555555b2938f in qemu_init_displays () at ../sources/qemu-11.0.0/system/vl.c:2689 #16 qemu_init (argc=<optimized out>, argv=<optimized out>) at ../sources/qemu-11.0.0/system/vl.c:3847 #17 0x0000555555892529 in main (argc=<optimized out>, argv=<optimized out>) at ../sources/qemu-11.0.0/system/main.c:71 ``` Reverting the following commit fixes the issue: https://gitlab.com/qemu-project/qemu/-/commit/52053b7e0a0e285ce3448b830053b05fb0a9b1a8 To reproduce, unset WAYLAND_DISPLAY (and ensure DISPLAY is present and valid) and run: ``` $ WAYLAND_DISPLAY= ../bin/qemu-system-x86_64 -display sdl,gl=on Segmentation fault ```
issue