tooling: add a deterministic CPU differential fuzz smoke #894

Manually merged
github merged 2 commits from gh-pr/894/head into gh-pr/894/base 2026-11-26 22:26:30 +00:00
Owner

@⁠triggered02 on GitHub · 2026-11-23 16:18 UTC · original
triggered02:tooling/cpu-differential-fuzz → main · +356 −0 · 4 files · 2 commits · merged 2026-11-23 16:46 UTC

Refs #446.

Change

Adds a deterministic differential fuzz smoke for the shared cpu_switch_aot lifter. tools/fuzz_cpu.py generates 20 leaf functions from seed 0xA902 covering 8-, 16-, 32- and 64-bit ALU chains, shifts and rotates, CMP/TEST producers feeding SETcc/CMOVcc/Jcc consumers, a forward branch diamond, and a Jcc to its own fallthrough. The build assembles one MASM DLL, translates all exports into one C++ source, and builds that source at the preset's optimization plus an explicit /O2 build.

The test runs native, default-translated and /O2-translated exports over 313 deterministic input pairs per function and compares RAX plus a guarded 256-byte output buffer. A mismatch prints the seed, function, input, native/lifted values and the one-function MASM; --only NAME --input INDEX reproduces one case. CPU_FUZZ_FUNCTIONS and CPU_FUZZ_SEED configure a longer manual run.

Verification

Windows 11 Pro 26200, MSVC 19.52, CMake/Ninja, Ryzen 5 5500 (no GPU involved).

ctest --preset dev --no-tests=error -R '^cpu_aot_fuzz_smoke$' -V

Dev: seed 0xA902, 20 functions, 313 inputs, 12,520 comparisons, 0.37 s.

ctest --preset release --no-tests=error -R '^cpu_aot_fuzz_smoke$' -V

Release: same 12,520 comparisons, 0.37 s.

Manual long run: cmake --preset dev -DCPU_FUZZ_SEED=0xCCD1 -DCPU_FUZZ_FUNCTIONS=96, then the same test: 60,096 comparisons in 1.09 s.

python -B tests/docs_links_check.py (13 files, 178 links), python -B tests/bidi_controls_check.py (718 files) and git diff --check pass.

Evidence and follow-up

  • The generator and fixtures are source-built in this repository and add no dependency. Generated output stays under the build tree.
  • This answers the #446 questions with the smallest useful smoke: cpu_switch_aot first, 20 functions at about 0.4 s per Windows job, seed-only by default, and a documented promotion path to fixed cpu_asm_fixture/cpu_translation fixtures for cases worth keeping.
  • The current scope is leaf ALU, flags and forward branches. Frames, calls, shared callees, tail jumps, dead reads and fault equivalence are follow-ups. The /O2 build is the first hook for the dead-read class.
  • The comparator has a self-test. A planted translator mutation is not part of this first smoke.
  • No game files, dumps, distribution links or secrets.

Checklist

  • This pull request covers one reviewable behavior.
  • I included the exact command and result for every check I ran.
  • I considered a negative control or failure case for a new fixture.
  • I updated README/docs when a capability or build requirement changed.
  • I did not include game files, dumps, distribution links or secrets.

AI-assisted.

**@⁠triggered02** on GitHub · 2026-11-23 16:18 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/894) `triggered02:tooling/cpu-differential-fuzz` → `main` · +356 −0 · 4 files · 2 commits · merged 2026-11-23 16:46 UTC Refs #446. ## Change Adds a deterministic differential fuzz smoke for the shared `cpu_switch_aot` lifter. `tools/fuzz_cpu.py` generates 20 leaf functions from seed `0xA902` covering 8-, 16-, 32- and 64-bit ALU chains, shifts and rotates, CMP/TEST producers feeding SETcc/CMOVcc/Jcc consumers, a forward branch diamond, and a Jcc to its own fallthrough. The build assembles one MASM DLL, translates all exports into one C++ source, and builds that source at the preset's optimization plus an explicit `/O2` build. The test runs native, default-translated and `/O2`-translated exports over 313 deterministic input pairs per function and compares RAX plus a guarded 256-byte output buffer. A mismatch prints the seed, function, input, native/lifted values and the one-function MASM; `--only NAME --input INDEX` reproduces one case. `CPU_FUZZ_FUNCTIONS` and `CPU_FUZZ_SEED` configure a longer manual run. ## Verification Windows 11 Pro 26200, MSVC 19.52, CMake/Ninja, Ryzen 5 5500 (no GPU involved). ```powershell ctest --preset dev --no-tests=error -R '^cpu_aot_fuzz_smoke$' -V ``` Dev: seed 0xA902, 20 functions, 313 inputs, 12,520 comparisons, 0.37 s. ```powershell ctest --preset release --no-tests=error -R '^cpu_aot_fuzz_smoke$' -V ``` Release: same 12,520 comparisons, 0.37 s. Manual long run: `cmake --preset dev -DCPU_FUZZ_SEED=0xCCD1 -DCPU_FUZZ_FUNCTIONS=96`, then the same test: 60,096 comparisons in 1.09 s. `python -B tests/docs_links_check.py` (13 files, 178 links), `python -B tests/bidi_controls_check.py` (718 files) and `git diff --check` pass. ## Evidence and follow-up - The generator and fixtures are source-built in this repository and add no dependency. Generated output stays under the build tree. - This answers the #446 questions with the smallest useful smoke: `cpu_switch_aot` first, 20 functions at about 0.4 s per Windows job, seed-only by default, and a documented promotion path to fixed `cpu_asm_fixture`/`cpu_translation` fixtures for cases worth keeping. - The current scope is leaf ALU, flags and forward branches. Frames, calls, shared callees, tail jumps, dead reads and fault equivalence are follow-ups. The `/O2` build is the first hook for the dead-read class. - The comparator has a self-test. A planted translator mutation is not part of this first smoke. - No game files, dumps, distribution links or secrets. ## Checklist - [x] This pull request covers one reviewable behavior. - [x] I included the exact command and result for every check I ran. - [x] I considered a negative control or failure case for a new fixture. - [x] I updated README/docs when a capability or build requirement changed. - [x] I did not include game files, dumps, distribution links or secrets. AI-assisted.
Generate 20 leaf functions from seed 0xA902 for cpu_switch_aot, translate them, and compare native, default and /O2 builds over 313 inputs each. Refs #446.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 22:26:28 +00:00
github manually merged commit b3f0076690 into gh-pr/894/base 2026-11-26 22:26:30 +00:00
Author
Owner

