Skip to content

xgameruntime: XAsyncBeginAlloc and XTaskQueueIsEmpty are forwarded to the real task queue - #185

Draft
Andretuta wants to merge 1 commit into
mainfrom
old-pr/9917
Draft

Andretuta wants to merge 1 commit into
mainfrom
old-pr/9917

Conversation

@Andretuta

Copy link
Copy Markdown
Collaborator

Carried over from old PR 9917 by tedin7 in the original Leonida repository, which went private on 23 Nov 2026. The code is the branch old-pr/9917, exactly that PR's last commit. All carried-over PRs are listed in #17.
Opened as a draft, and the CI runs the opening started were cancelled so 250 PRs don't fill the queue. Re-run CI here when you review it.
tedin7: this is your work. Feel free to take it over, by pushing to the branch or opening your own PR and closing this one.


Original description (mentions and #N references are disabled; the numbers refer to the old repository):

@ItsNotRexed: an exe PR, as you asked.

Rebased cleanly on current main; supersedes #8588 closed during org migration.

What

XThreadingImpl slot 8 (XAsyncBeginAlloc) and slot 28 (XTaskQueueIsEmpty) forward to the real task queue instead of answering E_NOTIMPL / 0. Slot 8 starts the provider once with a separate 16-byte context holding the copied parameter bytes; slot 28 reports the real state of the queue port. The runtime_imports.md row now says slot 28 takes a queue and a port.

Why

On main slot 28 always answers 0 ("empty"), so a caller polling a queue with queued work is told it is idle, and slot 8 refuses a call the task queue library can run.

Tested

Cross-built with clang-cl 19 + lld-link (xwin SDK 10.0.26100), run under Wine: xgameruntime_test: OK, 163 checks, 0 failures.
Negative control: same new test file against main's xgameruntime.cpp: 4 of 162 checks fail (slot 28 idle port empty, slot 28 completion empty while work is queued, slot 8 begins the provider, slot 8 context with copied parameter block).

AI-assisted (Claude Code).

…ty are forwarded to the real task queue

Squashed from ItsNotRexed/Leonida#8588 by tedin7, head e09f0a9bd (security scan PASS).

Applied as the PR's own diff (gh pr diff); head matches the watcher's scan. xgameruntime_test keeps Wave 1's per-thread time-sensitive flag checks (#7957); the old slot-8 comment that preceded this PR's new slot-8 test is dropped.
@fiestorra

Copy link
Copy Markdown
Contributor

Independent verification on this machine (Windows 11, MSVC 19.44.35226): this pull request builds and then fails two of the eight xgameruntime tests on its own tree.

1. It applies. merge-tree clean; the commits cherry-pick onto main 4014af7fe without a conflict. Three files: docs/runtime_imports.md, runtime/shims/xgameruntime.cpp (the change) and runtime/test/xgameruntime_test.cpp.

2. It builds:

[6/6] Linking CXX executable xgameruntime_test.exe

3. Two of the eight tests fail:

75% tests passed, 2 tests failed out of 8
157 - xgameruntime_offline      (Failed)
158 - xgameruntime_offline_hdr  (Failed)

FAIL XUserFindForDevice before XUserAddAsync: E_GAMEUSER_USER_NOT_FOUND and no handle
FAIL no XUserHandle was handed out before the add
FAIL the add result and the found user are two XUserHandles

4. My first hypothesis was wrong, and I tested it: those three assertions read like the ones #126 introduces, so I applied #185 then #126 on top and re-ran:

git cherry-pick …185…   -> f8ec30197
git cherry-pick …126…   -> applies cleanly
cmake --build … --target xgameruntime_test
ctest -R '^xgameruntime'
75% tests passed, 2 tests failed out of 8      <- unchanged

So #185 is not blocked on #126 - the two failures survive with both applied, and the branch's own test file is the thing that disagrees with the branch's own shim.

What I would look at first: the test in this branch expects a pre-XUserAddAsync query to answer E_GAMEUSER_USER_NOT_FOUND and to hand out no handle, plus that the add result and the found user are two distinct XUserHandles. main passes the same test target today, so either the branch adds assertions its shim change does not implement, or the cherry-pick's three-way merge produced a test/shim pair that neither side wrote.

What I did not do: edit either file to see which is wrong. That is the author's call, and a stranger changing a shim to satisfy a test would be guessing at intent.

How it was found: I was running a negative control on this PR (revert the shim, keep the test) and the "with the PR" side came up red. The control is useless until the baseline is green - which is why I checked and am reporting the failure rather than the control.

Written with an AI assistant.

@fiestorra

Copy link
Copy Markdown
Contributor

Correction to my comment above: this pull request does not fail its tests. The two failures I reported came from stale binaries of other test executables, and with every xgameruntime binary rebuilt on the branch's tree it is 8/8.

What I did wrong: I built only the target the branch's changed test file names (xgameruntime_test), then ran ctest -R '^xgameruntime', which also matches xgameruntime_offline, xgameruntime_offline_hdr, xgameruntime_gamesave, xgameruntime_store, xgameruntime_user - five tests whose executables belong to other targets, which I had not rebuilt. Those binaries were left over from other pull requests' trees in the same build directory.

The correct run - rebuild every binary the matching tests name:

ctest --show-only=json-v1  -> binaries: xgameruntime_gamesave_test, xgameruntime_offline_test,
                                        xgameruntime_store_test, xgameruntime_test, xgameruntime_user_test
cmake --build … --target <all five>        [35/35] Linking CXX executable xgameruntime_store_test.exe
ctest -R '^xgameruntime'
100% tests passed, 0 tests failed out of 8

So the state of this pull request is: applies cleanly, builds, 8 of 8 pass, and my earlier "two failures" were an artefact of a shared build directory. The three assertions I quoted (XUserFindForDevice before XUserAddAsync: …) were produced by an old xgameruntime_offline_test.exe, not by this branch.

Why the artefact is easy to produce here, and worth a note for anyone repeating this: the test name and the executable are different things (as I found earlier on xbox_geometry_upload_batch), and one ctest -R pattern can span five executables. Rebuilding "the target the PR touches" is not enough when the pattern reaches beyond it.

What I have not done: a negative control on this branch. The control is only meaningful once the baseline is green, and I now have that baseline - the shim change is next.

Written with an AI assistant.

@fiestorra

Copy link
Copy Markdown
Contributor

The negative control, on the green baseline I now have: it bites. One of the eight fails with the shim reverted.

Method, with every binary rebuilt on both sides (the five executables that -R '^xgameruntime' spans):

with the branch   -> 100% tests passed, 0 tests failed out of 8
revert only runtime/shims/xgameruntime.cpp
rebuild all five  ->  88% tests passed, 1 tests failed out of 8
     153 - xgameruntime (Failed)

So the change is covered by the branch's own test. Combined with the correction above, the state of this pull request is:

check result
applies onto main 4014af7fe clean, no conflict
builds yes
all eight xgameruntime tests 8/8 pass
control: shim reverted 1 of 8 fails

What the change is: the branch adds the xtaskqueue/XAsyncProviderPriv includes to the shim and the doc line that goes with them, so the offline runtime's task-queue path goes through the real provider headers rather than a stub. The test that notices its absence is xgameruntime, the base one - the other seven do not, which is the normal shape: one test owns the path.

What I did not test: anything outside those eight tests, and whether the includes are the minimum necessary.

On the wrong claim I made earlier: it is corrected above, and the cause was a stale xgameruntime_offline_test.exe from another branch in a shared build directory. The lesson is now written in the coordination thread - a ctest -R pattern can span executables a pull request never touches, and "rebuild the target it touches" is not enough.

Written with an AI assistant.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants