xgameruntime tests: compare slots by the function bound to their name, not by function address #200

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

@⁠Kalmarv on GitHub · 2026-11-23 20:28 UTC · original
Kalmarv:test/slot-fn-identity → main · +29 −8 · 1 files · 1 commits · closed without merging

The windows-gnu build fails hle::xgameruntime::api::tests::legacy_console_iids_map_to_their_own_slots, at targets[36] == register_token4 as usize. Dispatch is correct. The test assumes a function has one address, but Rust doesn't guarantee that (std::ptr::fn_addr_eq). The GNU build has two copies of register_token4, one per codegen unit, and the vtable slot holds the other copy.

Only that test changes (crates/xcl/src/hle/xgameruntime/api.rs, +29/−8); there are no production, linker or codegen changes.

  • Each legacy slot is checked against the function the main vtable binds to the same GDK name, through XCL's own table, instead of against f as usize.
  • v2's slot 36 is called through the vtable, as a title would call it. It returns S_OK twice with increasing tokens, and E_INVALIDARG for a null token. v1 has nothing at slot 36 (E_NOTIMPL).
build hle::xgameruntime tests, base 956a476 this branch (4c3c156)
x86_64-pc-windows-gnu (MinGW POSIX), under Wine 9.0 on Linux 72 / 73, this test fails 73 / 73
x86_64-pc-windows-msvc (VS2022), native Windows 11, debug 73 / 73 73 / 73

Mutation checks on the GNU build each fail the new test: routing slot 36 to the wrong slot, routing it to a stub, and a fake S_OK that writes no token. MSVC doesn't show the original failure, as expected, since it emits one copy. No release MSVC build was run.

Not touched: four other as usize address comparisons elsewhere in the test module, which pass on both builds today.

AI-assisted (Claude Code). No game data.

🤖 Generated with Claude Code

**@⁠Kalmarv** on GitHub · 2026-11-23 20:28 UTC · [original](https://github.com/xcl-dev/xcl/pull/200) `Kalmarv:test/slot-fn-identity` → `main` · +29 −8 · 1 files · 1 commits · closed without merging The windows-gnu build fails `hle::xgameruntime::api::tests::legacy_console_iids_map_to_their_own_slots`, at `targets[36] == register_token4 as usize`. Dispatch is correct. The test assumes a function has one address, but Rust doesn't guarantee that (`std::ptr::fn_addr_eq`). The GNU build has two copies of `register_token4`, one per codegen unit, and the vtable slot holds the other copy. Only that test changes (`crates/xcl/src/hle/xgameruntime/api.rs`, +29/−8); there are no production, linker or codegen changes. - Each legacy slot is checked against the function the main vtable binds to the same GDK name, through XCL's own table, instead of against `f as usize`. - v2's slot 36 is called through the vtable, as a title would call it. It returns S_OK twice with increasing tokens, and E_INVALIDARG for a null token. v1 has nothing at slot 36 (E_NOTIMPL). | build | `hle::xgameruntime` tests, base 956a476 | this branch (4c3c156) | |---|---|---| | x86_64-pc-windows-gnu (MinGW POSIX), under Wine 9.0 on Linux | 72 / 73, this test fails | 73 / 73 | | x86_64-pc-windows-msvc (VS2022), native Windows 11, debug | 73 / 73 | 73 / 73 | Mutation checks on the GNU build each fail the new test: routing slot 36 to the wrong slot, routing it to a stub, and a fake S_OK that writes no token. MSVC doesn't show the original failure, as expected, since it emits one copy. No release MSVC build was run. Not touched: four other `as usize` address comparisons elsewhere in the test module, which pass on both builds today. AI-assisted (Claude Code). No game data. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
A function has no single address in Rust (std::ptr::fn_addr_eq). In the
x86_64-pc-windows-gnu build, register_token4 has two copies, one per
codegen unit, so legacy_console_iids_map_to_their_own_slots failed at
targets[36] == register_token4 as usize although slot 36 dispatches to
register_token4. Compare each slot with the function the main vtable
binds to the same GDK name, and call v2's slot 36 through the vtable to
check the routing by behaviour.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:14:53 +00:00
github-bot closed this pull request 2026-11-26 04:14:53 +00:00
Author
Owner

@⁠Kalmarv on GitHub · 2026-11-23 21:04 UTC · original

Rebased on main eaa36b6 (0bb3c15, no conflicts). cargo test --release -p xcl --lib xgameruntime: 73 passed. Overlaps: none known; the change is test-only (hle/xgameruntime/api.rs tests).

**@⁠Kalmarv** on GitHub · 2026-11-23 21:04 UTC · [original](https://github.com/xcl-dev/xcl/pull/200#issuecomment-7113951431) Rebased on main eaa36b6 (0bb3c15, no conflicts). `cargo test --release -p xcl --lib xgameruntime`: 73 passed. Overlaps: none known; the change is test-only (`hle/xgameruntime/api.rs` tests).
Author
Owner

@⁠ivall on GitHub · 2026-11-23 21:10 UTC · original

Merged into main (6da33fa) as 4c3c1562, the head before your last rebase - the same patch (identical patch-id), so GitHub does not show it as merged; closing it by hand. Checked on an RX 9070 (RDNA4) with the 22 PRs merged together: 582 unit tests passed, 0 failed, the integration and e2e tests passed, and the retail game still reaches its first menu (646 frames in 30 s, no device removal). Thanks!

**@⁠ivall** on GitHub · 2026-11-23 21:10 UTC · [original](https://github.com/xcl-dev/xcl/pull/200#issuecomment-7114096942) Merged into main (6da33fa) as 4c3c1562, the head before your last rebase - the same patch (identical patch-id), so GitHub does not show it as merged; closing it by hand. Checked on an RX 9070 (RDNA4) with the 22 PRs merged together: 582 unit tests passed, 0 failed, the integration and e2e tests passed, and the retail game still reaches its first menu (646 frames in 30 s, no device removal). Thanks!

Pull request closed

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