@⁠chatgpt-codex-connector[bot] on GitHub · 2026-11-23 16:18 UTC · original · edited 2026-11-23 16:34 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-23T16:34:47.797991Z b3f0076 Manual request
ℹ️ 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-23 16:18 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/894#issuecomment-7106935273) · edited 2026-11-23 16:34 UTC <!-- codex-pull-request-review-summary --> <!-- codex-review-state:v1 {"code_review":{"commit_sha":"b3f007669011040bfda003fce004cbb0300bd892","has_any_findings":false,"has_unresolved_findings":false,"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-23T16:34:47.797991Z">2026-11-23T16:34:47.797991Z</relative-time> | `b3f0076` | Manual request | <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>
@ -0,0 +218,4 @@
if count <= 0:
raise SystemExit("CPU_FUZZ_FUNCTIONS must be positive")
selected = [function for function in functions if only is None or function.name == only]
selected_inputs = [(index, value) for index, value in enumerate(inputs) if input_index is None or index == input_index]
Author
Owner

@⁠chatgpt-codex-connector[bot] on GitHub · 2026-11-23 16:22 UTC · original

P2 Badge Reject empty fuzz selections

When a caller mistypes --only NAME or supplies an out-of-range or negative --input, these comprehensions leave a selection empty. The command then performs no comparisons but still prints that the default and /O2 builds matched and exits successfully, making an invalid reproduction filter look like a pass; fail when either selection is empty.

AGENTS.md reference: AGENTS.md:L75-L76

Useful? React with 👍 / 👎.

**@⁠chatgpt-codex-connector[bot]** on GitHub · 2026-11-23 16:22 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/894#discussion_r4668604042) **<sub><sub>![P2 Badge](https://img.shields.io/badge/P2-yellow?style=flat)</sub></sub> Reject empty fuzz selections** When a caller mistypes `--only NAME` or supplies an out-of-range or negative `--input`, these comprehensions leave a selection empty. The command then performs no comparisons but still prints that the default and `/O2` builds matched and exits successfully, making an invalid reproduction filter look like a pass; fail when either selection is empty. AGENTS.md reference: [AGENTS.md:L75-L76](https://github.com/R0Y00/Xbox2Windows/blob/638e95ed49f2203ec4902b8e660007b5ae037b65/AGENTS.md#L75-L76) Useful? React with 👍 / 👎. <!-- codex-code-review-finding:v1 -->
@ -0,0 +218,4 @@
if count <= 0:
raise SystemExit("CPU_FUZZ_FUNCTIONS must be positive")
selected = [function for function in functions if only is None or function.name == only]
selected_inputs = [(index, value) for index, value in enumerate(inputs) if input_index is None or index == input_index]
Author
Owner

@⁠triggered02 on GitHub · 2026-11-23 16:30 UTC · original

Fixed in b3f0076: an empty --only or --input selection now exits non-zero before any comparison, and a non-positive CPU_FUZZ_FUNCTIONS is rejected. Verified --only fuzz_0 --input 0 passes (2 comparisons); --only nope, --input 999 and count 0 fail; cpu_aot_fuzz_smoke still passes.

**@⁠triggered02** on GitHub · 2026-11-23 16:30 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/894#discussion_r4668711096) Fixed in `b3f0076`: an empty `--only` or `--input` selection now exits non-zero before any comparison, and a non-positive `CPU_FUZZ_FUNCTIONS` is rejected. Verified `--only fuzz_0 --input 0` passes (2 comparisons); `--only nope`, `--input 999` and count 0 fail; `cpu_aot_fuzz_smoke` still passes.
Author
Owner

@⁠triggered02 on GitHub · 2026-11-23 16:31 UTC · original

@⁠codex review

**@⁠triggered02** on GitHub · 2026-11-23 16:31 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/894#issuecomment-7107267688) @⁠codex review
Author
Owner

@⁠chatgpt-codex-connector[bot] on GitHub · 2026-11-23 16:34 UTC · original

Codex Review: Didn't find any major issues. More of your lovely PRs please.

Reviewed commit: b3f0076690

ℹ️ 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-23 16:34 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/894#issuecomment-7107350379) <!-- codex-review-receipt:v1 --> Codex Review: Didn't find any major issues. More of your lovely PRs please. **Reviewed commit:** `b3f0076690` <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>
Author
Owner

@⁠chatgpt-codex-connector[bot] on GitHub · 2026-11-23 16:22 UTC · original · reviewed

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 638e95ed49

ℹ️ 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-23 16:22 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/894#pullrequestreview-6025216714) · **reviewed** <!-- codex-review-receipt:v1 --> ### 💡 Codex Review Here are some automated review suggestions for this pull request. **Reviewed commit:** `638e95ed49` <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>
This discussion has been locked. Commenting is limited to contributors.
No description provided.