take loader_lock when adding unknown functions - #2047
Merged
charles-lunarg merged 2 commits intoOct 2, 2026
Merged
Conversation
vkGetInstanceProcAddr holds no lock, so registering an unknown extension function raced vkCreateDevice and vkDestroyDevice on each driver's logical device list, and raced other queries on the instance's unknown function name tables.
|
Author aizu-m not on autobuild list. Waiting for curator authorization before starting CI build. |
2 similar comments
|
Author aizu-m not on autobuild list. Waiting for curator authorization before starting CI build. |
|
Author aizu-m not on autobuild list. Waiting for curator authorization before starting CI build. |
Collaborator
|
The failing CI jobs were the no-assembly jobs, which need manual disabling of unknown function tests. I went ahead and pushed a commit that adds the correct disables. |
charles-lunarg
approved these changes
Oct 2, 2026
|
CI Vulkan-Loader build queued with queue ID 141658. |
|
CI Vulkan-Loader build # 3799 running. |
charles-lunarg
force-pushed
the
unknown-function-gpa-lock
branch
from
October 2, 2026 17:20
41590da to
f20c51b
Compare
|
Author aizu-m not on autobuild list. Waiting for curator authorization before starting CI build. |
1 similar comment
|
Author aizu-m not on autobuild list. Waiting for curator authorization before starting CI build. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ThreadSanitizer,
test_threadingbuilt with-D LOADER_ENABLE_THREAD_SANITIZER=ON, threads querying unknown device extension entry points while others create and destroy devices:M0 is
loader_lockand the address isicd_term->logical_device_list. The writer holds the lock, the reader holds nothing. OncevkDestroyDevicehas unlinked and freed theloader_devicethe walk is on, that walk reads freed memory and writesldev->loader_dispatch.ext_dispatch[idx]into it.Same shape on the name tables, with neither side holding anything:
Found reading through the unknown function handling after the
DestroySurfaceKHRlocking change.vkGetInstanceProcAddrtakes no lock, andtrampoline_get_proc_addrfalls through to these handlers once every name table has missed, so a driver reporting an entry point throughvk_icdGetInstanceProcAddrorvk_icdGetPhysicalDeviceProcAddrputs the registration on an unlocked path. Registration appends toinst->{dev,phys_dev}_ext_disp_functions, walksinst->icd_termsand each driver's logical device list, and writesicd_term->phys_dev_ext[]andinst->disp->phys_dev_ext[]. Every mutator of that state holdsloader_lock:vkCreateDevice/vkDestroyDevicearoundloader_add_logical_device/loader_remove_logical_device,vkEnumeratePhysicalDevicesaroundunload_drivers_without_physical_devices, instance create and destroy aroundicd_termsand the free of the tables. None of those require external synchronisation of theVkInstance, andvkGetInstanceProcAddrhas no external sync requirement either, so this is a legal call pattern.So take
loader_lockin the four entry points. It is recursive on both platforms, so the instance chain terminators that reach the_termvariants while already holding it are unaffected. It only lands on the registration path, which already calls into every driver and down the layer chain per invocation, not on the name lookup the recentvkGetInstanceProcAddrwork sped up.Two tests added. Both abort under ThreadSanitizer before the change;
linux-threadingis green after it.