XTaskQueue: terminating a composite spares the base queue's tasks #382
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/fxceless--victory-fork!382
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/382/head"
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?
@JordanFableFur on GitHub · 2026-11-25 00:12 UTC · original
JordanFableFur:fix/composite-terminate-keeps-base-tasks→main· +99 −9 · 1 files · 2 commits · closed without mergingWhat
A port shared by two queues (a composite queue's ports are the base queue's own) drained everything when one of them terminated: the base queue's pending callbacks ran with
canceled=true, and a dispatch of the base queue had nothing left to run. The queues using a port have independent lifetimes (XTaskQueue.h: terminating one must not cancel what belongs to another).Each task now carries the submitting queue's identity.
XTaskQueueTerminateonly cancels that queue's own tasks; the others keep their FIFO place and run uncanceled. Cancellation callbacks now run outside the port locks (they may submit again or take locks). Tasks still delayed (their own thread sleeping before delivery) are issue #198's case and are not covered here; this fixes what is already in the shared port.Fixes #243.
Testing
A regression creates a manual base queue and a composite over its ports, submits one immediate callback on each, terminates the composite, then dispatches the base queue: the composite's callback was cancelled at once, the base's stays queued and runs with
canceled=falseon the base queue. The existing terminate test is unchanged and passes.Validated on Windows CI (fork-run of the repository workflow): clippy both builds and the full test suite pass: https://github.com/JordanFableFur/victory-fork/actions/runs/45513602357
AI use: written with Codex and Claude Code (GPT-5.2 Codex); reviewed and posted with my approval. No game files were used.
@chatgpt-codex-connector[bot] on GitHub · 2026-11-25 00:12 UTC · original · edited 2026-11-25 00:17 UTC
Codex Review Summary: ✅ Completed
This comment shows the latest Codex review activity on this pull request.
9ce1c19ℹ️ About Codex in GitHub
Your 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.
@JordanFableFur on GitHub · 2026-11-25 00:32 UTC · original
Addressed in
75258c0: the partition happens under each port's mutex — this queue's tasks come out, the others keep their FIFO place in the deque — and the cancellation callbacks run afterwards, outside the lock. A nested terminate (or a concurrent one) now sees the other queues' tasks in place, and a callback's submits queue behind them.@kaayzouee on GitHub · 2026-11-25 01:19 UTC · original
Duplicate of #296?
@JordanFableFur on GitHub · 2026-11-25 01:46 UTC · original
Closing — #296 fixes the same issue (#243) and was opened first, including the partition under the port lock so a cancellation callback cannot miss the other queues' tasks. Thanks for flagging.
@chatgpt-codex-connector[bot] on GitHub · 2026-11-25 00:17 UTC · original
On
crates/victory-hle/src/modules/xasync.rsline 421 (outdated):When a composite's cancellation callback terminates the base queue, an earlier base task is already hidden in
others. The nestedXTaskQueueTerminate(base, true, ...)therefore returns without canceling that task, and this loop subsequently restores it; a later base dispatch invokes it withcanceled=false, potentially after termination cleanup has released its context. Concurrent terminations have the same race. Even a cancellation callback that merely submits new base work causes that work to overtake the older buffered tasks. Partition each port's deque under its mutex, leaving non-owned tasks queued before invoking the extracted cancellation callbacks.Useful? React with 👍 / 👎.
Pull request closed