Repository navigation
Use recursive mutexes to fix deadlocks in loader - #1866
Merged
charles-lunarg merged 6 commits intoFeb 20, 2026
Merged
Conversation
Because the functions are non-global, to enable proper threaded test execution, they must be initialized per InstWrapper.
This improves performance slightly by reducing the amount of symbols that need to be resolved in calls to dlopen.
Requires adding locks to various components of the test framework that need to support multiple calls to it simultaneously.
|
CI Vulkan-Loader build queued with queue ID 654373. |
|
CI Vulkan-Loader build # 3423 running. |
|
CI Vulkan-Loader build queued with queue ID 654391. |
|
CI Vulkan-Loader build # 3424 running. |
|
CI Vulkan-Loader build # 3424 failed. |
All mutexes are now recursive and can be acquired in the same thread. And loader_global_instance_list_lock was removed as it masked the underlying synchronization problems. The fundamental sync problem is that vkCreateInstance and vkCreateDevice must call down the chain to fill out the dispatch tables and during this it must search through the global list of instances/devices. With recursive mutexes, we do not need to do anything special to guarantee that walking the global lists are safe when occurring inside of vkCreateInstance/vkCreateDevice and outside of those calls. This commit adds a new threading test which exercises the debug utils naming functions. It also enables the threading tests to run during regular runs, and adds a github action CI job which enables the thread sanitizer.
charles-lunarg
force-pushed
the
use_recursive_mutexes
branch
from
February 18, 2026 22:50
f6b47a5 to
5b0ed94
Compare
|
CI Vulkan-Loader build queued with queue ID 654430. |
1 similar comment
|
CI Vulkan-Loader build queued with queue ID 654430. |
|
CI Vulkan-Loader build # 3425 running. |
|
CI Vulkan-Loader build # 3425 failed. |
Need to only use the mutex after initialization .
Closed
In debug mode, address sanitizer reports errors that are false positives when loading a library with dlopen for the second time.
|
CI Vulkan-Loader build queued with queue ID 655592. |
1 similar comment
|
CI Vulkan-Loader build queued with queue ID 655592. |
|
CI Vulkan-Loader build # 3428 running. |
|
CI Vulkan-Loader build # 3428 passed. |
CommanderStorm
pushed a commit
to maplibre/maplibre-native-rs
that referenced
this pull request
Oct 1, 2026
…n loaders before 1.4.345 (#295) Solves (technically speaking avoid) #294 issue in which having a "not so old" Vulkan version causes Segfault when renderers are created or dropped concurrently. This adds a workaround until supported distributions ship a fixed loader. ### Changes - With the Vulkan backend only, a process-wide mutex is held while a `MapRenderer` is constructed and destroyed. Loading styles and rendering stay parallel. - The lock is only taken when the loader is older than 1.4.345 (KhronosGroup/Vulkan-Loader#1866). The version is queried once at runtime through `vkEnumerateInstanceVersion`, opening `libvulkan` with `dlopen` as MapLibre Native does. If it cannot be queried, the lock is taken. - `build.rs` defines `MLN_RENDER_BACKEND_VULKAN` for the bridge, next to the existing `MLN_RENDER_BACKEND_OPENGL`. - Same approach as the temporary `headlessDisplayMutex` for EGL (#230), removed in #262 once maplibre/maplibre-native#4332 landed. It carries a `TODO` to remove it in the same way. - New test `renderers_created_and_dropped_on_many_threads`: 8 threads each create, render and drop a tile renderer 4 times. ### AI assistance Claude was used to investigate the crash and to help write the code and the test. --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
EtienneLescot
added a commit
to getopenscreen/openscreen
that referenced
this pull request
Oct 31, 2026
Vulkan-Loader 1.4.341 (Ubuntu 26.04, ubuntu-latest since 30/10/2026) walks its global device list on every vkSetDebugUtilsObjectNameEXT and vkGetDeviceProcAddr while vkDestroyDevice on another thread frees a node of that list under a different lock. With one device per test, the parallel suite read a freed loader_device and died in SIGSEGV. Fixed upstream in KhronosGroup/Vulkan-Loader#1866, not in 1.4.341. One device created once and never destroyed leaves no destruction racing the tests, without serialising them.
Merged
3 tasks done
EtienneLescot
added a commit
to getopenscreen/openscreen
that referenced
this pull request
Oct 31, 2026
Vulkan-Loader 1.4.341 (Ubuntu 26.04, ubuntu-latest since 30/10/2026) walks its global device list on every vkSetDebugUtilsObjectNameEXT and vkGetDeviceProcAddr while vkDestroyDevice on another thread frees a node of that list under a different lock. With one device per test, the parallel suite read a freed loader_device and died in SIGSEGV. Fixed upstream in KhronosGroup/Vulkan-Loader#1866, not in 1.4.341. One device created once and never destroyed leaves no destruction racing the tests, without serialising them.
EtienneLescot
added a commit
to getopenscreen/openscreen
that referenced
this pull request
Oct 31, 2026
Vulkan-Loader 1.4.341 (Ubuntu 26.04, ubuntu-latest since 30/10/2026) walks its global device list on every vkSetDebugUtilsObjectNameEXT and vkGetDeviceProcAddr while vkDestroyDevice on another thread frees a node of that list under a different lock. With one device per test, the parallel suite read a freed loader_device and died in SIGSEGV. Fixed upstream in KhronosGroup/Vulkan-Loader#1866, not in 1.4.341. One device created once and never destroyed leaves no destruction racing the tests, without serialising them. (cherry picked from commit 5ae165e)
ItsMattoid
added a commit
to Metallic-Club/studio
that referenced
this pull request
Nov 4, 2026
The GPU test binaries crashed on ubuntu-26.04 because its Vulkan loader (libvulkan1 1.4.341) frees drivers without a device in vkEnumeratePhysicalDevices while another thread's vkSetDebugUtilsObjectNameEXT walks every instance's driver list (fixed upstream in loader 1.4.345, KhronosGroup/Vulkan-Loader#1866). With VK_DRIVER_FILES naming lavapipe alone, nothing is unloaded, so the Linux test job leaves the ubuntu-24.04 pin. Co-authored-by: mattoid <itsmattoid@gmail.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
oetiker
added a commit
to oetiker/shadcn-egui
that referenced
this pull request
Nov 9, 2026
Since ubuntu-latest moved to ubuntu-26.04 (between 2026-11-05 and 2026-11-08), the Workspace tests job dies with SIGSEGV in the checkbox test binary. The crash is in the Vulkan loader 1.4.341 that 26.04 ships: loader_get_icd_and_device() walks the process-global device list under loader_global_instance_list_lock, while vkCreateDevice and vkDestroyDevice change that list under loader_lock only. Each egui_kittest snapshot test creates and destroys its own wgpu device, so with four test threads in one process one test reads a device another test has just freed. wgpu's debug object names (on in debug builds) reach that walk on every named object. Measured in an ubuntu:26.04 container with one prebuilt checkbox binary: loader 1.4.341 crashes 6 of 6 runs; the 1.3.275 loader of ubuntu-24.04, or Debian's 1.4.363, passes; WGPU_DEBUG=0 or one test thread passes. Upstream fixed it in KhronosGroup/Vulkan-Loader#1866, first released in 1.4.350. nextest runs every test in a process of its own, so no two devices share a loader. The whole workspace run that way (999 tests, four at a time, against loader 1.4.341) passed three of three runs in 220 s, against 288 s for cargo test with four threads and 679 s with one. Doctests stay on cargo test: nextest does not run them. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 13, 2026
3 tasks
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.
While thread sanitizer has been a build option for a long time, it was not enabled in any tests leading to multiple threading issues persisting in the code.
Fixes #1863
Fixes #1739