HLE: with no process task queue, a call given no queue fails with E_NO_TASK_QUEUE #2075
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!2075
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2075"
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?
@0xkn0wh3r3 on GitHub · 2026-11-25 04:23 UTC · original
0xkn0wh3r3:hle/xasync-no-task-queue→main· +345 −40 · 3 files · 3 commits · openThe problem
A title that sets the process task queue to null and then begins an async call with no queue got S_OK, and the call's work then had nowhere to go.
XTaskQueueSetCurrentProcessTaskQueuedocuments that the process queue can be set to null, and that GDK APIs then fail withE_NO_TASK_QUEUE(0x800701AB) when given a null queue. Inxasync.rs, a null queue handle stands for the process queue:XAsyncBegin(andXAsyncRun, and the runtime's own calls begun for the title through it) checked nothing and returned S_OK.XTaskQueueSubmit*,XTaskQueueTerminate,XTaskQueueRegisterMonitorandXAsyncSchedule, which substitute the process queue for a null handle, returnedE_INVALIDARG.Found by the conformance title in #2057, which lists this check as a known divergence.
The fix
XAsyncBeginnow refuses the call withE_NO_TASK_QUEUEbefore touching the block, when its queue is null and there is no process queue.XTaskQueueSubmit*,XTaskQueueTerminate,XTaskQueueRegisterMonitorandXAsyncSchedulereturnE_NO_TASK_QUEUEthere instead ofE_INVALIDARG. A missing callback is stillE_INVALIDARG.Nothing changes while a process queue exists.
Testing
a_null_process_queue_refuses_calls_given_no_queueincrates/victory-hle/tests/no_task_queue.rs. It is a binary of its own: the process queue is process-wide, and the unit tests begin calls with null queues on other threads. With the process queue set to null, it checks thatXAsyncRun,XAsyncBegin, a call the runtime starts for the title, andXTaskQueueSubmitDelayedCallbackfail withE_NO_TASK_QUEUEand that nothing runs. It then checks that a queue of the title's own still works, and that once the process queue is restored a null queue means it again.cargo test -p victory-hle: all pass.cargo clippy -p victory-hle --all-targets: clean.Not covered / Related
XAsyncBegin) also returnsE_NO_TASK_QUEUEfromXAsyncBegin. This one covers the other entry points that stand the process queue in for a null handle, and tests it through the process queue. Whichever merges second resolves the overlap.KNOWNlist (a listed check that passes fails that test).Rebased onto
f3578e3maingained30a5202(#114): the first completion claims a call with an atomic flag (claimed) and runs the provider's cleanup without holding a lock. This branch keeps that. The call'sstage(pending, completed, delivered), which replaced thedoneflag in 8440297, is now set only after the cleanup and after the status is published, asdoneis onmain.XAsyncCancelchecksclaimed, as onmain. Upstream'scleanup_runs_without_the_completion_locknow checksstage.After the rebase:
cargo test -p victory-hlepasses,tests/no_task_queue.rspassed 150 runs in a row with no exit crash, andprocess_queue_changepassed 50.cargo clippy -p victory-hle --all-targetsis clean, and so iscargo xtask policy.@jeremygold02 on GitHub · 2026-11-25 04:29 UTC · original
Triage verdict — Keep the no-queue fix and preserve #503’s queue pinning (
7f53379)Evidence
Checks and limits
Next step
This verification was AI-assisted.
@Dathinel on GitHub · 2026-11-25 04:50 UTC · original
I reproduced the process-default switch raised in the review above. I used two manually dispatched queues, set A as the process default, and started an operation with a null block queue. After begin returned I set B as the process default, dispatched work on A, then polled both completion ports with timeout zero. The block was left untouched. The callback ran exactly once in every run.
940d32f) and #2075 (7f53379)ffe310e)4371039)That makes queue retention a separate behavior worth preserving when reconciling the two patches. The switch predates #2075. Microsoft's public libHttpClient implementation also stores the resolved process queue and uses it for completion. These were synthetic Windows HLE tests, one run per revision. AI-assisted.
@0xkn0wh3r3 on GitHub · 2026-11-25 06:02 UTC · original
Thanks @jeremygold02 and @Dathinel, and thanks for the reproduction table and the libHttpClient pointer.
b6e635ckeeps the queue a call resolves atXAsyncBegin, the block's own or the process queue at that moment. The call's work and completion both use that queue, which also stays alive for the length of the call. That matches libHttpClient'sAsyncLib.cppand #503's queue pinning.The new test
process_queue_change(its own binary, since the process queue is process-wide) is your scenario. It begins with no queue while A is the process queue, sets B in flight, and checks that work and completion arrive on A and nothing on B. On the previous head it fails with the completion on B, as you measured. With this, the two patches agree on refusing at begin and on keeping the queue, so whichever lands second should rebase cleanly. Removing the matching known divergence in #2057 still applies.@Marvisak on GitHub · 2026-11-25 10:28 UTC · original · edited 2026-11-26 01:24 UTC
Automated triage for the maintainers.
Merge candidate (kept). The new head is a rebase onto
mainafter #114. I checked how it combines with that change incrates/victory-hle/src/modules/xasync.rs:complete_callstill claims the call throughclaimedand runsrelease(the provider's cleanup) with no lock held. The block goes intoCOMPLETINGbeforerelease, sowaited(which locksCALLS, thenCOMPLETING) can't miss it, andstageis set only after the status is published.XAsyncCancelchecksclaimed, as onmain.cleanup_runs_without_the_completion_locknow checksstage.XAsyncBegin, and the wait that lasts until the completion routine has returned are unchanged from the last review.queue()returnsNoneonly for a null handle with no process queue, so the newE_NO_TASK_QUEUEreturns don't affect bad non-null handles.The overlap with #503 still needs the maintainer to pick one, and #2057's
KNOWNlist loses its no-queue entry when this lands.CI: passing (
check).Generated by Claude Code
@0xkn0wh3r3 on GitHub · 2026-11-25 19:03 UTC · original
One more fix, 8440297, found by checking this branch against current
main.tests/no_task_queue.rssometimes crashed at exit (2 of 200 runs, access violation). The cause is in the runtime, not the test.XAsyncGetStatus(block, wait=true)returned as soon as the result was stored, while the completion routine was still queued, and the queued task then read(*block).callbackfrom the block. A title that waits and then frees the block, like the test's stack block, leaves that task reading freed memory.libHttpClient's
AsyncLib.cppsignals the wait only after the routine returns (CompletionCallbackcallsasyncBlock->callback, thenSignalWait). It now does the same here:New test
a_wait_lasts_until_the_completion_routine_has_run.no_task_queuenow asserts that the routine ran before the wait returned. Before the fix that assertion failed in 200 of 200 runs; after it, the test has 0 failures in 700 runs andprocess_queue_change0 in 400.cargo test -p victory-hle, clippy and policy pass.@catminou4 on GitHub · 2026-11-25 04:26 UTC · original · reviewed
Static review only: victory-hle is Windows-only — nothing compiles or runs on macOS; source review of the diff.
No process task queue + no queue arg → proper failure — HLE task-queue edge case; defensive fix.
@DenRakEiw on GitHub · 2026-11-25 04:41 UTC · original · approved these changes
Verified locally merged onto
origin/main(940d32f, Windows 11 x64, Rust 1.98.1 MSVC):cargo test -p victory-hle --test no_task_queue— 1 passed, 0 failedcargo clippy -p victory-hle --all-targets— 0 warningscargo xtask policy— ok (184 files ok)Clean
E_NO_TASK_QUEUEhandling when no process task queue is configured, verified by dedicated integration test. Looks good.AI-assisted (Gemini 4 Neon).
@fuzeofficlal on GitHub · 2026-11-26 19:11 UTC · original · approved these changes
Reviewed
c0b4ea14553fmerged cleanly onto63bcca43.The changes in
crates/victory-hle/src/modules/xasync.rsand the two isolated integration binaries cleanly cover all three behaviors:E_NO_TASK_QUEUE(0x8007_01AB) when no process queue is set (xasync.rs:39,392,406,438,653):XAsyncBegin(andXAsyncRun/finished),XTaskQueueSubmitDelayedCallback,XTaskQueueTerminate, andXTaskQueueRegisterMonitorall fail withE_NO_TASK_QUEUEwhen given a null queue and no process queue exists, before mutatingAsyncBlockstatus or inserting intoCALLS.xasync.rs:527,653-664,701,790): Capturing the resolvedArc<Queue>onCallatXAsyncBeginensures changing the process default queue while a call is in flight does not redirect its work or completion port.xasync.rs:504-592,732-805): MovingCallthroughStage::{Pending, Completed, Delivered}withCOMPLETING(populated beforerelease(block)and queried underCALLSinwaited()) and the thread-localDELIVERINGguard preventsXAsyncGetStatus(block, true)from returning before the completion callback finishes (fixing stack-block UAF on return) without deadlocking when the callback itself callsXAsyncGetStatus(block, true). Lock acquisition order (CALLS -> COMPLETING, never nested in reverse) is deadlock-free, andXTaskQueueTerminatedrains pending tasks withtask.run(true)sodelivered()still runs and unblocks waiters.Verification (native Windows 11):
cargo xtask policyandcargo clippy --locked -p victory-hle --all-targets -- -D warnings(default and--all-features) pass cleanly.cargo test --locked -p victory-hle --lib xasync::(14/14),--test no_task_queue(20 consecutive runs, 0 failures), and--test process_queue_changeall pass.mode = 1) async calls whose callback callsXAsyncGetStatus(b, true)with immediate stack-allocatedAsyncBlockdrop right after the waiter returns (300/300 callback-before-return, zero crashes), plusXTaskQueueTerminatewhile a completion callback is pending on a manual port with another thread blocked inXAsyncGetStatus(block, true)(confirming termination runs the pending completion and unblocks the waiter cleanly).LGTM.
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.