GPU: keep command queues alive while HELD tracks pending work #3255
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!3255
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3255"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@fuzeofficlal on GitHub · 2026-11-26 14:44 UTC · original
fuzeofficlal:fix/gpu-held-queue-release-uaf→main· +342 −23 · 1 files · 1 commits · openSummary
queue::execute,queue::signal, andqueue::waitpreviously stored raw*const Queueaddresses (this as usize) inHELDwithout retaining a COM reference to the queue object. Under D3D12, a title may legally release anID3D12CommandQueuewhile submitted command lists, signals, or fence waits are still pending. Doing so freedBox<Queue>whileHELDstill tracked items under that address, causing two bugs:pump()(for safety-valve warnings and released-work accounting) andaccount_frame()calledkind(queue)on the freedQueuepointer.account_frame()also dropped theHELDmutex before readingkind(*queue), racing withpump_helddraining and freeing the queue concurrently.ID3D12CommandQueuereused the freedBox<Queue>address, its independent work was queued behind the released queue's blocked wait inHELD, stalling unrelated submissions (including the work meant to unblock the wait).Changes
HELDinHolding { held, pinned }incrates/victory-gpu/src/queue.rs:Holding::pushcallsobject::add_ref(queue)once per distinct queue when itsHELDFIFO becomes non-empty and records its address inpinned.pumptakes theHELDlock guard by value, finishes allkind(queue)reads while drained queues are still pinned, extracts drained queues viaHolding::take_drained(), drops theHELDlock, and then callsrelease(queue)outside the lock (preserving lock ordering without nestingHELD -> PRIVATE).account_frameresolveskind(queue)intou32queue kinds while still holdingHELD.crates/victory-gpu/src/queue.rs:released_queue_holding_work_stays_alive_and_does_not_alias_new_queues(reproduces the UAF + ABA address-reuse deadlock before the fix and verifies clean drain + zero D3D12 debug layer messages after).held_queue_pinning_handles_multiple_items_signals_waits_and_concurrent_accounting(covers single-ref deduplication across multiple lists and heldSignal,Item::FenceWaitpinning/unpinning, and concurrentaccount_framevs.pump_helddrain).Verification
cargo test -p victory-gpu --lockedtargeted queue/hold/fence tests: 20 passed (RTX 5090 default, RTX 5090 +VICTORY_D3D12_DEBUG=1 --features diagnostics --test-threads=1, and WARP +VICTORY_D3D12_DEBUG=1 --features diagnostics --test-threads=1).victory-gpusuite on WARP (VICTORY_D3D12_WARP=1 --features diagnostics --locked): 248 passed, 0 failed, 1 ignored.cargo clippy --workspace --all-targets --locked -- -D warningsand--all-features: clean.cargo test -p xtask --locked policy::tests::repository_passes_policy: passed.@Dukestar69 on GitHub · 2026-11-26 14:47 UTC · original · approved these changes
Reviewed the diff and verified locally on Windows 11 x64 (RTX 5090 + WARP):
eleased_queue_holding_work_stays_alive_and_does_not_alias_new_queues).
Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.