startup: check XAsync completion on a manual completion port #2162

Merged
Jess-Doit merged 3 commits from upstream-pr/2170 into main 2026-11-25 03:02:50 +00:00
Jess-Doit commented 2026-11-25 02:38:33 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Jess-Doit on 2026-11-25T02:38:33Z.


Refs #870. This is the source-built manual-completion comparison offered here and claimed here.

What it checks

tests/startup_async_manual_completion.cpp starts one synthetic XAsync operation, with an 8-byte payload and no account or application input, on a queue whose work and completion ports are both manual. The provider completes it on another thread. The test prints the four observations separately for each phase:

Phase Begin XAsyncGetStatus(wait=false) and XAsyncGetResultSize Callback count Result consumed
pending (accepted, not completed) printed printed must be 0 no
unpumped (completed, work port dispatched once, completion port not) printed must be 0 (negative control) no
dispatched (one completion-port dispatch) printed must be 1 must match the payload

A second completion-port dispatch must find no work. A second block on an immediate queue is the contrast: its callback runs at completion without any dispatch.

  • system: the installed Windows gaming runtime's XAsync service (073b7dcb, slots 3/4/7/10/11/12/16/17). The runtime's status and result-size answers are printed, not asserted, because those answers are the open pending-versus-undispatched question. The test exits 77 when the runtime or queue is unavailable.
  • controlled: an in-test stand-in that holds a completed block's callback on the manual port.
  • inline_control: the stand-in runs the callback inside XAsyncComplete, as an immediate port would. It must print FAIL: callback ran before the completion port was dispatched.

The test is separate from the runtime proxy and does not change any runtime behaviour.

Results

At 6dd71ab4 (main c118f569 + this commit), Windows 10 build 19045, MSVC dev preset. No GPU is used.

ctest --preset dev --no-tests=error -R '^startup_async_manual_completion_(controlled|system|inline_control)$' -V
controlled:     start begin=0x00000000
                pending    status=0x8000000a result_size=0x8000000a callbacks=0 consumed=no
                unpumped   status=0x00000000 result_size=0x00000000 bytes=8 callbacks=0 consumed=no
                dispatched callbacks=1 consumed=expected, second_dispatch=0
                immediate  callbacks=1 consumed=expected
                PASS: controlled manual completion port
system:         Skipped (77) at 6dd71ab4 before Gaming Services was installed; passes at 7c8b7ad6 (see below)
inline_control: FAIL: callback ran before the completion port was dispatched   -> test passes

At 6dd71ab4: 2 passed, 1 capability skip. At 7c8b7ad6 with the runtime installed: 3 passed. docs_links_check.py, bidi_controls_check.py and git diff --check are clean.

Real runtime: with Gaming Services 39.118.30001.0 installed, system passed. A completed but undispatched block reports S_OK from the non-waiting status call, with an 8-byte result size and 0 callbacks. A pending block reports E_PENDING (0x8000000a). The full table is in this comment.

AI-assisted.

