XTaskQueue: terminating a queue cancels its delayed callbacks too #132
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!132
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/132/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?
@Dufftwt on GitHub · 2026-11-24 00:49 UTC · original
Dufftwt:fix/terminate-cancels-delayed-callbacks→main· +54 −9 · 1 files · 1 commits · merged 2026-11-25 00:07 UTCWhat's wrong
XTaskQueueSubmitDelayedCallbacklets a title queue a callback to run after a delay. Inxasync.rs, the delayed callback waits on a thread of its own and is handed to the queue when the delay runs out.XTaskQueueTerminateis supposed to cancel everything still pending on the queue: each pending callback runs once withcanceled = true, and only then does the termination callback fire. It only cancels what is already sitting in the queue's ports. A delayed callback still waiting out its delay is missed. When its delay runs out, it is delivered and runs as normal, live work:A title typically frees whatever its callbacks use in the termination callback, or right after it. So that late callback can run against freed memory or a shut-down subsystem. At best it does work for a queue that no longer exists.
What the fix does
delayed, in submission order) until their delay runs out.XTaskQueueTerminatecancels those along with the queued ones, before it calls the termination callback.XTaskQueueTerminatere-checksterminatedwhile it holds the list's lock. A callback is therefore always either canceled with the others or refused withE_ABORT, never lost or run late.How it behaves after the fix
canceled = true), before the termination callback, and they never run again afterwards.Tests
The new test
terminate_cancels_delayed_callbacksinxasync.rssubmits a callback with a 50 ms delay and terminates the queue. It checks that the callback was canceled before the termination callback ran. It then waits 200 ms and checks that the callback did not run again.I ran
cargo test --workspace --no-fail-faston GitHub'swindows-latestwith Rust 1.98.1 fromrust-toolchain.toml:victory-hlehas 82 passed and 0 failed.main: it fails. The callback was never canceled, and only the termination callback ran (left: ["terminated"],right: ["canceled", "terminated"]).victory-gpu'sroot::tests::host_serialized_blobs_create_root_signatures. It fails the same way on themainthis branch starts from, and #36, now merged, fixes it.Not tested: a run of the game itself.
Related: #114 and #122 also change
xasync.rs, in other functions. They don't depend on each other. #114 adds its test at the end of the same test module as this one, so whichever lands second may need a one-line rebase there.@jeremygold02 on GitHub · 2026-11-24 04:31 UTC · original
Tested head
b9ff219826e61ba6306f6a1378b613319f70da47withcargo test -p victory-hle --lib xasync -- --test-threads=1: 6 passed, 0 failed (76 unrelated library tests filtered out). The relevant testsmodules::xasync::tests::terminate_cancels_delayed_callbacksandterminate_cancels_what_is_queuedpass; they cover delayed and already-queued callbacks when a queue is terminated (xasync.rs). This is synthetic unit coverage, not a title runtime test.