HLE: XTaskQueueTerminate cancels only its own tasks on shared ports #1673
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!1673
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1673"
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?
@Calvix2k on GitHub · 2026-11-24 20:40 UTC · original
Calvix2k:codex/hle-xtaskqueue-shared-ports-1637→main· +600 −15 · 2 files · 3 commits · openFixes #1637.
Ports the verified fix from @AndyLatimer's fork (commit 47e61a2 by Manuel Pérez), applied unchanged onto
ffe310e; the commit keeps its original author.Summary
XTaskQueueTerminatedrained every port unconditionally, so terminating one queue cancelled the queued callbacks and pendingXAsyncwork of every other queue sharing that port (manual, serialized, or composite queues mapping both ports to one shared port).Queuegets a monotonic id, shared acrossXTaskQueueDuplicateHandleand distinct for composite queues.Port::take_ownedremoves only the terminating queue's tasks, keeping other queues' order.Port::submitre-checksqueue.terminatedunder the port lock, so a task racing with termination is cancelled instead of enqueued after the drain.Tests
Three new synthetic tests (also in the commit): shared manual port with duplicate handles and a composite queue on one port, shared serialized port, and pending
XAsyncRuncalls across composite queues. All pass with the fix and fail before it.Validation
cargo test -p victory-hle --locked -- --test-threads=1— passed (97 unit tests and 1 integration test).cargo clippy -p victory-hle --all-targets --all-features --locked -- -D warnings— passed.cargo xtask policy— passed (154 files).rustfmt --edition 2024 --checkon the file reports only pre-existing hunks in untouched code.@avt0m4t48 on GitHub · 2026-11-24 22:38 UTC · original
I independently tested exact head
dda166c8with a source-built public queue API fixture. It preserves sibling FIFO and reproduces the reviewed manual reentrant case. A separate serialized-worker control also runs the terminating owner's already queued completion withcanceled=falsewhere the owner state expects true.A follow-up that carries the submitting queue's cancellation state into both dispatch paths passed all 13 isolated Linux tests, including the three API cases, which also passed 25 repeats. The exact PR plus follow-up passed Windows-target checks for
victory-hleandvictory-gputests withblake3/pure. Windows runtime was outside these checks. Tested follow-up with API fixturesAI-assisted using Codex.
@AgneyaK on GitHub · 2026-11-25 02:17 UTC · original
Verified locally: merged
0ef707eontomain940d32f(clean), Windows 11 26300, Rust 1.98.1 MSVC.main'sxasync.rs, all three fail:terminate_on_shared_manual_port_only_cancels_its_own_tasks,terminate_on_shared_serialized_port_keeps_other_queues_tasks, andterminate_composite_queue_preserves_other_queues_async_calls(left: -2147467260(E_ABORT),right: -2147483638(E_PENDING)). With the PR they pass.cargo test -p victory-hle --lib -- xasync10 runs in a row, 15 of 15 every time.cargo clippy -p victory-hle --all-targets --locked -- -D warnings: clean.a_dupin the test) shares its queue's tasks, as it should.terminatedunder the port lock inPort::submitcloses the submit/terminate race from #1637.take_ownedkeeps both lists in FIFO order.Not tested: the title (this path matters for its shared ports, but I can't run the story load on this machine).
AI use: Claude Code (Claude Opus 5.5) ran the checks and wrote this; the results are from the runs described.
@Marvisak on GitHub · 2026-11-25 03:33 UTC · original · edited 2026-11-25 22:25 UTC
Automated triage for the maintainers.
Needs rebase. This PR no longer merges cleanly into
main:mainhas moved since the last triage, and the branch now conflicts incrates/victory-hle/src/modules/xasync.rs. It will be reviewed again once it is rebased onto currentmain.Previous verdict for this head: merge candidate.
Generated by Claude Code
@Calvix2k on GitHub · 2026-11-25 09:04 UTC · original
@avt0m4t48 Thank you — I folded your follow-up in rather than leaving it beside the PR.
36c7741is your13a01c3("HLE: use submitting queue cancellation at dispatch"), cherry-picked onto this branch with your authorship kept, rebased over the delayed-callback map this branch adds (delayed: Mutex<BTreeMap<u64, Task>>stays).Arc<AtomicBool>(the queue's termination flag) in aPendingTaskinstead of the queue id,take_ownedmatches withArc::ptr_eq, and both dispatch paths (XTaskQueueDispatchand the serialized worker) read the flag at the moment the task runs — so a completion taken from a shared port after its queue was terminated now runs withcanceled = true, which is the control you reported failing.tests/xtaskqueue_shared_ports.rsis in the PR.Verified here (Windows 10 19045):
cargo test -p victory-hle— 146 lib tests pass,xtaskqueue_shared_ports3/3 (serialized_worker_cancels_completion_during_work_port_termination,reentrant_dispatch_uses_the_submitting_queues_cancellation_state,terminating_composite_preserves_original_callbacks_in_fifo_order), clippy-D warningsclean. CI is running on the new head.With that, the serialized-worker control is covered by a test in the PR itself, so the triage's merge-candidate reading now holds for that path too.
@StExpeditus on GitHub · 2026-11-25 09:13 UTC · original
Test report: RTX 5060 Ti (Blackwell), Windows 11 Pro 26200, driver 621.24. Branch at
36c7741.cargo test --workspace --locked --no-fail-fast-> 702 passed, 5 failed, 10 ignored. The failures are the same 5 pre-existing NVIDIA 1M-view-heap-cap failures (also on main; see my reports on #2030 and #1940). Nothing introduced by this PR fails on this machine.@Calvix2k on GitHub · 2026-11-25 16:39 UTC · original
Thanks — the same five NVIDIA heap-cap failures as on
main, and nothing from this PR. Noted on the record.@BaggyALPHA on GitHub · 2026-11-24 21:28 UTC · original · reviewed
The three new shared-port tests passed independently on Windows. A synthetic reentrant-dispatch test found one remaining cancellation case. Two manual queues share their ports. Queue B has a work callback and a completion callback pending, and queue A has a completion callback pending. While B is terminating, its canceled work callback dispatches the shared completion port through A. B's completion then receives canceled=false, and A's completion correctly receives canceled=false.
The termination flag is already set on B when this happens. Port::take drops the submitting queue identity, and XTaskQueueDispatch always supplies false. The dispatcher needs to read the submitting queue's cancellation state when it invokes the callback, including on the serialized worker path. Microsoft's libHttpClient reference implementation does this in DrainOneItem using the entry's port context. Keeping shared cancellation state with the queued entry would let dispatch distinguish the two callbacks.
AI-assisted (Codex). Tested with synthetic callbacks.
@catminou4 on GitHub · 2026-11-24 21:42 UTC · original · reviewed
Static review only: Windows-only code (D3D12/windows_sys/Win32) — nothing compiles or runs on macOS; source review of the diff.
XTaskQueueTerminate now cancels only the terminating queue's own tasks on shared ports: submit() takes an owner id + terminated flag, take_owned() collects only that owner's tasks, and two tests cover manual and serialized shared ports (record/hold extern callbacks log cancellation). Previously terminating one queue could cancel another queue's tasks on the same port — a real correctness fix for shared-port titles.
@andrewpozdnakov7-jpg on GitHub · 2026-11-26 13:31 UTC · original
I resolved the current
xasync.rstest conflict on e02e9ef. The first parent is your exact36c7741, so the original shared-port fix and @avt0m4t48’s follow-up keep their authorship. The second parent is upstream63bcca4. The resolution includes the shared-port regressions and main's test that checks provider cleanup runs with the completion lock released.On Windows, the integrated tree passed all 155 HLE unit tests and all five integration tests. That includes the three shared-port integration cases for FIFO order, reentrant dispatch cancellation, and the serialized worker. Strict HLE Clippy with all features and targets and the asset policy check passed.
The branch fast-forwards from
36c7741. If you fold the integration into another commit, please addCo-authored-by: andrewpozdnakov7-jpg <[email protected]>.AI-assisted with Codex.
@Calvix2k on GitHub · 2026-11-26 18:51 UTC · original
@andrewpozdnakov7-jpg thank you — I took your merge as the branch head (
e02e9ef) unchanged: it keeps our shared-port fix and @avt0m4t48's follow-up, brings main in, andcargo check -p victory-hle --all-targetspasses here on Windows 10. The PR is mergeable again.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.