gdk rt: XAsync return codes match the reference (6 conformance scenarios) #266

Closed
github-bot wants to merge 1 commit from gh-pr/266/head into gh-pr/266/base
Owner

@⁠QuentinDanblon on GitHub · 2026-11-23 08:41 UTC · original
QuentinDanblon:pr/xtq-async-hresults → main · +38 −19 · 3 files · 1 commits · closed without merging

Library / area: compat-common, GDK runtime XAsync (src/gdk/rt.rs), conformance table (tests/gdk_xtaskqueue_conformance.rs)

Exports changed (exports.txt rows): none

Source of the behaviour: libHttpClient Source/Task/AsyncLib.cpp and TaskQueue.cpp at c5007fd9 (MIT): the rules were followed and rewritten in Rust, no code copied. The existing libHttpClient line of THIRD_PARTY/CREDITS now names src/gdk/rt.rs too. The same six scenarios pass against the xgameruntime.dll of Gaming Services on my PC (gdk_xtaskqueue_conformance_real).

Six rows leave the DIFFERS table. Each one was a return code that differed from the reference:

scenario before now, as the reference
verify_global_queue XAsyncBegin with no queue in the block and no process queue returned S_OK returns E_NO_TASK_QUEUE and leaves that status in the block
verify_begin_after_terminate XAsyncBegin on a queue whose termination has started returned S_OK returns E_ABORT
verify_failed_begin_completes a failing Begin op made XAsyncBegin return that failure XAsyncBegin returns S_OK and the call completes with the failure, so the completion callback runs
verify_cant_schedule_twice a second XAsyncSchedule returned S_OK returns E_UNEXPECTED until the worker callback has run
verify_failure_in_do_work DoWork returning a success code without XAsyncComplete left the status S_OK the call completes with E_UNEXPECTED
verify_result_buffer_checks XAsyncGetResult with a null buffer returned 0x8007007a returns E_INVALIDARG, checked before the size; XAsyncGetResultSize writes 0 for a pending or failed call

Two side changes these needed:

  • XAsyncRun's provider now calls XAsyncComplete with the result of the work function, as the reference does. Without it, the new E_UNEXPECTED rule would have turned every successful XAsyncRun into a failure.
  • The worker callback only acts on the call it was scheduled for (it compares the state it captured with the state the block has now), so a block reused before a stale worker runs is not completed by it.

What is still different, and not claimed here

  • The E_ABORT of XAsyncBegin reads the queue's terminated flags. The reference gets it from XTaskQueueSuspendTermination, which also holds termination back while the call is in flight. That part is the verify_terminate_waits_for_async_in_flight row, which stays in DIFFERS.
  • XAsyncBegin with a non-zero queue handle that is not a queue is still accepted, as before.
  • XAsyncSchedule on a call whose state is gone returns E_INVALIDARG, as before. The reference returns the call's failure code first when it has one.

Tests

  • cargo test -p compat-common --release --test gdk_xtaskqueue_conformance, on this commit rebased on 6e81ffc: 3 runs, 60 passed each.
  • Before the rebase (base 902209a, the two differ by docs/BLOCKERS.md only) I ran it 6 times while other builds and GPU tests were running on the machine: 4 runs passed, 2 failed.
    • One run failed verify_simple_async_call ("XAsyncGetStatus(wait) returned before the completion callback ran"). That scenario also fails now and then on main without this change: 2 failures in 10 runs on 902209a, on verify_simple_async_call and verify_async_block_reuse.
    • One run took 10.7 s instead of 4 s and failed verify_immediate_dispatch, verify_serialized_queues_do_not_keep_threads and verify_serialized_port_final_release ("a delayed callback on an immediate port never ran"). These three do not use XAsync. I did not see them fail on main, and I did not reproduce the failure. I think it is a timing limit under load, but I have not proven it.
  • gdk_xtaskqueue_conformance_real (the same scenarios against the real xgameruntime.dll): 60 passed.
  • TOMBOX_XTQ_ALL=1 ... -- --test-threads=1 --skip verify_get_async_status_no_deadlock: 43 passed, 16 failed. The 16 are rows still in DIFFERS.
  • cargo test -p compat-common --release --no-fail-fast: lib 125 passed. gdk_multi_dll did not build here (the d3d12_xs build script did not find DXC in that shell), every other integration test passed.
  • pr_gate.py: 0 problems.

