feat: ship xgameruntime.dll from Rust, task queue waiters and QueryInterface #356

Open
github-bot wants to merge 25 commits from github-bot/gh-356 into main AGit
Owner

@⁠LooperSalty on GitHub · 2026-11-26 12:18 UTC · original
LooperSalty:codex/xgameruntime-rust-dll → main · +864 −24 · 12 files · 25 commits · open

Next step of the move to Rust after #351: runtime/build/bin/xgameruntime.dll is now the Rust one (crates/anyxboxx-xgameruntime). The C++ build stays only as the parity oracle. Work by Codex (24 commits, about 70 minutes), pushed by Claude: Codex's sandbox has no network.

Changes

  • runtime/CMakeLists.txt: xgameruntime.dll added to ANYXBOXX_RUST_DLLS; the C++ DLL is built under another name as the oracle.
  • Chunk uninstall: refused like the C++ oracle. tests/test_runtime_package.py no longer skips its case ("Rust refusal differs from C++").
  • Task queue: waiters (XTaskQueueRegisterWaiter/Unregister, self-unregistration) and QueryInterface. Parity tests against the C++ oracle in crates/anyxboxx-xgameruntime/src/parity_tests.rs and tests/test_runtime_task_waiter.py. Interface slots compared between C++ and Rust in tests/test_rust_dlls.py.
  • third_party/victory/crates/victory-hle/src/modules/xasync.rs and the new xasync_waiter.rs: the same waiter support in VIctory's HLE. This code runs in the game.
  • docs/rust-full-status.md (EN and FR): xgameruntime shipping checks.

Test plan

  • Codex: cargo build and test of the workspace, CMake runtime build, the pytest cases it could run
  • Full suite: Codex left 11 launcher tests unrun (they start a synthetic victory.exe, which its instructions forbade). CI runs them.
  • CI green
  • In-game check before merging, because victory-hle changed: one Series X run with the launcher, compared with main (13.4 fps median on 2026-11-26, no crash)

🤖 Generated with Claude Code

https://claude.ai/code/session_01LwHrL62nyr3m1M4tJsHRox