🤖 Generated with Claude Code

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6595919742 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2170). Originally posted by [Jess-Doit](https://github.com/Jess-Doit) on 2026-11-25T02:38:33Z. --- Refs #870. This is the source-built manual-completion comparison [offered here](https://github.com/R0Y00/Xbox2Windows/issues/870#issuecomment-7148975352) and [claimed here](https://github.com/R0Y00/Xbox2Windows/issues/870#issuecomment-7150669021). ## What it checks `tests/startup_async_manual_completion.cpp` starts one synthetic XAsync operation, with an 8-byte payload and no account or application input, on a queue whose work and completion ports are both manual. The provider completes it on another thread. The test prints the four observations separately for each phase: | Phase | Begin | `XAsyncGetStatus(wait=false)` and `XAsyncGetResultSize` | Callback count | Result consumed | |---|---|---|---|---| | `pending` (accepted, not completed) | printed | printed | must be 0 | no | | `unpumped` (completed, work port dispatched once, completion port not) | | printed | **must be 0** (negative control) | no | | `dispatched` (one completion-port dispatch) | | printed | must be 1 | must match the payload | A second completion-port dispatch must find no work. A second block on an immediate queue is the contrast: its callback runs at completion without any dispatch. - **`system`:** the installed Windows gaming runtime's XAsync service (`073b7dcb`, slots 3/4/7/10/11/12/16/17). The runtime's status and result-size answers are printed, not asserted, because those answers are the open pending-versus-undispatched question. The test exits 77 when the runtime or queue is unavailable. - **`controlled`:** an in-test stand-in that holds a completed block's callback on the manual port. - **`inline_control`:** the stand-in runs the callback inside `XAsyncComplete`, as an immediate port would. It must print `FAIL: callback ran before the completion port was dispatched`. The test is separate from the runtime proxy and does not change any runtime behaviour. ## Results At 6dd71ab4 (main c118f569 + this commit), Windows 10 build 19045, MSVC `dev` preset. No GPU is used. ```powershell ctest --preset dev --no-tests=error -R '^startup_async_manual_completion_(controlled|system|inline_control)$' -V ``` ```text controlled: start begin=0x00000000 pending status=0x8000000a result_size=0x8000000a callbacks=0 consumed=no unpumped status=0x00000000 result_size=0x00000000 bytes=8 callbacks=0 consumed=no dispatched callbacks=1 consumed=expected, second_dispatch=0 immediate callbacks=1 consumed=expected PASS: controlled manual completion port system: Skipped (77) at 6dd71ab4 before Gaming Services was installed; passes at 7c8b7ad6 (see below) inline_control: FAIL: callback ran before the completion port was dispatched -> test passes ``` At 6dd71ab4: 2 passed, 1 capability skip. At 7c8b7ad6 with the runtime installed: 3 passed. `docs_links_check.py`, `bidi_controls_check.py` and `git diff --check` are clean. **Real runtime:** with Gaming Services 39.118.30001.0 installed, `system` passed. A completed but undispatched block reports `S_OK` from the non-waiting status call, with an 8-byte result size and 0 callbacks. A pending block reports `E_PENDING` (`0x8000000a`). The full table is in [this comment](https://github.com/R0Y00/Xbox2Windows/pull/2170#issuecomment-7151292759). AI-assisted. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
tedin7 commented 2026-11-25 03:01:17 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T02:43:31Z.

Review: COMMENTED


Review of head 6dd71ab497bf9bbe7264c0d73e1b1d6339acc3f8 (comment only, no approval).

Scope: 3 files, +427 (CMakeLists.txt, docs/startup-runtime.md, tests/startup_async_manual_completion.cpp). Test and docs only. Title is neutral and the PR is mergeable. CI: Linux Python checks, gfx1013 fixtures and Windows build+test are green. The /O2 job and the chart publish were skipped.

Commands executed locally

  • git diff --check origin/main...HEAD: clean.
  • python3 tests/docs_links_check.py: 18 files, 401 links, OK.
  • python3 tests/bidi_controls_check.py: OK.
  • Built the new test with mingw (x86_64-w64-mingw32-g++ -std=c++17 -static -pthread) and ran it under wine:
    • controlled: PASS (callbacks 0 before dispatch, 1 after one dispatch, 0 on the second, payload matches, immediate contrast runs without dispatch).
    • inline-control: prints FAIL: callback ran before the completion port was dispatched, which is exactly what the CMake PASS_REGULAR_EXPRESSION expects.
    • system: exit 77 (no gaming runtime under wine), which matches SKIP_RETURN_CODE 77.
  • Mutation: disabled the two dispatch-count asserts and made the stand-in queue each ready block twice. The test failed with the callback did not retrieve the synthetic payload (callbacks=2, mismatch). The mutation was killed, and I reverted it with git checkout -- ..
  • I did not run the system variant on real Windows. CI's Windows job covers it. The runtime answers are only printed, not asserted, so a Win2025 run adds observation but no new gate.

P1: none.
P2: none.

Nits

  • tests/startup_async_manual_completion.cpp stand-in dispatch: it returns false for the work port, so work_port_dispatched=0 in controlled mode. The comment and doc say "after one work-port dispatch". That is true only for the system variant. Say so in the doc, or make the stand-in model one work item.
  • tests/startup_async_manual_completion.cpp in run(): const auto close = ...; (void)close; is unused (the Queues destructor fetches its own). Remove it.
  • The system PASS only asserts the callback count, the dispatch behaviour and the payload. It never asserts that the runtime's status is E_PENDING before completion, so a runtime quirk there would go unnoticed. This is intentional per the doc, but worth one line saying so.
  • Clean-room: the doc and comments cite public Microsoft Learn pages and one ivall/xcl slot table link. That is fine for an MIT repo, but keep it as a reference link only.

Verdict: the logic is sound, the negative control works and a real mutation is caught.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6051028828 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2170#pullrequestreview-6051028828). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T02:43:31Z. **Review:** COMMENTED --- Review of head `6dd71ab497bf9bbe7264c0d73e1b1d6339acc3f8` (comment only, no approval). **Scope:** 3 files, +427 (CMakeLists.txt, docs/startup-runtime.md, tests/startup_async_manual_completion.cpp). Test and docs only. Title is neutral and the PR is mergeable. CI: Linux Python checks, gfx1013 fixtures and Windows build+test are green. The /O2 job and the chart publish were skipped. **Commands executed locally** - `git diff --check origin/main...HEAD`: clean. - `python3 tests/docs_links_check.py`: 18 files, 401 links, OK. - `python3 tests/bidi_controls_check.py`: OK. - Built the new test with mingw (`x86_64-w64-mingw32-g++ -std=c++17 -static -pthread`) and ran it under wine: - `controlled`: PASS (callbacks 0 before dispatch, 1 after one dispatch, 0 on the second, payload matches, immediate contrast runs without dispatch). - `inline-control`: prints `FAIL: callback ran before the completion port was dispatched`, which is exactly what the CMake `PASS_REGULAR_EXPRESSION` expects. - `system`: exit 77 (no gaming runtime under wine), which matches `SKIP_RETURN_CODE 77`. - Mutation: disabled the two dispatch-count asserts and made the stand-in queue each ready block twice. The test failed with `the callback did not retrieve the synthetic payload` (callbacks=2, mismatch). The mutation was killed, and I reverted it with `git checkout -- .`. - I did not run the `system` variant on real Windows. CI's Windows job covers it. The runtime answers are only printed, not asserted, so a Win2025 run adds observation but no new gate. **P1:** none. **P2:** none. **Nits** - `tests/startup_async_manual_completion.cpp` stand-in `dispatch`: it returns false for the work port, so `work_port_dispatched=0` in controlled mode. The comment and doc say "after one work-port dispatch". That is true only for the system variant. Say so in the doc, or make the stand-in model one work item. - `tests/startup_async_manual_completion.cpp` in `run()`: `const auto close = ...; (void)close;` is unused (the `Queues` destructor fetches its own). Remove it. - The `system` PASS only asserts the callback count, the dispatch behaviour and the payload. It never asserts that the runtime's status is `E_PENDING` before completion, so a runtime quirk there would go unnoticed. This is intentional per the doc, but worth one line saying so. - Clean-room: the doc and comments cite public Microsoft Learn pages and one `ivall/xcl` slot table link. That is fine for an MIT repo, but keep it as a reference link only. Verdict: the logic is sound, the negative control works and a real mutation is caught. AI-assisted; commands listed were executed locally.
Jess-Doit commented 2026-11-25 03:01:24 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Jess-Doit on 2026-11-25T02:52:12Z.


Real-runtime result for the system variant, at 7c8b7ad6. Gaming Services 39.118.30001.0 (xgameruntime.dll 10.0.26100.9656), Windows 10 build 19045. No GPU is used.

ctest --preset dev --no-tests=error -R '^startup_async_manual_completion_(controlled|system|inline_control)$' -V
Phase XAsyncGetStatus(false) XAsyncGetResultSize Callbacks Result consumed
pending 0x8000000a (E_PENDING) 0x8000000a 0 no
complete, completion port not dispatched S_OK S_OK, 8 bytes 0 no
after one completion-port dispatch S_OK S_OK, 0 bytes 1 yes, payload matches

A second completion-port dispatch found no work. The immediate-port contrast ran its callback at completion. 3/3 passed, with no skips: controlled, system and inline_control, which printed its expected FAIL.

What this means for the accepted user-add: on the installed runtime, a non-waiting status call distinguishes the two cases. An operation that is still in progress returns E_PENDING. One that has completed but whose completion port nobody dispatched returns S_OK with its result size available, while its callback count stays 0. So one XAsyncGetStatus(block, false) from the proxy on the accepted block, at the stop, would settle pending versus undispatched without touching the queue.

Follow-up commit: after retrieval the runtime reports a result size of 0, so the stand-in now does the same, and docs/startup-runtime.md records these answers.

Status: ready for review.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7151292759 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2170#issuecomment-7151292759). Originally posted by [Jess-Doit](https://github.com/Jess-Doit) on 2026-11-25T02:52:12Z. --- Real-runtime result for the `system` variant, at 7c8b7ad6. Gaming Services 39.118.30001.0 (`xgameruntime.dll` 10.0.26100.9656), Windows 10 build 19045. No GPU is used. ```powershell ctest --preset dev --no-tests=error -R '^startup_async_manual_completion_(controlled|system|inline_control)$' -V ``` | Phase | `XAsyncGetStatus(false)` | `XAsyncGetResultSize` | Callbacks | Result consumed | |---|---|---|---|---| | pending | `0x8000000a` (E_PENDING) | `0x8000000a` | 0 | no | | complete, completion port not dispatched | **`S_OK`** | `S_OK`, 8 bytes | **0** | no | | after one completion-port dispatch | `S_OK` | `S_OK`, 0 bytes | 1 | yes, payload matches | A second completion-port dispatch found no work. The immediate-port contrast ran its callback at completion. 3/3 passed, with no skips: `controlled`, `system` and `inline_control`, which printed its expected FAIL. **What this means for the accepted user-add:** on the installed runtime, a non-waiting status call distinguishes the two cases. An operation that is still in progress returns `E_PENDING`. One that has completed but whose completion port nobody dispatched returns `S_OK` with its result size available, while its callback count stays 0. So one `XAsyncGetStatus(block, false)` from the proxy on the accepted block, at the stop, would settle pending versus undispatched without touching the queue. Follow-up commit: after retrieval the runtime reports a result size of 0, so the stand-in now does the same, and `docs/startup-runtime.md` records these answers. **Status:** ready for review.
upstream-sync closed this pull request 2026-11-25 04:04:04 +00:00
tedin7 commented 2026-11-25 04:04:04 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T03:05:35Z.

Review: COMMENTED


Review of head 0435874c0ece7b7996504a29d8fe88fa538ec01e (comment only, no approval).

Scope: 3 files, test and docs only (CMakeLists.txt, docs/startup-runtime.md, tests/startup_async_manual_completion.cpp). Mergeable. Compared with the previous heads, this one adds a stand-in result size check (8 before, 0 after retrieval), asserts the work port is empty and no callback or provider read happens before the completion dispatch, and makes a queue creation error fail the test instead of reporting a skip. The docs match the code.

Review notes

  • No P1 and no P2 found.
  • The Queues destructor keeps its own close lookup, so removing the outer local is fine.
  • The system variant is a capability skip (77) on the test VM, so the installed runtime answers are documented but not exercised there.

Commands executed locally

  • git diff --check origin/main...HEAD: clean.
  • python3 tests/docs_links_check.py: 18 files, 401 links, OK.
  • python3 tests/bidi_controls_check.py: OK.
  • mingw build (x86_64-w64-mingw32-g++ -std=c++17 -static -pthread) run under wine: controlled PASS, inline-control prints FAIL: callback ran before the completion port was dispatched (as the CMake regex expects), system reports the runtime unavailable (capability skip).
  • Mutation: removing the completion queue pop_front made controlled fail with the callback did not retrieve the synthetic payload. Earlier, dropping the consumed-size rule made it fail with stand-in result size was not 8 before and 0 after retrieval. Reverted with git checkout -- ..
  • Win2025 (x2w_pipe.py win2025 2170, tested head matches 0435874c): Debug and Release -O2 both ran startup_async_manual_completion_(controlled|system|inline_control): controlled PASS, inline_control PASS, system skipped (capability). All non-skipped tests passed.
  • CI: Build and test on Windows SUCCESS, Linux Python checks SUCCESS, gfx1013 fixtures SUCCESS.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6051253139 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2170#pullrequestreview-6051253139). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T03:05:35Z. **Review:** COMMENTED --- Review of head `0435874c0ece7b7996504a29d8fe88fa538ec01e` (comment only, no approval). **Scope:** 3 files, test and docs only (CMakeLists.txt, docs/startup-runtime.md, tests/startup_async_manual_completion.cpp). Mergeable. Compared with the previous heads, this one adds a stand-in result size check (8 before, 0 after retrieval), asserts the work port is empty and no callback or provider read happens before the completion dispatch, and makes a queue creation error fail the test instead of reporting a skip. The docs match the code. **Review notes** - No P1 and no P2 found. - The `Queues` destructor keeps its own `close` lookup, so removing the outer local is fine. - The `system` variant is a capability skip (77) on the test VM, so the installed runtime answers are documented but not exercised there. **Commands executed locally** - `git diff --check origin/main...HEAD`: clean. - `python3 tests/docs_links_check.py`: 18 files, 401 links, OK. - `python3 tests/bidi_controls_check.py`: OK. - mingw build (`x86_64-w64-mingw32-g++ -std=c++17 -static -pthread`) run under wine: `controlled` PASS, `inline-control` prints `FAIL: callback ran before the completion port was dispatched` (as the CMake regex expects), `system` reports the runtime unavailable (capability skip). - Mutation: removing the completion queue `pop_front` made `controlled` fail with `the callback did not retrieve the synthetic payload`. Earlier, dropping the consumed-size rule made it fail with `stand-in result size was not 8 before and 0 after retrieval`. Reverted with `git checkout -- .`. - Win2025 (`x2w_pipe.py win2025 2170`, tested head matches 0435874c): Debug and Release `-O2` both ran `startup_async_manual_completion_(controlled|system|inline_control)`: controlled PASS, inline_control PASS, system skipped (capability). All non-skipped tests passed. - CI: `Build and test on Windows` SUCCESS, Linux Python checks SUCCESS, gfx1013 fixtures SUCCESS. AI-assisted; commands listed were executed locally.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
R0Y00/Xbox2Windows!2162
No description provided.