Skip to content

egl: compare the wl_display interface by address in eglGetDisplay - #2226

Open
JROtto5 wants to merge 1 commit into
flightlessmango:masterfrom
JROtto5:fix/2205-egl-x11-display
Open

JROtto5 wants to merge 1 commit into
flightlessmango:masterfrom
JROtto5:fix/2205-egl-x11-display

Conversation

@JROtto5

@JROtto5 JROtto5 commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

On X11, an app that calls eglGetDisplay() with its X11 Display* can segfault in the hook. To spot a wl_display it read the display's first pointer as a wl_interface* and strcmp'd its name, but an Xlib Display starts with ext_data, which SDL3's X11 backend sets, so it followed junk (the try/catch can't catch a SIGSEGV). A gbm_device crashes the same way. It now compares that pointer with &wl_display_interface, which is how Mesa detects a Wayland display.

Tested master vs this branch, 5 runs each, on NVIDIA 615.78 and Mesa 26.2.5 (llvmpipe): an SDL3 X11 window + eglGetDisplay(display) segfaults every run on master and runs every time here, and a GBM device does the same on NVIDIA. Native Wayland eglGetDisplay(wl_display) is still detected with both drivers (MangoHud's wl_seat.get_keyboard shows up in WAYLAND_DEBUG).

Fixes #2205

The hook read the first pointer of the native display as a wl_interface*
and compared its name. An Xlib Display starts with ext_data, which SDL3's
X11 backend sets, and a gbm_device starts with a function pointer, so the
strcmp followed junk and segfaulted; try/catch can't catch a SIGSEGV.

Compare the pointer with &wl_display_interface instead, as Mesa does.

Fixes flightlessmango#2205
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] some games crash on x11+egl

1 participant