Thread safety: vkDeviceWaitIdle on vkback-live vs vkQueueBindSparse on umem-binds #38

Closed
opened 2026-12-01 03:12:35 +00:00 by github-bot · 2 comments
Owner

@⁠tmalik1116 on GitHub · 2026-12-01 03:10 UTC · original

Finding (AGENTS.md rule 29): vkDeviceWaitIdle on the vkback-live thread runs at the same time as vkQueueBindSparse on umem's umem-binds thread. vkDeviceWaitIdle requires every queue of the device to be externally synchronized (Vulkan spec, "Threading Behavior"), and the bind thread does not hold off for it.

Seen on: 19862d4 (with the present fix from the linked PR, which does not touch these paths). Not seen in the next three validation runs (73ee0ab, with and without that fix): it is timing-dependent.

UNASSIGNED-Threading-MultipleThreads-Write
vkDeviceWaitIdle(): THREADING ERROR : object of type VkQueue is simultaneously used in current thread "vkback-live" (vkDeviceWaitIdle) and thread "umem-binds" (vkQueueBindSparse)

Where (73ee0ab): the device_wait_idle calls on the live thread are greenfield/vkback/src/present.rs:308, present.rs:837 and greenfield/vkback/src/lib.rs:4148 (presenter and backend teardown, and swapchain recreate). The binds are greenfield/umem/src/binds.rs:481 and binds.rs:490.

Why it is not a one-line fix: making the bind thread wait while the device idles could hang. Queued work waits on the binds' timeline values, so the device does not go idle until the binds run (compare texcheck.rs:20, where device_wait_idle hung for a similar reason). Waiting on the live thread's own queue or fences instead of the whole device may be the way out. That is not tested.

Setup: RX 6800 XT (RDNA2), Mesa 26.3.1, vulkan-validation-layers 1.4.363.1, core, thread-safety and shader checks, errors only.

**@⁠tmalik1116** on GitHub · 2026-12-01 03:10 UTC · [original](https://github.com/vktory6/VKtory/issues/38) **Finding (AGENTS.md rule 29):** `vkDeviceWaitIdle` on the `vkback-live` thread runs at the same time as `vkQueueBindSparse` on umem's `umem-binds` thread. `vkDeviceWaitIdle` requires every queue of the device to be externally synchronized (Vulkan spec, "Threading Behavior"), and the bind thread does not hold off for it. Seen on: 19862d4 (with the present fix from the linked PR, which does not touch these paths). Not seen in the next three validation runs (73ee0ab, with and without that fix): it is timing-dependent. ``` UNASSIGNED-Threading-MultipleThreads-Write vkDeviceWaitIdle(): THREADING ERROR : object of type VkQueue is simultaneously used in current thread "vkback-live" (vkDeviceWaitIdle) and thread "umem-binds" (vkQueueBindSparse) ``` **Where (73ee0ab):** the `device_wait_idle` calls on the live thread are `greenfield/vkback/src/present.rs:308`, `present.rs:837` and `greenfield/vkback/src/lib.rs:4148` (presenter and backend teardown, and swapchain recreate). The binds are `greenfield/umem/src/binds.rs:481` and `binds.rs:490`. **Why it is not a one-line fix:** making the bind thread wait while the device idles could hang. Queued work waits on the binds' timeline values, so the device does not go idle until the binds run (compare `texcheck.rs:20`, where `device_wait_idle` hung for a similar reason). Waiting on the live thread's own queue or fences instead of the whole device may be the way out. That is not tested. **Setup:** RX 6800 XT (RDNA2), Mesa 26.3.1, `vulkan-validation-layers` 1.4.363.1, core, thread-safety and shader checks, errors only.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-01 03:12:36 +00:00
Author
Owner

@⁠vktory6 on GitHub · 2026-12-01 07:34 UTC · original

Thanks! I created a task based on your report: it's on the "Vulkan validation errors" list as a thread-safety line in github.com/vktory6/VKtory@5169307, with your note that making the bind thread wait can hang. The other thread-safety pair (present fence and swapchain) is handled by #39.

**@⁠vktory6** on GitHub · 2026-12-01 07:34 UTC · [original](https://github.com/vktory6/VKtory/issues/38#issuecomment-7304232088) Thanks! I created a task based on your report: it's on the "Vulkan validation errors" list as a thread-safety line in https://github.com/vktory6/VKtory/commit/5169307, with your note that making the bind thread wait can hang. The other thread-safety pair (present fence and swapchain) is handled by #39.
Author
Owner

@⁠vktory6 on GitHub · 2026-12-01 10:36 UTC · original

Fixed by #56 (github.com/vktory6/VKtory@5507c25): teardown now waits on vkback's own queue instead of calling vkDeviceWaitIdle, so it no longer races the bind thread's vkQueueBindSparse. The line is off the validation list (github.com/vktory6/VKtory@7f11798). Closing, thanks!

**@⁠vktory6** on GitHub · 2026-12-01 10:36 UTC · [original](https://github.com/vktory6/VKtory/issues/38#issuecomment-7308441880) Fixed by #56 (https://github.com/vktory6/VKtory/commit/5507c25): teardown now waits on vkback's own queue instead of calling `vkDeviceWaitIdle`, so it no longer races the bind thread's `vkQueueBindSparse`. The line is off the validation list (https://github.com/vktory6/VKtory/commit/7f11798). Closing, thanks!
This discussion has been locked. Commenting is limited to contributors.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/vktory6--VKtory#38
No description provided.