Repository navigation
GPU: hold SHADER_HEAPS while a shader-visible heap is used (port of upstream 628b95d) - #668
Open
coderanonymus wants to merge 2 commits into
Open
coderanonymus wants to merge 2 commits into
coderanonymus wants to merge 2 commits into
Conversation
- indirect.rs: the timing rig kept the written depth view it never reads after setup; drop the field. - draw.rs: the scissor census sorts by a reversed key. - resource.rs: placed_filler_twins is read only by the diagnostics build's copystat; allow it to be dead without the feature, as shadow and pipeline do. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
mirror() previously dropped the SHADER_HEAPS lock inside shader_slot() before using the returned &Heap, allowing a concurrent Heap::drop to free the heap while mirror() accessed it. Also guards copy_simple() against invalid descriptor kinds, rejects placed heaps whose address+size wraps u64, and checks offset+count*bytes in resolve_queries() against overflow (with a regression test). (cherry picked from commit 628b95d) Port notes: the fork's make_waiting() was a second caller of shader_slot(). It now looks the heap up the same way and keeps SHADER_HEAPS held while it reads the slot (view()), and while it makes the host view (heap.host, HostHeap::mirror), so the heap cannot be freed under it either. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codex Review Summary: ❌ FailedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
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.
Port of upstream 628b95d (by Manuel Pérez). It is stacked on #642, which fixes the clippy failure on
main.I left this commit out of #653 because it doesn't build on the fork as it stands. It merges cleanly with #653.
Why
shader_slot()takes theSHADER_HEAPSlock, finds the heap and returns&Heapafter the lock is released. A title that releases a descriptor heap on one thread while another writes a descriptor can therefore haveHeap::dropfree the heap while it is still being read.The fork has a second caller with the same window.
make_waiting()reads the slot (view(handle)) and makes the host view from a heap it no longer holds. The fork's own comment there notes the handle is "read only while its heap is there", but nothing kept the heap there.What
mirror()keepsSHADER_HEAPSlocked for its whole run.copy_simple()returns on an invalid heap kind.create_heaprefuses a placed heap whose address + size wraps.resolve_querieschecksoffset + count * bytesfor overflow, with a test (resolve_queries_rejects_overflowing_offset).make_waiting()finds the heap the same way and keepsSHADER_HEAPSheld while it reads the slot and callsHostHeap::mirror(.., true).shader_slot()is gone.Review
Ultracode-reviewed: three independent read-only reviewers traced the fork's code.
HostHeap::mirrorfor bothfor_drawvalues,wait_for,host_copy, host texture creation andretire. Nothing takesSHADER_HEAPSagain, records a descriptor, or drops a heap.SHADER_HEAPSis taken:submitted,RELEASING, a queue's held lock,list.state. Locks taken under it:pending,made,VIEWS,WAITING,MADE_LATE, resource, shadow and card locks. No path takes the two sets in the opposite order, so the order is acyclic.copy_simple's old behaviour, and the new test needs no host device.The cost is wait time, not deadlock. Descriptor writes on other threads can now wait while a slot's host view is made, which can create a host texture. That's a short wait per slot. The first
Heap::host()on a heap replays its queued writes while holdingpending, so writes to any heap wait once per heap at startup.Verification
cargo clippy --workspace --all-targets --locked -- -D warnings, and the same with--all-features, forx86_64-pc-windows-msvc(cross-checked from Linux): clean.No game data used.
🤖 Generated with Claude Code