hle(xasync): wait for provider calls on cleanup, scope queue termination, and bound worker pool with shared timer #162
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: launcher
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
run report
security: hold
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs gpu test
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/Androtim--MiniVI!162
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/162/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?
@Androtim on GitHub · 2026-11-29 20:31 UTC · original
Androtim:feat/iter160-xasync-provider-cleanup-bounded-pool→main· +689 −57 · 1 files · 1 commits · closed without merging## Summary
crates/victory-hle/src/modules/xasync.rs):Callbusy: Mutex<(usize, bool)>tracking (Call::run/Call::cleanup) soOP_CLEANUPis deferred until any concurrentOP_DO_WORK,OP_CANCEL, orOP_GET_RESULTreturns, preventing context UAF under concurrent cancel/completion while preservingState::Completing/State::Done(HRESULT)publication before removing completed calls fromCALLS.Queue(weak reference) and track outstanding callbacks from submission until completion/cancellation;XTaskQueueTerminatecancels only that queue's own callbacks across ports, the pool, and delayed timers, respectswait, avoids self-deadlock when called from one of its own callbacks, and invokes the termination callback asynchronously whenwaitis false.2 * cores(min 4) with a 50 ms stall detector so blocked callbacks can still grow the pool without starvation.Test plan
cargo run -p xtask -- policy: passedcargo test -p victory-hle xasync::: passedcargo clippy --workspace --all-targets(default and--features diagnostics) with-D warnings: passed@Androtim on GitHub · 2026-11-29 21:04 UTC · original · edited 2026-11-29 22:05 UTC
Automated triage for the maintainers (not an approval).
Verdict:
needs-work· CI (check):passingReview Summary
The provider cleanup synchronization (
Call::run/Call::cleanup), scoped queue termination (take_tasks/Pool::take_tasks), bounded worker pool with stall detection (Pool), and sharedTimerthread incrates/victory-hle/src/modules/xasync.rsare well-structured and avoid lock-order inversions (queue.delayed->queue.running->port.tasks/POOL.state->TIMER.state).However, there are two concrete bugs in the new asynchronous
XTaskQueueTerminatecompletion path:Async termination callback is silently dropped if the queue handle is closed before running callbacks finish:
Task::queueis aWeak<Queue>(to avoid cycles with undrainedManualports), andQueue::runningstoresOption<(usize, usize)>without holding a strongArc<Queue>.XTaskQueueTerminate(q, false, ctx, Some(cb))while callbacks are still running (running.0 > 0) and then immediately callsXTaskQueueCloseHandle(q)(standard GDK async teardown),Arc::decrement_strong_countdropsQueuebefore the in-flight callbacks return. When those callbacks finish,Task::rungetsNonefromself.queue.upgrade(),Queue::rannever runs, andcbis never invoked.XTaskQueueTerminatehas already drained all queued/delayed tasks before storingrunning.1, retaining a strongArc<Queue>alongside the pending termination callback inrunning.1(released whenQueue::rantakes it atrunning.0 == 0) keepsQueuealive without leaking.Repeated
XTaskQueueTerminateoverwrites a pending termination callback:XTaskQueueTerminate,if running.0 > 0 { running.1 = callback.map(...); }unconditionally overwritesrunning.1. CallingXTaskQueueTerminate(q, false, null, None)(or with a second callback) while callbacks are still draining clobbers and drops a previously registered termination callback.To change the verdict:
Queuealive (e.g., storeArc<Queue>with the pending termination callback inQueue::running) untilQueue::raninvokes the callback, and add a unit test coveringXTaskQueueTerminate(q, false, ctx, Some(cb))followed immediately byXTaskQueueCloseHandle(q)while a callback is in flight.XTaskQueueTerminatecalls (e.g., store pending termination callbacks in aVecor preserve existing callbacks whencallbackisNone).Generated with Antigravity CLI (
agy).@Androtim on GitHub · 2026-12-01 01:38 UTC · original
Closing stale/conflicted backlog PR per #276. Superseded by the active root-architecture replacement pillars with isolated plain --release A/B verification.
Pull request closed