Skip to content

vulkaninfo: Fix crash with no X server - #1276

Open
igouss wants to merge 1 commit into
KhronosGroup:mainfrom
igouss:vulkaninfo-destroy-only-created
Open

igouss wants to merge 1 commit into
KhronosGroup:mainfrom
igouss:vulkaninfo-destroy-only-created

Conversation

@igouss

@igouss igouss commented Nov 13, 2026

Copy link
Copy Markdown

I run a Wayland desktop (Hyprland). After its Xwayland socket went away,
DISPLAY=:0 still pointed at it, and vulkaninfo --summary started
segfaulting at exit. On a terminal the summary prints and then it
crashes; piped or redirected (vulkaninfo --summary | grep deviceName)
it prints nothing, because stdout is still buffered when it crashes.

Any setup where DISPLAY is set but XOpenDisplay fails takes the same
path. I hit it after Xwayland went away; a stale DISPLAY over SSH or a
container with DISPLAY set and no server should do the same, though I
haven't tested those.

Cause. AppCreateXlibWindow throws when XOpenDisplay returns null.
The main loop catches that and skips the extension (vulkaninfo.cpp,
the create_window try/catch), but the teardown loop still calls
destroy_window for every surface extension, whether or not its window
was created. AppDestroyXlibWindow then calls
XDestroyWindow(nullptr, ...). (The XCB path got the equivalent null
check in #292.)

Fix. SurfaceExtension records whether create_window succeeded,
and teardown only calls destroy_window for windows that were created.
I fixed it in the loop rather than in AppDestroyXlibWindow because the
same pattern applies to other platforms: from reading the code, DirectFB
and QNX Screen can throw partway through create_window and would then
run their destroy functions on fields that were never set. I could only
build and test the Linux XCB/Xlib/Wayland paths. If you'd rather keep
the change local, a null check in AppDestroyXlibWindow (matching the
existing one in AppDestroyXcbWindow) also fixes this crash; I tested
that too and it behaved identically here.

One trade-off: a create_window that throws partway through now leaks
whatever it had already allocated (e.g. the DirectFB dfb, or the QNX
context) instead of passing it to destroy_window. The process is about
to exit, so I preferred that to running destroy on half-initialized
state.

Repro (nothing listening on :99):

DISPLAY=:99 vulkaninfo --summary
  • Expected: summary printed, surface creation errors on stderr, exit 0.
  • Actual: Segmentation fault, exit 139 (stdout empty when
    redirected); backtrace
    XDestroyWindow ← AppDestroyXlibWindow.

Testing (Arch Linux, Mesa 26.2.5, libX11 1.8.14; Intel UHD 630 +
AMD Radeon R9 200 / HD 7900 Series (RADV TAHITI)), with VK_LAYER_KHRONOS_validation
enabled:

Case main (1d3fbab) this PR
DISPLAY=:99, no X server, --summary segfault, exit 139 exit 0
DISPLAY=:99, no X server, full output — exit 0
DISPLAY unset — exit 0
live X server on :99 (Xwayland), full and --summary exit 0 exit 0; XCB and Xlib surfaces listed (full output)

No validation messages in any run. With a live X server, output is the
same as main apart from the heap budget value, which varies between
runs. Also reproduced the crash with the Arch vulkan-tools 1.4.363.0-1
package.

🤖 Generated with Claude Code

When DISPLAY is set but no X server is reachable, AppCreateXlibWindow
throws after XOpenDisplay returns null. The error is caught and the
extension is skipped, but the teardown loop still calls destroy_window
for every surface extension. AppDestroyXlibWindow then passes the null
Display to XDestroyWindow and segfaults. Output still buffered in
stdout is lost, so a piped or redirected run prints nothing.

Record in SurfaceExtension whether create_window succeeded, and only
call destroy_window for windows that were created. This covers every
platform's teardown rather than adding a null check to one of them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ci-tester-lunarg

Copy link
Copy Markdown

User igouss not on autobuild list. Waiting for curator authorization before starting CI build.

1 similar comment
@ci-tester-lunarg

Copy link
Copy Markdown

User igouss not on autobuild list. Waiting for curator authorization before starting CI build.

@CLAassistant

CLAassistant commented Nov 13, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

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.

3 participants