HLE: keep async status waits attached through provider cleanup #3195
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!3195
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3195"
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?
@andrewpozdnakov7-jpg on GitHub · 2026-11-26 11:56 UTC · original
andrewpozdnakov7-jpg:codex2/xasync-wait-cleanup→main· +76 −3 · 1 files · 1 commits · openProblem
XAsyncGetStatus(block, true)can returnE_PENDINGfor a call that is already inside provider cleanup. Completion removes the call from the registry before cleanup, then publishes the final status when cleanup returns. A waiter arriving in that interval finds nothing to wait on. XAsyncGetStatus contractKeep the call registered while the provider cleans up. Remove it and publish its final status under the registry lock. Cleanup still runs before status publication and outside both locks, as in #114.
Verification
The same synthetic provider pauses inside cleanup on main
63bcca43and on this branch. Each trial includes a zero-payload success and a cancellation.E_PENDINGreturned earlyS_OKE_PENDINGreturned earlyE_ABORTA nonblocking poll reports
E_PENDINGwhile cleanup is paused in both builds. Main failed 10/10 trials. The patch passed 10/10, with both outcomes checked in every trial. Full HLE library tests passed 153/153 in both configurations, including the cleanup-lock regression from #114. Strict HLE Clippy and the repository asset policy passed.Coordination claim
AI-assisted with Codex.
@cloph-dsp on GitHub · 2026-11-26 12:12 UTC · original
Independent local verification of head
c079fabon Windows 11, Rust 1.100.0/MSVC:cargo test --locked -p victory-hle --lib -- --exact modules::xasync::tests::waiting_status_follows_payload_free_cleanup— 1 passed, 0 failed.git diff --check origin/main HEAD— clean.CPU-only synthetic thread/payload scenario; no D3D12 device or game data used. Worktree-local
CARGO_TARGET_DIR. AI-assisted (Hy4 flash).@AurumCarlos on GitHub · 2026-11-26 12:33 UTC · original · reviewed
The race is real and the fix closes it. I read it against
release,call,XAsyncBeginandXAsyncGetStatusonmain:main,releaseremoves the call fromCALLSbeforeOP_CLEANUP, and the status is published only after cleanup returns. A blockingXAsyncGetStatusin between finds no call and returns the still-E_PENDINGstatus.size/statushappen under theCALLSlock, so a waiter either finds the call and blocks ondone, or finds it gone and reads the final status. Cleanup still runs with no lock held, so the #114 case (cleanup_runs_without_the_completion_lock) keeps working.XAsyncBeginon the same block is rejected whiledoneis still false, so no new call can be filed at that address before the unconditionalcalls.remove(&(block as usize)). The removal can't drop someone else's call.Two small points:
1. A new constraint on providers, worth writing down. Since the call is now registered while
OP_CLEANUPruns, a provider whose cleanup callsXAsyncGetStatus(block, true)on its own block would now block forever, becausedoneis only set after cleanup returns. Onmain, it gotE_PENDINGstraight away. The in-tree cleanups only drop their boxed state (finished_with, and the one at L856), so nothing hits this today. A line in the comment would keep a future provider from tripping on it, e.g. "cleanup must not wait on its own block". If you want the removal to be robust on its own rather than relying onXAsyncBegin'sdonecheck, you could also guard it withArc::ptr_eq, the wayis_currentdoes.2. Nit: the
eprintln!in the test. It looks like it was left over from investigating, since theassert_eq!onoutcomesalready prints all four values when it fails. Also, the 250 msrecv_timeoutcan only make a slow runner pass falsely (an early return that arrives late), never fail falsely, so the test shouldn't be flaky. 👍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.