tooling: add stack_args differential fuzz area #3655

Manually merged
github merged 1 commit from github-bot/gh-3653 into main 2026-12-01 01:19:27 +00:00 AGit
Owner

@⁠Ammmae0x on GitHub · 2026-11-30 21:43 UTC · original
Ammmae0x:tooling/fuzz-cpu-stack-args → main · +1092 −2 · 5 files · 1 commits · merged 2026-12-01 01:17 UTC

Refs #446

Adds --area stack_args to tools/fuzz_cpu.py: internal callees taking 5th-8th stack arguments ([rsp+20h]..[rsp+38h]) in 8/16/32/64-bit widths, with single/pair/cond/fwd/rec caller recipes, two refusal controls and a stack-slot-swapping mutant.

  • Only tools/fuzz_cpu.py changes among tracked files; new tests/cmake/cpu_fuzz_stack_args.cmake (targets cpu_fuzz_stack_args, cpu_fuzz_stack_args_lifted, cpu_fuzz_stack_args_o2, test cpu_aot_fuzz_stack_args), tests/fuzz_cpu_stack_args_check.py + tests/checks/python-linux/fuzz_cpu_stack_args.txt, and docs/experiments/cpu-aot-fuzz-stack-args.md.
  • All 11 existing AREAS seed streams byte-identical.

Linux (Python 3.12.3 in /tmp/pe-env):

  • tests/fuzz_cpu_stack_args_check.py: 10 tests, OK.
  • tests/form_coverage_check.py, tests/docs_links_check.py (193 files, 749 links), tests/bidi_controls_check.py (2762 files): pass.
  • Scratch translation/emulation (keystone + Unicorn, not committed): 34 functions assemble to a 2868-byte blob; a minimal PE64 DLL exports the 24 callers; the translator accepts all 24 with all six demand tuples present and refuses both controls with their exact substrings; the mutant changes the translation; Unicorn runs all 313 inputs x 24 callers (7512 runs) and matches the Python reference return + full 288-byte buffer every time. This caught one real bug: the pair spill at [rsp+40h] collided with the saved-RDI slot, so pair callers now save R12 and subtract 48h.
  • Mutation audit, 8/8 killed on /tmp copies only.

Note: in this clone origin is R0Y00/Xbox2Windows and the fork is remote fork (Ammmae0x/Xbox2Windows), so the branch was pushed to the fork.

Windows ML64/cl execution awaits verification.

Windows Verification (603fd189)

Commit: 603fd189cf0e57819674cf73e29fcc933bae28de (merge-tree upstream/main HEAD -> 8d9e9e91, exit 0; git diff --check clean)
dev: cmake --build --preset dev --target cpu_fuzz_stack_args cpu_fuzz_stack_args_lifted cpu_fuzz_stack_args_o2 cpu_fuzz cpu_fuzz_lifted cpu_fuzz_lifted_o2 && ctest --preset dev --no-tests=error -R "^(cpu_aot_fuzz_stack_args|tooling_fuzz_cpu_stack_args_check|cpu_aot_fuzz_smoke|tooling_fuzz_cpu_cli_check)$" --output-on-failure -> 4/4 passed (12.48s; stack_args 0.60s: 24 fns x 313 inputs = 15,024 comparisons matched, 2 controls refused, swap_stack_args mutant 4938/7512 mismatches in 17/24 fns)
release: cmake --build --preset release --target cpu_fuzz_stack_args cpu_fuzz_stack_args_lifted cpu_fuzz_stack_args_o2 cpu_fuzz cpu_fuzz_lifted cpu_fuzz_lifted_o2 && ctest --preset release --no-tests=error -R "^(cpu_aot_fuzz_stack_args|tooling_fuzz_cpu_stack_args_check|cpu_aot_fuzz_smoke|tooling_fuzz_cpu_cli_check)$" -E "cpu_native_archive_" --output-on-failure -> 4/4 passed (12.38s)
Checks: fuzz_cpu_stack_args_check.py (10/10 OK), fuzz_cpu_cli_check.py (9/9 OK), form_coverage_check.py, docs_links_check.py (193 files, 749 links), bidi_controls_check.py (2764 files) -> passed

AI-assisted.

