HLE: XTaskQueueTerminate cancels other queues' queued tasks on shared ports (fix on a fork) #1637
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#1637
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
@AndyLatimer on GitHub · 2026-11-24 20:15 UTC · original
Summary
XTaskQueueTerminateincrates/victory-hle/src/modules/xasync.rsdrainsport.tasksunconditionally for both ports of the terminated queue:When multiple queues share a
PortviaXTaskQueueGetPort+XTaskQueueCreateComposite(manual or serialized ports, including composite queues that map bothWORKandCOMPLETIONto the same shared port), terminating one queue steals and cancels every queued callback and pendingXAsyncwork item submitted through other still-open queues on that port.This also leaves a race window between
Queue::submitcheckingself.terminatedandPort::submitlockingport.tasks, where a task from a queue being terminated concurrently could still be pushed onto a shared port afterXTaskQueueTerminatealready drained it.Per Microsoft's GDK
XTaskQueuesemantics (as implemented inmicrosoft/libHttpClient'sTaskQueuePortImpl::CancelPendingEntries/IsCallCanceled), queued entries belong to the submitting queue's port context: terminating one queue cancels only its own pending entries and leaves other queues' entries untouched on the shared port.Fix on a fork
AndyLatimer/VIctory@fix/hle-xtaskqueue-terminate-shared-ports(based onmain@ffe310e)47e61a2What the commit changes in
crates/victory-hle/src/modules/xasync.rs:Queuea monotonicid: u64(NEXT_QUEUE), shared across duplicated handles (XTaskQueueDuplicateHandle) and distinct for composite queues (XTaskQueueCreateComposite).Port::taskswith(owner_id, Task).Port::take_owned(owner)to remove and return only tasks submitted through the terminating queue in FIFO order, preserving other queues' queued tasks in FIFO order.queue.terminatedunderport.tasksinsidePort::submitso a task racing withXTaskQueueTerminateis canceled instead of being enqueued after the drain.XAsyncRuncalls across composite queues.Verification
Before fix (
ffe310e+ new tests)bcanceled all 8 queued tasks acrossa,a_dup,b, andc([(1, true), (2, true), (3, true), (4, true), (5, true), (6, true), (10, true), (11, true)]instead of[(2, true), (5, true), (11, true)]).bcanceleda's queued callbacks ([(1, true), (2, true), (3, true)]instead of[(2, true)]).XAsyncRunon shared port: terminatingbaborteda's pending async call (E_ABORTinstead ofE_PENDING).After fix (
47e61a2)cargo test -p victory-hle:97 passed; 0 failed(lib) +1 passed; 0 failed(no_dll_planting)cargo clippy -p victory-hle --all-targets -- -D warnings: pass (0 warnings)cargo check -p victory --features diagnostics: passrustfmt --edition 2024 --check crates/victory-hle/src/modules/xasync.rs: 0 diffs on touched lines (only pre-existing untouched lines fromorigin/main)cargo xtask policy:asset policy: 154 files okDisclosures
@CaravelaLabs on GitHub · 2026-11-25 00:10 UTC · original
@AndyLatimer this is still on main
70564ae. Terminate has not changed sinceffe310e.Two manual queues, the second a composite on the first's ports. A callback is already queued on the first. Terminating the second runs that callback as canceled (stored 2, wanted 0 still queued). Nothing is left to dispatch. Wine 11.22. This is the queue code, not the GPU.
The test already on main waits until a callback has run, then terminates the other queue, then submits a new one. It never leaves a callback queued across that terminate, so it still passes:
github.com/Marvisak/VIctory@70564ae08c/crates/victory-hle/src/modules/xasync.rs (L1450-L1459)Terminate still drains every task on both ports:
github.com/Marvisak/VIctory@70564ae08c/crates/victory-hle/src/modules/xasync.rs (L384-L392)@Calvix2k's #1673 ports your fork commit and is still open. I did not re-run that head. @avt0m4t48 already ran
dda166c8and reported a separate serialized-completion case there. I have not checked that one.I did not run a title. AI-assisted; tests run on this machine.
@Calvix2k on GitHub · 2026-11-25 00:41 UTC · original
Rebased #1673 onto current main (
4118f33) and pushed. Conflict was only the doc comment plus a test added on main in the same place; the resolution keeps both tests:Validation on Windows 10 x64 (Ryzen 7 5800X, RX 7800 XT): cargo test -p victory-hle --locked xasync → 15 passed; cargo clippy -p victory-hle --all-targets --all-features --locked -- -D warnings clean; cargo xtask policy 182 files ok. No title run needed for the port semantics. PR is mergeable again.
@Marvisak on GitHub · 2026-11-25 12:51 UTC · original
Automated triage for the maintainers.
Confirmed on
main(940d32f):XTaskQueueTerminateincrates/victory-hle/src/modules/xasync.rsdrains every task from each of the queue's ports (lock(&port.tasks).drain(..)) and runs them as canceled, without checking which queue submitted them, so a queue sharing a port (viaXTaskQueueGetPort+XTaskQueueCreateComposite) loses its queued callbacks when another queue on that port is terminated.Open PR #1673 carries the fork commit, rebased onto
main, and keeps the existing delayed-callback test; a separate serialized-completion case was reported in that PR's review.Generated by Claude Code