XAsync: cleanup waits for provider calls under way; XTaskQueueTerminate honours wait and cancels only its own (part of #228) #244
No reviewers
Labels
No labels
accessibility
already-solved
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
merged
needs-decision
needs-game-run
needs-rebase
not-merged
nvidia
obsolete
question
security
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/avatarmanz--VIctory-7900XTX!244
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-244"
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?
@sharan104 on GitHub · 2026-11-26 12:32 UTC · original
sharan104:fix/xasync-cancel-races→main· +366 −26 · 1 files · 1 commits · openPart of #228. It fixes the two race items in the issue and leaves the two design items open (listed below).
It builds on main and doesn't overlap #229's #214 fix (
db23fd1,pending_with).git merge-treecombines the two without conflicts.Cleanup while
DoWork/Cancelruns. A cancel or complete on one thread could release a call while its provider'sDoWorkorCancelwas still running on another. The provider's cleanup, which frees its context, then ran underneath them. Now:releasemarks the call. If nothing is running, it cleans up at once; otherwise the last operation to return runs the cleanup.XTaskQueueTerminateignoredwait. It called the termination callback straight away. Callbacks already running, or waiting in the shared pool, still ran after it, and draining a port cancelled the callbacks of every composite queue sharing that port. Now:waitit blocks until then; without it, the last callback to return calls the termination callback.waitfrom inside one of the same queue's own callbacks doesn't block. Blocking there would deadlock, where main simply ignoredwait. A per-thread stack of running queues detects the case, and it handles nested Immediate-port callbacks.Tests (deterministic: channels, no sleeps):
cleanup_waits_for_work_under_wayterminate_completes_once_running_callbacks_return(with and withoutwait)terminate_leaves_other_queues_on_the_port_aloneterminate_waiting_from_its_own_callback_returns(with the guard switched off it fails after 10 s, instead of hanging)Results:
cargo test -p victory-hle --locked: 159 passed, 0 failed, 2 ignored.--all-features --test-threads=1.cargo clippy -p victory-hle --all-targets --locked --no-deps -- -D warningsis clean, with and without--all-features. Workspace Clippy on main also fails onwatch.rs:3205, which #241 fixes.Left open in #228:
complete_callstill runs an immediate cleanup under the call's lock. Moving it out means cleanup could run after the title has freed the block.For review:
🤖 Generated with Claude Code
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.