fix(core): drop PendingSubmission's guards in reverse acquisition order - #9960
Merged
ErichDonGubler merged 3 commits intoJul 30, 2026
Merged
Conversation
…rder `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.
8 tasks
ErichDonGubler
approved these changes
Jul 30, 2026
ErichDonGubler
left a comment
Member
There was a problem hiding this comment.
Approved, conditional on current changes requested already being implemented. I'm leaving this open so you have a chance to object or suggest alternatives for the minor thing I wanted to see changed.
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.
Connections
wgpu_validate_locksin CI contains this same field swap, plus rank-graph changes addressing the remaining violation noted below. This PR is a small landable subset of it.PendingSubmissionwith this field order.DropGuardsto the end of their parent structs. #8353 — prior fix of the same declaration-order/drop-order class inwgpu-hal.Description
PendingSubmissionholds aSnatchGuardacquired by its caller and aCommandIndiceswrite guard acquired later, insideQueue::allocate_submission— but declares them in that same order. Struct fields drop in declaration order, so the guard acquired first is released first.--cfg wgpu_validate_locksenforces stack-ordered release, so this fires on any submission reaching that path:Swapping the two declarations makes the release order match the acquisition order. Without the cfg there is no behavioural change — both guards are still released before the struct's other fields, and neither is observed in between.
Testing
With
RUSTFLAGS="--cfg wgpu_validate_locks",cargo test -p wgpu-test --test wgpu-validation -- api::buffer_mapping:10 passed.Without the cfg,
cargo test -p wgpu-core --all-features(65 pass) andcargo xtask test bufferare unaffected.This does not make the whole suite pass under the validator. At least one unrelated violation remains on trunk — a rank ordering error rather than a release-order one:
which still aborts the command-buffer tests. I have not investigated that one; it needs either a declared rank edge or a narrower guard scope, and I did not want to guess which.
Worth noting that nothing in CI or
xtaskpasses--cfg wgpu_validate_locks, which is presumably how both of these accumulated.Squash or Rebase?
Single commit; ready to rebase.
Checklist
wgpumay be affected behaviorally.CHANGELOG.mdentries for the user-facing effects of this change are present.