startup: check XAsync completion on a manual completion port #2162
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2170"
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?
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.cppstarts 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:XAsyncGetStatus(wait=false)andXAsyncGetResultSizepending(accepted, not completed)unpumped(completed, work port dispatched once, completion port not)dispatched(one completion-port dispatch)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 insideXAsyncComplete, as an immediate port would. It must printFAIL: 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(mainc118f569+ this commit), Windows 10 build 19045, MSVCdevpreset. No GPU is used.At
6dd71ab4: 2 passed, 1 capability skip. At7c8b7ad6with the runtime installed: 3 passed.docs_links_check.py,bidi_controls_check.pyandgit diff --checkare clean.Real runtime: with Gaming Services 39.118.30001.0 installed,
systempassed. A completed but undispatched block reportsS_OKfrom the non-waiting status call, with an 8-byte result size and 0 callbacks. A pending block reportsE_PENDING(0x8000000a). The full table is in this comment.AI-assisted.
🤖 Generated with Claude Code
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.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: printsFAIL: callback ran before the completion port was dispatched, which is exactly what the CMakePASS_REGULAR_EXPRESSIONexpects.system: exit 77 (no gaming runtime under wine), which matchesSKIP_RETURN_CODE 77.the callback did not retrieve the synthetic payload(callbacks=2, mismatch). The mutation was killed, and I reverted it withgit checkout -- ..systemvariant 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.cppstand-indispatch: it returns false for the work port, sowork_port_dispatched=0in 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.cppinrun():const auto close = ...; (void)close;is unused (theQueuesdestructor fetches its own). Remove it.systemPASS only asserts the callback count, the dispatch behaviour and the payload. It never asserts that the runtime's status isE_PENDINGbefore completion, so a runtime quirk there would go unnoticed. This is intentional per the doc, but worth one line saying so.ivall/xclslot 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.
Imported from R0Y00/Xbox2Windows. Originally posted by Jess-Doit on 2026-11-25T02:52:12Z.
Real-runtime result for the
systemvariant, at7c8b7ad6. Gaming Services 39.118.30001.0 (xgameruntime.dll10.0.26100.9656), Windows 10 build 19045. No GPU is used.XAsyncGetStatus(false)XAsyncGetResultSize0x8000000a(E_PENDING)0x8000000aS_OKS_OK, 8 bytesS_OKS_OK, 0 bytesA second completion-port dispatch found no work. The immediate-port contrast ran its callback at completion. 3/3 passed, with no skips:
controlled,systemandinline_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 returnsS_OKwith its result size available, while its callback count stays 0. So oneXAsyncGetStatus(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.mdrecords these answers.Status: ready for review.
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
Queuesdestructor keeps its owncloselookup, so removing the outer local is fine.systemvariant 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.x86_64-w64-mingw32-g++ -std=c++17 -static -pthread) run under wine:controlledPASS,inline-controlprintsFAIL: callback ran before the completion port was dispatched(as the CMake regex expects),systemreports the runtime unavailable (capability skip).pop_frontmadecontrolledfail withthe callback did not retrieve the synthetic payload. Earlier, dropping the consumed-size rule made it fail withstand-in result size was not 8 before and 0 after retrieval. Reverted withgit checkout -- ..x2w_pipe.py win2025 2170, tested head matches0435874c): Debug and Release-O2both ranstartup_async_manual_completion_(controlled|system|inline_control): controlled PASS, inline_control PASS, system skipped (capability). All non-skipped tests passed.Build and test on WindowsSUCCESS, Linux Python checks SUCCESS, gfx1013 fixtures SUCCESS.AI-assisted; commands listed were executed locally.