Skip to content

Commit 1717d91

Browse files
committed
fix(core): drop PendingSubmission's guards in reverse acquisition order
`PendingSubmission` holds a `SnatchGuard` acquired by its caller and a `CommandIndices` write guard acquired later in `Queue::allocate_submission`, but declares them in that same order. Struct fields drop in declaration order, so the older guard was released first. `--cfg wgpu_validate_locks` enforces stack-ordered release, so this trips its assertion on the first submission that goes through this path — which makes the validator unusable on the buffer-mapping path, since `flush_writes_for_buffer` reaches it. Swap the two declarations. No runtime behaviour changes without the cfg; both guards are still released before the struct's other fields.
1 parent 22c5a70 commit 1717d91

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

wgpu-core/src/device/queue.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -638,8 +638,12 @@ impl WebGpuError for QueueSubmitError {
638638
/// [`submit`]: `PendingSubmission::submit`
639639
pub(crate) struct PendingSubmission<'a> {
640640
queue: &'a Queue,
641-
snatch_guard: SnatchGuard<'a>,
641+
// Declared before `snatch_guard` so that it is dropped first. `snatch_guard`
642+
// is acquired by the caller and `command_index_guard` in
643+
// `Queue::allocate_submission`, so releasing in field order would release the
644+
// older guard first — which `--cfg wgpu_validate_locks` rejects.
642645
command_index_guard: RwLockWriteGuard<'a, CommandIndices>,
646+
snatch_guard: SnatchGuard<'a>,
643647
// Command buffers to be executed, along with trackers for the resources they use.
644648
pub executions: Vec<EncoderInFlight>,
645649
// Surface textures referenced by command buffers in this submission. These need to be

0 commit comments

Comments
 (0)