[Intel CPU] a_clzero_loop_becomes_plain_stores fails when crash::tests::clzero_loops_end_like_their_last_pass runs first #167

Closed
opened 2026-11-27 05:29:10 +00:00 by github-bot · 3 comments
Owner

@⁠samuelcurcelicordovil-collab on GitHub · 2026-11-27 05:28 UTC · original

A title-free test run (no game files) on an Intel CPU. Everything passes except one victory-loader test, which fails only when a particular crash test runs before it in the same process.

Vice-Tay build

02b693e (main, git clone), default cargo test profile, Rust 1.98.1 from rust-toolchain.toml. console_insn.rs and crash.rs are unchanged on the current main (93f3b5f).

Hardware and graphics driver

Intel Core i9-12900F (16 cores / 24 threads, no CLZERO), 32 GB DDR4-3200, NVIDIA GeForce RTX 4070 SUPER 12 GB, driver 621.40 (clean install), Windows 11 Pro 25H2 build 26200.9974, feature level 12_2, WDDM 3.2.

How to reproduce

cargo test --workspace --locked failed in 1 of 2 runs. To get it every time, fix the order with a shuffle seed. The shuffle flags are unstable, so RUSTC_BOOTSTRAP is set for the test binary only:

cargo test --locked -p victory-loader --lib --no-run
$env:RUSTC_BOOTSTRAP = '1'
.\target\debug\deps\victory_loader-<hash>.exe clzero --test-threads=1 -Z unstable-options --shuffle-seed 5

It fails exactly when crash::tests::clzero_loops_end_like_their_last_pass runs first:

Seed clzero_loops_end_like_their_last_pass runs a_clzero_loop_becomes_plain_stores
1, 2, 3, 4, 8 after it ok
5, 6, 7 before it FAILED

What you observed

thread 'console_insn::tests::a_clzero_loop_becomes_plain_stores' panicked at crates\victory-loader\src\console_insn.rs:634:21:
assertion `left == right` failed: a jump

The rest of the workspace passes: cargo test --workspace --locked --no-fail-fast gave 1141 passed, 0 failed, 54 ignored. cargo test --locked -p victory-gpu --lib -- --test-threads=1 gave 433 passed, 0 failed, 42 ignored. No TDR or nvlddmkm events during the runs.

Likely cause

  1. crash::tests::clzero_loops_end_like_their_last_pass runs a real clzero loop from the test binary's .text. On Intel that raises #UD, and the vectored handler calls console_insn::emulate, which calls patch_clzero.
  2. The first patch_clzero sets the process-wide STUBS region with near(at), so it lands near the test executable's image.
  3. a_clzero_loop_becomes_plain_stores puts its loop in a page from VirtualAlloc(NULL, …), normally more than 2 GB from that image. The rel32 jumps in jump(at, stub) and clzero_stub cannot reach, patch_clzero returns false, and the byte at page + 16 stays 0x0f instead of 0xe9.

Of the ways patch_clzero can return false, reach is the only one that plausibly depends on what ran before. On AMD (Zen has CLZERO) step 1 never faults, which would explain why it does not show up there. In the game it is probably harmless, since the title's clzero loops all sit in one image.

Two possible fixes: have patch_clzero take a new region with near(at) when the current one is out of reach, instead of giving up; or have the test allocate its page within reach of STUBS.

I can rerun the tests or try a fix on this machine.

AI-assisted (Claude)