**@⁠Ammmae0x** on GitHub · 2026-11-30 21:43 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3653) `Ammmae0x:tooling/fuzz-cpu-stack-args` → `main` · +1092 −2 · 5 files · 1 commits · merged 2026-12-01 01:17 UTC Refs #446 Adds `--area stack_args` to `tools/fuzz_cpu.py`: internal callees taking 5th-8th stack arguments (`[rsp+20h]`..`[rsp+38h]`) in 8/16/32/64-bit widths, with single/pair/cond/fwd/rec caller recipes, two refusal controls and a stack-slot-swapping mutant. - Only `tools/fuzz_cpu.py` changes among tracked files; new `tests/cmake/cpu_fuzz_stack_args.cmake` (targets `cpu_fuzz_stack_args`, `cpu_fuzz_stack_args_lifted`, `cpu_fuzz_stack_args_o2`, test `cpu_aot_fuzz_stack_args`), `tests/fuzz_cpu_stack_args_check.py` + `tests/checks/python-linux/fuzz_cpu_stack_args.txt`, and `docs/experiments/cpu-aot-fuzz-stack-args.md`. - All 11 existing AREAS seed streams byte-identical. Linux (Python 3.12.3 in /tmp/pe-env): - `tests/fuzz_cpu_stack_args_check.py`: 10 tests, OK. - `tests/form_coverage_check.py`, `tests/docs_links_check.py` (193 files, 749 links), `tests/bidi_controls_check.py` (2762 files): pass. - Scratch translation/emulation (keystone + Unicorn, not committed): 34 functions assemble to a 2868-byte blob; a minimal PE64 DLL exports the 24 callers; the translator accepts all 24 with all six demand tuples present and refuses both controls with their exact substrings; the mutant changes the translation; Unicorn runs all 313 inputs x 24 callers (7512 runs) and matches the Python reference return + full 288-byte buffer every time. This caught one real bug: the pair spill at `[rsp+40h]` collided with the saved-RDI slot, so pair callers now save R12 and subtract 48h. - Mutation audit, 8/8 killed on /tmp copies only. Note: in this clone `origin` is R0Y00/Xbox2Windows and the fork is remote `fork` (Ammmae0x/Xbox2Windows), so the branch was pushed to the fork. Windows ML64/cl execution awaits verification. ### Windows Verification (`603fd189`) ```text Commit: 603fd189cf0e57819674cf73e29fcc933bae28de (merge-tree upstream/main HEAD -> 8d9e9e91, exit 0; git diff --check clean) dev: cmake --build --preset dev --target cpu_fuzz_stack_args cpu_fuzz_stack_args_lifted cpu_fuzz_stack_args_o2 cpu_fuzz cpu_fuzz_lifted cpu_fuzz_lifted_o2 && ctest --preset dev --no-tests=error -R "^(cpu_aot_fuzz_stack_args|tooling_fuzz_cpu_stack_args_check|cpu_aot_fuzz_smoke|tooling_fuzz_cpu_cli_check)$" --output-on-failure -> 4/4 passed (12.48s; stack_args 0.60s: 24 fns x 313 inputs = 15,024 comparisons matched, 2 controls refused, swap_stack_args mutant 4938/7512 mismatches in 17/24 fns) release: cmake --build --preset release --target cpu_fuzz_stack_args cpu_fuzz_stack_args_lifted cpu_fuzz_stack_args_o2 cpu_fuzz cpu_fuzz_lifted cpu_fuzz_lifted_o2 && ctest --preset release --no-tests=error -R "^(cpu_aot_fuzz_stack_args|tooling_fuzz_cpu_stack_args_check|cpu_aot_fuzz_smoke|tooling_fuzz_cpu_cli_check)$" -E "cpu_native_archive_" --output-on-failure -> 4/4 passed (12.38s) Checks: fuzz_cpu_stack_args_check.py (10/10 OK), fuzz_cpu_cli_check.py (9/9 OK), form_coverage_check.py, docs_links_check.py (193 files, 749 links), bidi_controls_check.py (2764 files) -> passed ``` AI-assisted. <!-- WIN-VERIFY: passed | sha=603fd189cf0e57819674cf73e29fcc933bae28de | targets=cpu_fuzz_stack_args cpu_fuzz_stack_args_lifted cpu_fuzz_stack_args_o2 | ctest=^cpu_aot_fuzz_stack_args$ | release=true -->
Refs #446

Internal callees taking 5th-8th stack arguments ([rsp+20h]..[rsp+38h]),
with single/pair/cond/fwd/rec caller recipes, two refusal controls and a
stack-slot-swapping mutant. All 11 existing AREAS seed streams are
byte-identical. Linux: stack_args check 10 tests OK, form/docs/bidi pass,
scratch keystone/Unicorn run 7512 caller/input runs match the reference,
mutation audit 8/8 killed. Windows ML64/cl execution awaits verification.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-30 21:47:23 +00:00
github manually merged commit 4ddc14aca5 into main 2026-12-01 01:19:27 +00:00
Author
Owner

@⁠R0Y00 on GitHub · 2026-12-01 01:16 UTC · original · approved these changes

Reviewed the source-built stack-argument fuzz area. The fixtures distinguish arguments five through eight across operand widths and compare generated code with the original MASM fixture. ctest --test-dir <build> --no-tests=error -j1 -R '^(cpu_aot_fuzz_stack_args|tooling_fuzz_cpu_stack_args_check)$' --output-on-failure passed on Windows with MSVC, including the /O2 stack-slot-swap control.

**@⁠R0Y00** on GitHub · 2026-12-01 01:16 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3653#pullrequestreview-6123447638) · **approved these changes** Reviewed the source-built stack-argument fuzz area. The fixtures distinguish arguments five through eight across operand widths and compare generated code with the original MASM fixture. `ctest --test-dir <build> --no-tests=error -j1 -R '^(cpu_aot_fuzz_stack_args|tooling_fuzz_cpu_stack_args_check)$' --output-on-failure` passed on Windows with MSVC, including the /O2 stack-slot-swap control.
This discussion has been locked. Commenting is limited to contributors.
No description provided.