HLE: wait for in-flight monitor callbacks in XTaskQueueUnregisterMonitor #2416
No reviewers
Labels
No labels
AMD
audio
bug
confirmed
crash
cutscene
dlss
documentation
duplicate
enhancement
fixed-on-main
frame-generation
good first issue
help wanted
input
INTEL
invalid
lighting
linux-proton
memory
needs-info
needs-logs
needs-rebase
NVIDIA
performance
pr-diagnostics
pr-docs
pr-feature
pr-fix
pr-performance
pr-refactor
pr-tests
question
RAYTRACING
rendering
report
series-s
shaders
spam
startup
upstream
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/trustno1-coder--VIctory-NVIDIA!2416
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2416"
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?
@fuzeofficlal on GitHub · 2026-11-29 12:51 UTC · original
fuzeofficlal:fix/hle-xtaskqueue-unregister-monitor-sync→main· +422 −11 · 1 files · 1 commits · merged 2026-11-30 14:12 UTCSummary
Ported from
Marvisak/VIctory#3263(9659e3a726).Queue::deliverpreviously clonedself.monitorsout of the mutex and invoked callbacks without tracking active invocations, whileXTaskQueueUnregisterMonitoronly removed the token from the vector and returned immediately. Because callers may free a monitor's context as soon asXTaskQueueUnregisterMonitorreturns, this left two UAF races (an in-flight callback on another thread, and a sibling monitor unregistered mid-notification still invoked from the stale snapshot), plus a token-publish race inXTaskQueueRegisterMonitor.Changes
Queue::monitorswithMonitors { entries: Mutex<Vec<Monitor>>, done: Condvar }incrates/victory-hle/src/modules/xasync.rs:notify()snapshots active tokens (zero-allocation fast path when empty), re-checks registration before each callback, and clears active thread frames via an unwind-safeDropguard.unregister()marks the entry removed, skips blocking on reentrant self-unregister (preventing single- and dual-thread self-deadlock), and otherwise blocks onCondvaruntil every in-flight invocation returns.XTaskQueueRegisterMonitorwrites*tokenbefore registering the entry under the mutex.unregister_monitor_waits_for_in_flight_callbacksandunregister_monitor_skips_unstarted_siblings_and_handles_reentrant_self_unregister.Verification
cargo test --locked -p victory-hle --lib modules::xasync::(plus 5 consecutive stress runs of the new concurrency tests): all passing.cargo test --locked -p victory-hle -- --test-threads=1: all passing.cargo clippy --locked -p victory-hle --all-targets: 0 new warnings.cargo xtask policy --staged: passed.