**@⁠samuelcurcelicordovil-collab** on GitHub · 2026-11-27 05:28 UTC · [original](https://github.com/TaynanGT/Vice-Tay/issues/167) A title-free test run (no game files) on an Intel CPU. Everything passes except one victory-loader test, which fails only when a particular crash test runs before it in the same process. ### Vice-Tay build `02b693e` (main, git clone), default `cargo test` profile, Rust 1.98.1 from `rust-toolchain.toml`. `console_insn.rs` and `crash.rs` are unchanged on the current `main` (`93f3b5f`). ### Hardware and graphics driver Intel Core i9-12900F (16 cores / 24 threads, no CLZERO), 32 GB DDR4-3200, NVIDIA GeForce RTX 4070 SUPER 12 GB, driver 621.40 (clean install), Windows 11 Pro 25H2 build 26200.9974, feature level 12_2, WDDM 3.2. ### How to reproduce `cargo test --workspace --locked` failed in 1 of 2 runs. To get it every time, fix the order with a shuffle seed. The shuffle flags are unstable, so `RUSTC_BOOTSTRAP` is set for the test binary only: ```powershell cargo test --locked -p victory-loader --lib --no-run $env:RUSTC_BOOTSTRAP = '1' .\target\debug\deps\victory_loader-<hash>.exe clzero --test-threads=1 -Z unstable-options --shuffle-seed 5 ``` It fails exactly when `crash::tests::clzero_loops_end_like_their_last_pass` runs first: | Seed | `clzero_loops_end_like_their_last_pass` runs | `a_clzero_loop_becomes_plain_stores` | |---|---|---| | 1, 2, 3, 4, 8 | after it | ok | | 5, 6, 7 | before it | **FAILED** | ### What you observed ```text thread 'console_insn::tests::a_clzero_loop_becomes_plain_stores' panicked at crates\victory-loader\src\console_insn.rs:634:21: assertion `left == right` failed: a jump ``` The rest of the workspace passes: `cargo test --workspace --locked --no-fail-fast` gave 1141 passed, 0 failed, 54 ignored. `cargo test --locked -p victory-gpu --lib -- --test-threads=1` gave 433 passed, 0 failed, 42 ignored. No TDR or `nvlddmkm` events during the runs. ### Likely cause 1. `crash::tests::clzero_loops_end_like_their_last_pass` runs a real `clzero` loop from the test binary's `.text`. On Intel that raises `#UD`, and the vectored handler calls `console_insn::emulate`, which calls `patch_clzero`. 2. The first `patch_clzero` sets the process-wide `STUBS` region with `near(at)`, so it lands near the test executable's image. 3. `a_clzero_loop_becomes_plain_stores` puts its loop in a page from `VirtualAlloc(NULL, …)`, normally more than 2 GB from that image. The `rel32` jumps in `jump(at, stub)` and `clzero_stub` cannot reach, `patch_clzero` returns `false`, and the byte at `page + 16` stays `0x0f` instead of `0xe9`. Of the ways `patch_clzero` can return `false`, reach is the only one that plausibly depends on what ran before. On AMD (Zen has CLZERO) step 1 never faults, which would explain why it does not show up there. In the game it is probably harmless, since the title's `clzero` loops all sit in one image. Two possible fixes: have `patch_clzero` take a new region with `near(at)` when the current one is out of reach, instead of giving up; or have the test allocate its page within reach of `STUBS`. I can rerun the tests or try a fix on this machine. <sub>AI-assisted (Claude)</sub>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 05:29:10 +00:00
Author
Owner

@⁠TaynanGT on GitHub · 2026-11-27 05:46 UTC · original

Thanks for isolating the test order, @⁠samuelcurcelicordovil-collab. I reproduced the a jump assertion on Windows by pre-seeding the shared stub bank near the test image. The fixture in #170 now allocates the test loop near that bank, so both jumps stay within range.

All five CLZERO tests passed locally with the corrected fixture.

**@⁠TaynanGT** on GitHub · 2026-11-27 05:46 UTC · [original](https://github.com/TaynanGT/Vice-Tay/issues/167#issuecomment-7210935464) Thanks for isolating the test order, @⁠samuelcurcelicordovil-collab. I reproduced the `a jump` assertion on Windows by pre-seeding the shared stub bank near the test image. The fixture in #170 now allocates the test loop near that bank, so both jumps stay within range. All five CLZERO tests passed locally with the corrected fixture.
Author
Owner

@⁠samuelcurcelicordovil-collab on GitHub · 2026-11-27 05:53 UTC · original

Confirmed fixed on the same Intel machine (i9-12900F, no CLZERO), main at 8ed3c01, which includes #170:

  • Shuffle seeds 1 to 20 with clzero --test-threads=1: 20 of 20 pass. In 10 of them (5, 6, 7, 9, 10, 11, 13, 14, 17, 20) crash::tests::clzero_loops_end_like_their_last_pass ran first. Before #170 that order failed every time.
  • victory-loader lib tests: 63 passed, 0 failed.

Thanks for the quick fix. This can be closed from my side.

AI-assisted (Claude)

**@⁠samuelcurcelicordovil-collab** on GitHub · 2026-11-27 05:53 UTC · [original](https://github.com/TaynanGT/Vice-Tay/issues/167#issuecomment-7211040795) Confirmed fixed on the same Intel machine (i9-12900F, no CLZERO), `main` at `8ed3c01`, which includes #170: - Shuffle seeds 1 to 20 with `clzero --test-threads=1`: 20 of 20 pass. In 10 of them (5, 6, 7, 9, 10, 11, 13, 14, 17, 20) `crash::tests::clzero_loops_end_like_their_last_pass` ran first. Before #170 that order failed every time. - `victory-loader` lib tests: 63 passed, 0 failed. Thanks for the quick fix. This can be closed from my side. <sub>AI-assisted (Claude)</sub>
Author
Owner

@⁠TaynanGT on GitHub · 2026-11-27 06:02 UTC · original

Thanks for retesting on the i9-12900F, @⁠samuelcurcelicordovil-collab. All 20 shuffled runs passed, including 10 with the previously failing order. That confirms #170 on the machine that hit the failure.

**@⁠TaynanGT** on GitHub · 2026-11-27 06:02 UTC · [original](https://github.com/TaynanGT/Vice-Tay/issues/167#issuecomment-7211158708) Thanks for retesting on the i9-12900F, @⁠samuelcurcelicordovil-collab. All 20 shuffled runs passed, including 10 with the previously failing order. That confirms #170 on the machine that hit the failure.
This discussion has been locked. Commenting is limited to contributors.
No description provided.