**@⁠LooperSalty** on GitHub · 2026-11-26 12:18 UTC · [original](https://github.com/LooperSalty/AnyXboxX/pull/356) `LooperSalty:codex/xgameruntime-rust-dll` → `main` · +864 −24 · 12 files · 25 commits · open Next step of the move to Rust after #351: `runtime/build/bin/xgameruntime.dll` is now the Rust one (`crates/anyxboxx-xgameruntime`). The C++ build stays only as the parity oracle. Work by Codex (24 commits, about 70 minutes), pushed by Claude: Codex's sandbox has no network. ## Changes - `runtime/CMakeLists.txt`: `xgameruntime.dll` added to `ANYXBOXX_RUST_DLLS`; the C++ DLL is built under another name as the oracle. - Chunk uninstall: refused like the C++ oracle. `tests/test_runtime_package.py` no longer skips its case ("Rust refusal differs from C++"). - Task queue: waiters (`XTaskQueueRegisterWaiter`/`Unregister`, self-unregistration) and `QueryInterface`. Parity tests against the C++ oracle in `crates/anyxboxx-xgameruntime/src/parity_tests.rs` and `tests/test_runtime_task_waiter.py`. Interface slots compared between C++ and Rust in `tests/test_rust_dlls.py`. - **`third_party/victory/crates/victory-hle/src/modules/xasync.rs` and the new `xasync_waiter.rs`**: the same waiter support in VIctory's HLE. This code runs in the game. - `docs/rust-full-status.md` (EN and FR): xgameruntime shipping checks. ## Test plan - [x] Codex: cargo build and test of the workspace, CMake runtime build, the pytest cases it could run - [ ] Full suite: Codex left 11 launcher tests unrun (they start a synthetic `victory.exe`, which its instructions forbade). CI runs them. - [ ] CI green - [ ] **In-game check** before merging, because `victory-hle` changed: one Series X run with the launcher, compared with `main` (13.4 fps median on 2026-11-26, no crash) 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01LwHrL62nyr3m1M4tJsHRox
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 12:21:41 +00:00
Author
Owner

@⁠chatgpt-codex-connector[bot] on GitHub · 2026-11-26 12:18 UTC · original · edited 2026-11-26 12:20 UTC

Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-26T12:20:37.625909Z 8bb6a41 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@⁠codex review" or "@⁠codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

**@⁠chatgpt-codex-connector[bot]** on GitHub · 2026-11-26 12:18 UTC · [original](https://github.com/LooperSalty/AnyXboxX/pull/356#issuecomment-7191833004) · edited 2026-11-26 12:20 UTC <!-- codex-pull-request-review-summary --> <!-- codex-review-state:v1 {"code_review":{"commit_sha":"8bb6a41dfd9b4f9dae23fc155aff804cc1dd84a3","has_any_findings":true,"has_unresolved_findings":true,"status":"completed"},"security_review":{"commit_sha":null,"has_any_findings":null,"has_unresolved_findings":null,"status":null}} --> <details> <summary><strong>Codex Review Summary</strong>: ✅ Completed</summary> This comment shows the latest Codex review activity on this pull request. | Review | Status | Commit | Review trigger | | --- | --- | --- | --- | | 📝 **Code Review** | ✅ **Completed** <relative-time datetime="2026-11-26T12:20:37.625909Z">2026-11-26T12:20:37.625909Z</relative-time> | `8bb6a41` | PR opened | <details> <summary>ℹ️ About Codex in GitHub</summary> <br/> [Your team has set up Codex to review pull requests in this repo](https://chatgpt.com/codex/cloud/settings/general). Reviews are triggered when you - Open a pull request for review - Mark a draft as ready - Comment "@⁠codex review" or "@⁠codex security review". Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. </details> </details>
Author
Owner

@⁠chatgpt-codex-connector[bot] on GitHub · 2026-11-26 12:20 UTC · original · reviewed

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8bb6a41dfd

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@⁠codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@⁠codex address that feedback".

**@⁠chatgpt-codex-connector[bot]** on GitHub · 2026-11-26 12:20 UTC · [original](https://github.com/LooperSalty/AnyXboxX/pull/356#pullrequestreview-6074025463) · **reviewed** <!-- codex-review-receipt:v1 --> ### 💡 Codex Review Here are some automated review suggestions for this pull request. **Reviewed commit:** `8bb6a41dfd` <details> <summary>ℹ️ About Codex in GitHub</summary> <br/> [Your team has set up Codex to review pull requests in this repo](https://chatgpt.com/codex/cloud/settings/general). Reviews are triggered when you - Open a pull request for review - Mark a draft as ready - Comment "@⁠codex review". If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@⁠codex address that feedback". </details>
@ -0,0 +76,4 @@
pub(super) fn invoke(&self, canceled: bool) {
if !canceled && self.active.load(Ordering::Acquire) {
(self.task.callback)(self.task.context as *mut c_void, false);
Author
Owner

@⁠chatgpt-codex-connector[bot] on GitHub · 2026-11-26 12:20 UTC · original

P1 Badge Synchronize waiter callback admission with unregistration

With a thread-pool port or concurrent manual dispatch, invoke can read active == true, be descheduled, and resume after another thread has completed unregister. Because unregistration only stores false and signals an event, the callback can still begin after unregistration returns, potentially accessing a callback context the caller has already freed. The atomic load provides visibility but does not make checking and invoking indivisible. Coordinate callback admission with unregistration while preserving support for callbacks unregistering themselves; the existing queued-callback test does not exercise this interleaving.

Useful? React with 👍 / 👎.

**@⁠chatgpt-codex-connector[bot]** on GitHub · 2026-11-26 12:20 UTC · [original](https://github.com/LooperSalty/AnyXboxX/pull/356#discussion_r4708262336) **<sub><sub>![P1 Badge](https://img.shields.io/badge/P1-orange?style=flat)</sub></sub> Synchronize waiter callback admission with unregistration** With a thread-pool port or concurrent manual dispatch, `invoke` can read `active == true`, be descheduled, and resume after another thread has completed `unregister`. Because unregistration only stores `false` and signals an event, the callback can still begin after unregistration returns, potentially accessing a callback context the caller has already freed. The atomic load provides visibility but does not make checking and invoking indivisible. Coordinate callback admission with unregistration while preserving support for callbacks unregistering themselves; the existing queued-callback test does not exercise this interleaving. Useful? React with 👍 / 👎. <!-- codex-code-review-finding:v1 -->
@ -384,1 +410,4 @@
queue.terminated.store(true, Ordering::Release);
#[cfg(windows)]
for waiter in lock(&queue.waiters).drain().map(|(_, waiter)| waiter) {
waiter.cancel();
Author
Owner

@⁠chatgpt-codex-connector[bot] on GitHub · 2026-11-26 12:20 UTC · original

P2 Badge Deliver canceled waiter callbacks during queue termination

When a queue terminates with registered waiters, this drains their registrations and deactivates them without delivering cancellation callbacks. Even a waiter task already queued is silently suppressed because Waiter::invoke(true) never invokes the client. The bundled C++ implementation instead promotes registered waits in TaskQueuePortImpl::CancelPendingEntries(..., true) and dispatches their callbacks with the cancellation flag through DrainOneItem. Titles relying on that notification to release callback-owned resources or finish shutdown can consequently leak resources or wait indefinitely with the newly shipped Rust runtime. Preserve the distinction between explicit unregistration, which suppresses callbacks, and queue termination, which delivers cancellation.

Useful? React with 👍 / 👎.

**@⁠chatgpt-codex-connector[bot]** on GitHub · 2026-11-26 12:20 UTC · [original](https://github.com/LooperSalty/AnyXboxX/pull/356#discussion_r4708262346) **<sub><sub>![P2 Badge](https://img.shields.io/badge/P2-yellow?style=flat)</sub></sub> Deliver canceled waiter callbacks during queue termination** When a queue terminates with registered waiters, this drains their registrations and deactivates them without delivering cancellation callbacks. Even a waiter task already queued is silently suppressed because `Waiter::invoke(true)` never invokes the client. The bundled C++ implementation instead promotes registered waits in `TaskQueuePortImpl::CancelPendingEntries(..., true)` and dispatches their callbacks with the cancellation flag through `DrainOneItem`. Titles relying on that notification to release callback-owned resources or finish shutdown can consequently leak resources or wait indefinitely with the newly shipped Rust runtime. Preserve the distinction between explicit unregistration, which suppresses callbacks, and queue termination, which delivers cancellation. Useful? React with 👍 / 👎. <!-- codex-code-review-finding:v1 -->
Author
Owner

@⁠Lewandox on GitHub · 2026-11-26 16:40 UTC · original · reviewed

Reviewed third_party/victory/crates/victory-hle/src/modules/xasync.rs and xasync_waiter.rs ahead of the in-game check. In addition to the two Codex findings (which both look valid — Waiter::invoke vs unregister synchronization and delivering canceled = true on XTaskQueueTerminate), I spotted one more concurrency edge case in xasync_waiter.rs::register:

  • Spawning the waiter thread before writing *token (while holding queue.waiters lock):
    waiters.insert(id, waiter.clone());
    let weak = Arc::downgrade(&queue);
    if std::thread::Builder::new()
        .spawn(move || waiter.wait(weak, port))
        .is_err()
    {
        waiters.remove(&id);
        return 0x8007_000e_u32 as i32;
    }
    unsafe { token.write(id) };
    
    If watched is already signaled when register is called on a thread-pool queue, the waiter thread can wake up and submit/run the callback before token.write(id) executes. If the callback reads the registration token (e.g. to self-unregister) it can observe an uninitialized/stale value (data race on *token), or block on lock(&queue.waiters) if register hasn't dropped the guard yet. Writing token.write(id) before spawning (and clearing/leaving it on spawn error) and dropping waiters before spawning (or synchronizing via the waiter state) avoids that race.

Everything else (m_query_interface, check_thread debugger check, XAsyncComplete task.clone(), handle duplication with OwnedHandle) looks clean and well-tested.

**@⁠Lewandox** on GitHub · 2026-11-26 16:40 UTC · [original](https://github.com/LooperSalty/AnyXboxX/pull/356#pullrequestreview-6077702016) · **reviewed** Reviewed `third_party/victory/crates/victory-hle/src/modules/xasync.rs` and `xasync_waiter.rs` ahead of the in-game check. In addition to the two Codex findings (which both look valid — `Waiter::invoke` vs `unregister` synchronization and delivering `canceled = true` on `XTaskQueueTerminate`), I spotted one more concurrency edge case in `xasync_waiter.rs::register`: - **Spawning the waiter thread before writing `*token` (while holding `queue.waiters` lock)**: ```rust waiters.insert(id, waiter.clone()); let weak = Arc::downgrade(&queue); if std::thread::Builder::new() .spawn(move || waiter.wait(weak, port)) .is_err() { waiters.remove(&id); return 0x8007_000e_u32 as i32; } unsafe { token.write(id) }; ``` If `watched` is already signaled when `register` is called on a thread-pool queue, the waiter thread can wake up and submit/run the callback **before** `token.write(id)` executes. If the callback reads the registration token (e.g. to self-unregister) it can observe an uninitialized/stale value (data race on `*token`), or block on `lock(&queue.waiters)` if `register` hasn't dropped the guard yet. Writing `token.write(id)` before spawning (and clearing/leaving it on spawn error) and dropping `waiters` before spawning (or synchronizing via the waiter state) avoids that race. Everything else (`m_query_interface`, `check_thread` debugger check, `XAsyncComplete` `task.clone()`, handle duplication with `OwnedHandle`) looks clean and well-tested.
This pull request has changes conflicting with the target branch.
  • third_party/victory/crates/victory-hle/src/modules/xasync.rs
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/356/head:github-bot/gh-356'
git switch 'github-bot/gh-356'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-356'
git switch 'github-bot/gh-356'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-356'
git switch 'github-bot/gh-356'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-356'
git switch 'main'
git merge --squash 'github-bot/gh-356'
git switch 'main'
git merge --ff-only 'github-bot/gh-356'
git switch 'main'
git merge 'github-bot/gh-356'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.