Skip to content

Use recursive mutexes to fix deadlocks in loader#1866

Open
charles-lunarg wants to merge 6 commits intoKhronosGroup:mainfrom
charles-lunarg:use_recursive_mutexes
Open

Use recursive mutexes to fix deadlocks in loader#1866
charles-lunarg wants to merge 6 commits intoKhronosGroup:mainfrom
charles-lunarg:use_recursive_mutexes

Conversation

@charles-lunarg
Copy link
Collaborator

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

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-tester-lunarg
Copy link

CI Vulkan-Loader build queued with queue ID 654373.

@ci-tester-lunarg
Copy link

CI Vulkan-Loader build # 3423 running.

@ci-tester-lunarg
Copy link

CI Vulkan-Loader build queued with queue ID 654391.

@ci-tester-lunarg
Copy link

CI Vulkan-Loader build # 3424 running.

@ci-tester-lunarg
Copy link

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.
@ci-tester-lunarg
Copy link

CI Vulkan-Loader build queued with queue ID 654430.

1 similar comment
@ci-tester-lunarg
Copy link

CI Vulkan-Loader build queued with queue ID 654430.

@ci-tester-lunarg
Copy link

CI Vulkan-Loader build # 3425 running.

@ci-tester-lunarg
Copy link

CI Vulkan-Loader build # 3425 failed.

Need to only use the mutex after initialization .
@TornaxO7 TornaxO7 mentioned this pull request Feb 19, 2026
In debug mode, address sanitizer reports errors that are false positives when loading a
library with dlopen for the second time.
@ci-tester-lunarg
Copy link

CI Vulkan-Loader build queued with queue ID 655592.

1 similar comment
@ci-tester-lunarg
Copy link

CI Vulkan-Loader build queued with queue ID 655592.

@ci-tester-lunarg
Copy link

CI Vulkan-Loader build # 3428 running.

@ci-tester-lunarg
Copy link

CI Vulkan-Loader build # 3428 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.

received signal SIGSEV Deadlock on device destruction due to mutex

2 participants

Comments