Skip to content

fix leaked loader_lock in terminator_CreateHeadlessSurfaceEXT#1956

Merged
charles-lunarg merged 1 commit into
KhronosGroup:mainfrom
aizu-m:headless-surface-unlock
Jul 3, 2026
Merged

fix leaked loader_lock in terminator_CreateHeadlessSurfaceEXT#1956
charles-lunarg merged 1 commit into
KhronosGroup:mainfrom
aizu-m:headless-surface-unlock

Conversation

@aizu-m

@aizu-m aizu-m commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

terminator_CreateHeadlessSurfaceEXT, the disabled-extension branch:

loader_platform_thread_lock_mutex(&loader_lock);
...
if (!loader_inst->enabled_extensions.ext_headless_surface) {
    loader_log(...);
    return VK_SUCCESS;   // loader_lock still held here
}

Spotted while reading through the surface terminators after the recent DestroySurfaceKHR change. Every other terminator_Create*Surface* (win32, wayland, xcb, xlib, directfb, macos) reaches its exit through goto out, and out: unlocks loader_lock. This one returns straight out with the mutex still held.

loader_lock is the loader's global lock. Once it leaks the next entry point that tries to take it blocks forever, so a single vkCreateHeadlessSurfaceEXT call made without VK_EXT_headless_surface enabled wedges the whole instance.

Swapped the early return for goto out. result is already VK_SUCCESS at that point and icd_surface is still NULL, so cleanup_surface_creation is a no-op and the function returns the same value as before, only now the lock is released. Brings this branch in line with the other create-surface terminators.

@ci-tester-lunarg

Copy link
Copy Markdown

Author aizu-m not on autobuild list. Waiting for curator authorization before starting CI build.

1 similar comment
@ci-tester-lunarg

Copy link
Copy Markdown

Author aizu-m not on autobuild list. Waiting for curator authorization before starting CI build.

@ci-tester-lunarg

Copy link
Copy Markdown

CI Vulkan-Loader build queued with queue ID 26933.

@charles-lunarg charles-lunarg left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yet again, good eye!

@ci-tester-lunarg

Copy link
Copy Markdown

CI Vulkan-Loader build # 3604 running.

@ci-tester-lunarg

Copy link
Copy Markdown

CI Vulkan-Loader build # 3604 passed.

@charles-lunarg charles-lunarg merged commit 0aa588e into KhronosGroup:main Jul 3, 2026
51 checks passed
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