HLE/xasync: wait for running tasks, cancel delayed timers, and scope composite queue termination #584
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!584
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-584"
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?
@AscilCH on GitHub · 2026-11-25 02:35 UTC · original
AscilCH:fix/hle-xtaskqueue-terminate-wait-timers-and-composite→main· +338 −41 · 1 files · 1 commits · openProblem
Three bugs in
XTaskQueuetermination and delayed-callback handling (crates/victory-hle/src/modules/xasync.rs):Queue::submitwithdelay_ms > 0spawned a thread runningthread::sleep(delay)followed by unconditionalqueue.deliver(port, task)without checkingterminated.XTaskQueueTerminatereturned immediately while delayed timers remained armed; when they fired after the title freed callback/monitor contexts, they invoked title callbacks and queue monitors on freed memory.waitparameter inXTaskQueueTerminate:_wait: boolwas ignored, soXTaskQueueTerminate(q, true, ...)invokedterminated_callbackand returned whileThreadPool/Serialized/Manualcallbacks forqwere still executing (UAF when the title destroys contexts right afterXTaskQueueTerminate(q, true, ...)returns).XTaskQueueTerminateranlock(&port.tasks).drain(..)on each port without checking task ownership, canceling tasks belonging to sibling open queues sharing a port created viaXTaskQueueGetPort+XTaskQueueCreateComposite.Fix
Weak<Queue>+queue_id) and drain only matchingqueue_identries from ports andPOOLinXTaskQueueTerminate.QueueState::delayedand sleep on a per-queueCondvar, so termination wakes timer threads immediately and cancels all pending delayed tasks synchronously before returning.running: AtomicUsizecounter (incremented while holding the port/pool lock, decremented inRunningTask::dropwith adoneCondvar) sowait == trueblocks until all in-flight callbacks finish before callingterminated_callback.terminate_cancels_delayed_waits_for_running_and_preserves_composite_siblings.Verification
cargo test -p victory-hle --locked xasync::tests: 8 passed, 0 failedcargo xtask policy: 169 files okcargo clippy -p victory-hle --no-deps --all-targets --locked -- -D warnings: cleancargo clippy -p victory-hle --all-targets --all-features --locked -- -D warnings: clean(AI-assisted; synthetic unit tests only, no game data.)
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.