-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix deadlock between snatchable_lock and trackers in Queue::write_texture #7004
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Its actually not completely fixing the issue mentioned. Just one occurrence that I ran into. |
I just noticed another easy-to-fix deadlock. I will add another commit soon. (Sorry) |
I am not sure how feasible it is but I would suggest adding some internal documentation that exactly specifies in which order locks should be acquired if you need multiple. Like it was done for snatchable_lock at wgpu-core/src/device/resource.rs:88 The ordering that I detected from reading code that references the mutexes: |
This should be defined by https://github.com/gfx-rs/wgpu/blob/trunk/wgpu-core/src/lock/rank.rs - I'm not sure what the current status of mutex rank checking. |
- reimplement LAYERWAIT - fix for_layer_in_range to use inclusive [x; y] ranges instead of semi-internvals [x; y) - fix SEWAIT racing with the first set of the status by the audio loop - add deadlock detection to catch the elusive deadlock in wgpu (though it's probably fixed by gfx-rs/wgpu#7004) - fix yet another dynamic buffer-related crash
- reimplement LAYERWAIT - fix for_layer_in_range to use inclusive [x; y] ranges instead of semi-internvals [x; y) - fix SEWAIT racing with the first set of the status by the audio loop - add deadlock detection to catch the elusive deadlock in wgpu (though it's probably fixed by gfx-rs/wgpu#7004) - fix yet another dynamic buffer-related crash
Would it be possible to backport this as 24.0.x bugfix release? I am reproducing this deadlock quite reliably in my engine :(. In my case it's between |
If you could backport it (make a PR against the v24 branch) , we'll be doing a release next week and can release it |
…ture (gfx-rs#7004) * Fix deadlock between snatchable_lock and trackers in Queue::write_texture * Fix another deadlock in write_texture between pending_writes and snatchable_lock. # Conflicts: # CHANGELOG.md
…ture (#7004) * Fix deadlock between snatchable_lock and trackers in Queue::write_texture * Fix another deadlock in write_texture between pending_writes and snatchable_lock. # Conflicts: # CHANGELOG.md
…ture (#7004) * Fix deadlock between snatchable_lock and trackers in Queue::write_texture * Fix another deadlock in write_texture between pending_writes and snatchable_lock. # Conflicts: # CHANGELOG.md
Connections
Related to #5737
Description
The
Device.snatchable_lock
is usually acquired beforeDevice.trackers
is. OnlyQueue.write_texture()
acquired them in reverse order, introducing deadlocks. This PR swaps the order there to align with other usages of those mutexes.Testing
Manually checked all references to trackers mutex for snatchable_lock guards in the same scope.
Checklist
cargo fmt
.taplo format
.cargo clippy
. If applicable, add:--target wasm32-unknown-unknown
--target wasm32-unknown-emscripten
cargo xtask test
to run tests. (Some tests failed here, but those fail without my change too)CHANGELOG.md
. See simple instructions inside file.