SDL_Init( SDL_INIT_VIDEO ) hangs the program (Linux/Wayland)

Hello! I’m getting started with SDL3, but my program keeps hanging without showing the window. It seems that the issue is with my call to SDL_Init. The only thing I’m passing is SDL_INIT_VIDEO. Does anyone know why this might be an issue?

System Info:
Arch Linux
Intel Integrated & NVIDIA GTX graphics cards (laptop)
Wayland - Hyprland Compositor
Built SDL3 and SDL3_image from source.

what happens if you run your program with strace? which system call it freezes at?

It seems to keep calling clock_nanosleep(CLOCK_REALTIME, 0, {tv_sec=0, tv_nsec=1000000}, 0x7ffea322bab0) = 0 repeatedly…

quick guess: this might be undefined behavior. I saw an extensive discussion on #C channel at Libera.Chat regarding this.

this is the theory: there is probably some busy wait that calls this time function and waits time to pass. however, the compiler presumes that code runs as fast as possible, thus the difference could always be zero, thus time never really passes from the compiler perspective and so the compiler makes the busy wait never ends.

try to run your program with gdb, when it freezes, use gdb to stop the program and inspect the stack trace and discover who is doing such busy waiting. we need to determine whether SDL3 or Wayland is buggy. I think you’d need to download and configure debugging symbols in order to learn more about the buggy code, but I have never done that before, but you are an Arch Linux user, right? after this, then you should open some bug report for either SDL3 or Wayland or whatever is causing this.

compile your own code with -g3 and -fno-omit-frame-pointer

https://wiki.archlinux.org/title/Debugging/Getting_traces