verify_register_*, verify_queue_termination and the two verify_shared_port_queue_rundown_* rows (XTaskQueueRegisterWaiter) are being worked on in a separate branch. It touches lines next to these in DIFFERS, so I will rebase it on whatever you merge first.

  • cargo test -p compat-common passes, with the two exceptions written above (one build failure from my environment, one scenario that is already intermittent on main)
  • No game or console files and no binaries included
  • No fake success; anything not possible is left missing with a note

🤖 Generated with Claude Code

**@⁠QuentinDanblon** on GitHub · 2026-11-23 08:41 UTC · [original](https://github.com/omonkeyz/xbox-emulator/pull/266) `QuentinDanblon:pr/xtq-async-hresults` → `main` · +38 −19 · 3 files · 1 commits · closed without merging **Library / area:** `compat-common`, GDK runtime XAsync (`src/gdk/rt.rs`), conformance table (`tests/gdk_xtaskqueue_conformance.rs`) **Exports changed (exports.txt rows):** none **Source of the behaviour:** libHttpClient `Source/Task/AsyncLib.cpp` and `TaskQueue.cpp` at `c5007fd9` (MIT): the rules were followed and rewritten in Rust, no code copied. The existing libHttpClient line of `THIRD_PARTY/CREDITS` now names `src/gdk/rt.rs` too. The same six scenarios pass against the `xgameruntime.dll` of Gaming Services on my PC (`gdk_xtaskqueue_conformance_real`). Six rows leave the `DIFFERS` table. Each one was a return code that differed from the reference: | scenario | before | now, as the reference | |---|---|---| | `verify_global_queue` | `XAsyncBegin` with no queue in the block and no process queue returned S_OK | returns `E_NO_TASK_QUEUE` and leaves that status in the block | | `verify_begin_after_terminate` | `XAsyncBegin` on a queue whose termination has started returned S_OK | returns `E_ABORT` | | `verify_failed_begin_completes` | a failing Begin op made `XAsyncBegin` return that failure | `XAsyncBegin` returns S_OK and the call completes with the failure, so the completion callback runs | | `verify_cant_schedule_twice` | a second `XAsyncSchedule` returned S_OK | returns `E_UNEXPECTED` until the worker callback has run | | `verify_failure_in_do_work` | DoWork returning a success code without `XAsyncComplete` left the status S_OK | the call completes with `E_UNEXPECTED` | | `verify_result_buffer_checks` | `XAsyncGetResult` with a null buffer returned 0x8007007a | returns `E_INVALIDARG`, checked before the size; `XAsyncGetResultSize` writes 0 for a pending or failed call | Two side changes these needed: - `XAsyncRun`'s provider now calls `XAsyncComplete` with the result of the work function, as the reference does. Without it, the new `E_UNEXPECTED` rule would have turned every successful `XAsyncRun` into a failure. - The worker callback only acts on the call it was scheduled for (it compares the state it captured with the state the block has now), so a block reused before a stale worker runs is not completed by it. ### What is still different, and not claimed here - The `E_ABORT` of `XAsyncBegin` reads the queue's terminated flags. The reference gets it from `XTaskQueueSuspendTermination`, which also holds termination back while the call is in flight. That part is the `verify_terminate_waits_for_async_in_flight` row, which stays in `DIFFERS`. - `XAsyncBegin` with a non-zero queue handle that is not a queue is still accepted, as before. - `XAsyncSchedule` on a call whose state is gone returns `E_INVALIDARG`, as before. The reference returns the call's failure code first when it has one. ### Tests - `cargo test -p compat-common --release --test gdk_xtaskqueue_conformance`, on this commit rebased on `6e81ffc`: 3 runs, 60 passed each. - Before the rebase (base `902209a`, the two differ by `docs/BLOCKERS.md` only) I ran it 6 times while other builds and GPU tests were running on the machine: 4 runs passed, 2 failed. - One run failed `verify_simple_async_call` ("XAsyncGetStatus(wait) returned before the completion callback ran"). That scenario also fails now and then on `main` without this change: 2 failures in 10 runs on `902209a`, on `verify_simple_async_call` and `verify_async_block_reuse`. - One run took 10.7 s instead of 4 s and failed `verify_immediate_dispatch`, `verify_serialized_queues_do_not_keep_threads` and `verify_serialized_port_final_release` ("a delayed callback on an immediate port never ran"). These three do not use XAsync. I did not see them fail on `main`, and I did not reproduce the failure. I think it is a timing limit under load, but I have not proven it. - `gdk_xtaskqueue_conformance_real` (the same scenarios against the real `xgameruntime.dll`): 60 passed. - `TOMBOX_XTQ_ALL=1 ... -- --test-threads=1 --skip verify_get_async_status_no_deadlock`: 43 passed, 16 failed. The 16 are rows still in `DIFFERS`. - `cargo test -p compat-common --release --no-fail-fast`: lib 125 passed. `gdk_multi_dll` did not build here (the `d3d12_xs` build script did not find DXC in that shell), every other integration test passed. - `pr_gate.py`: 0 problems. `verify_register_*`, `verify_queue_termination` and the two `verify_shared_port_queue_rundown_*` rows (`XTaskQueueRegisterWaiter`) are being worked on in a separate branch. It touches lines next to these in `DIFFERS`, so I will rebase it on whatever you merge first. - [x] `cargo test -p compat-common` passes, with the two exceptions written above (one build failure from my environment, one scenario that is already intermittent on `main`) - [x] No game or console files and no binaries included - [x] No fake success; anything not possible is left `missing` with a note 🤖 Generated with [Claude Code](https://claude.com/claude-code)
The emulated XAsync now returns the same HRESULTs as Microsoft's
libHttpClient AsyncLib.cpp (MIT), and the six scenarios below are
removed from the DIFFERS table of gdk_xtaskqueue_conformance.

- verify_global_queue: XAsyncBegin on a block with no queue while no
  process queue is set returns E_NO_TASK_QUEUE and leaves that status
  in the block (AllocStateNoCompletion / AllocState).
- verify_begin_after_terminate: XAsyncBegin on a queue whose
  termination has started returns E_ABORT, as
  XTaskQueueSuspendTermination does in AllocStateNoCompletion
  (TaskQueue.cpp SuspendTermination / VerifyNotTerminated).
- verify_failed_begin_completes: when the provider's Begin op fails,
  XAsyncBegin completes the call with that HRESULT and returns S_OK,
  so the completion callback runs (XAsyncBegin).
- verify_cant_schedule_twice: a second XAsyncSchedule before the
  worker callback has run returns E_UNEXPECTED; the flag is cleared
  when the worker runs (XAsyncSchedule workScheduled, WorkerCallback).
  The worker only acts on the call it was scheduled for.
- verify_failure_in_do_work: DoWork returning a success code without
  XAsyncComplete completes the call with E_UNEXPECTED
  (WorkerCallback). XAsyncRun's provider now calls XAsyncComplete with
  the work result itself, as the reference XAsyncRun does.
- verify_result_buffer_checks: XAsyncGetResult with a null buffer for
  a call with a payload returns E_INVALIDARG, checked before the size
  (XAsyncGetResult); XAsyncGetResultSize writes 0 for a pending or
  failed call (XAsyncGetResultSize).

Co-Authored-By: Claude Fable 5.2 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 06:16:32 +00:00
github-bot closed this pull request 2026-11-26 06:16:32 +00:00
Author
Owner

@⁠omonkeyz on GitHub · 2026-11-23 09:41 UTC · original

Applied in 883d1c8 (merged in e3c62b7) with your authorship kept, thanks. It shipped in r32i (377a22a) after a full-boot Trackmania run: sign-in, the offline menu and the race all matched r32h, with no new gdk errors.

**@⁠omonkeyz** on GitHub · 2026-11-23 09:41 UTC · [original](https://github.com/omonkeyz/xbox-emulator/pull/266#issuecomment-7096981444) Applied in 883d1c8 (merged in e3c62b7) with your authorship kept, thanks. It shipped in r32i (377a22a) after a full-boot Trackmania run: sign-in, the offline menu and the race all matched r32h, with no new gdk errors.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.