tooling: add bad-pointer fault-equivalence area (fault_reads) to fuzz_cpu #3340
No reviewers
Labels
No labels
accessibility
awaiting author
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
priority: P0
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/R0Y00--Xbox2Windows!3340
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3338"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@Ammmae0x on GitHub · 2026-11-28 11:16 UTC · original
Ammmae0x:tooling/fuzz-cpu-fault-reads→main· +736 −5 · 3 files · 1 commits · merged 2026-11-29 13:03 UTCChange
Refs #446.
fault_reads(generate_fault_reads, registered inAREAS["fault_reads"]) totools/fuzz_cpu.py, generating bounded leaf functions forcpu_switch_aotthat execute dead/overwritten 8/16/32/64-bit guest memory reads ([rcx],[rdx],[rcx+disp]acrossmov,movzx/movsx/movsxd,cmp,test, ALU,cmovcc,bt, and paired loads) alongside live-read and null-skipping valid-pointer controls.MUTANTS["fault_reads"] = ("drop_dead_read", plant_drop_dead_read)removing thevolatilequalifier onload_alwaysso MSVC/O2optimizes out unused faulting reads.fuzz_cpu.py checkforfault_readsto execute isolated child probes (--_fault-probe) over valid mapped buffers (VirtualAlloc),PAGE_NOACCESSpages (VirtualProtect), unmapped low address (0x100), and null pointers against native, lifted/Od, and lifted/O2DLLs, verifying matching exit/exception status (0xC0000005on bad pointers), return value, and pre/post-fault output buffer bytes, plus verifying--mutantdrops faults under/O2.tests/fuzz_cpu_fault_check.pyand CMake registrationtests/cmake/cpu_fuzz_faults.cmake(cpu_aot_fuzz_faultsandtooling_fuzz_cpu_fault_check).AI-assisted.
Verification
Tested on commit
7f8935d4(tooling/fuzz-cpu-fault-reads) on Windows x64 (MSVC 14.50):cmake --preset dev && cmake --build --preset dev --target cpu_fuzz_fault_reads cpu_fuzz_fault_reads_lifted cpu_fuzz_fault_reads_o2(and all siblingcpu_fuzz*targets) -> exit0, 0 warnings oncpu_fuzz_fault_reads*.cmake --preset release && cmake --build --preset release --target cpu_fuzz_fault_reads cpu_fuzz_fault_reads_lifted cpu_fuzz_fault_reads_o2(and all siblingcpu_fuzz*targets) -> exit0, 0 warnings oncpu_fuzz_fault_reads*.ctest --preset dev --no-tests=error -R "^(cpu_aot_fuzz_faults|tooling_fuzz_cpu_fault_check|cpu_aot_fuzz.*)$" -E "cpu_native_archive_" --output-on-failure-> exit0(12/12passed):cpu_aot_fuzz_faults:area=fault_reads seed=0xfa17 functions=29 inputs=7 comparisons=406 default and /O2 matched;mutant drop_dead_read: 101/203 mismatches (101 dropped faults) in 25/29 functionstooling_fuzz_cpu_fault_check:Ran 5 tests in 0.059s OK+ end-to-end equivalence + negative control (/O2mutant passed aso2failed equivalence with0xc0000005)ctest --preset release --no-tests=error -R "^(cpu_aot_fuzz_faults|tooling_fuzz_cpu_fault_check|cpu_aot_fuzz.*)$" -E "cpu_native_archive_" --output-on-failure-> exit0(12/12passed).ctest --preset dev --no-tests=error -R "^tooling_fuzz_cpu_cli_check$" --output-on-failure-> exit0(1/1passed).out\pe-env\Scripts\python.exe -B tests/form_coverage_check.py,tests/docs_links_check.py,tests/bidi_controls_check.py-> all exit0.tools/fuzz_cpu.py(dropping exception status comparison, droppingfault_dropscheck, and disabling missing-needleSystemExitinplant_drop_dead_read): all 3 failedtooling_fuzz_cpu_fault_check(exit8) and were cleanly restored.Evidence and follow-up
tools/fuzz_cpu.pyunder seed0xFA17(24generated functions +5controls =29exports).SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX)and release allVirtualAllocallocations infinally.Checklist
@Leyukaka on GitHub · 2026-11-29 05:52 UTC · original · reviewed
Comment at
7f8935d4, no blocking finding. I read the diff and the code around it on main212d4b5f. Nothing was built or run.Semantics. The PR changes only tests and
tools/fuzz_cpu.py; the translator is untouched. On main,cpu_switch_aotalready reads every non-frame memory operand through the volatileload_always(cpu_switch_aot.py:977-979), withstatic_cast<void>(mem)for a CMP/TEST read nothing uses (:963-964). A CMOVcc memory source goes through the same path and is read before the condition (:1464-1465), andbt m, immreads throughoperand()(:1293). The mutant's needle matches cpu_switch_aot.py:2316 exactly. In every generated function the loaded value is never used and the flags are overwritten before any consumer. Incmov_dead,cmp r11d, r11dmakes ne/g/l false, so only the fault can show. The reported counts are consistent with the code: 203 = 29 exports x 7 probes, 406 = 203 x 2 variants, and 25/29 mutant functions = the 24 generated ones plusfuzz_fault_control_skip_zero, whose[rcx]read is dead. The four live controls use their value.Docs. No docs file changes, and the checklist's docs item is ticked. Every other fuzz area has a paragraph in docs/experiments.md (3458-3472), and :3460 and :3466 still list dead reads and fault equivalence as follow-ups. CONTRIBUTING.md:88 puts reproduction details there. Suggested: a paragraph with the seed, function and probe counts, the probe set, the mutant result and the
ctestcommand, and an update of those two lines.Tests.
prpresets neither buildcpu_fuzz_fault_reads*(CMakePresets.json:26-39) nor selectcpu_aot_fuzz_faults/tooling_fuzz_cpu_fault_check(:46-53), so the pull request check does not cover the two new tests._run_fault_probe_subprocess, and the end-to-end cases differ only by exception status. By reading, these mutations survive:or diff is not None, fuzz_cpu.py:2424-2426): no guard has a buffer-only difference;exception codeparse (:2274).volatileis verified, but only the clean source is checked (:203-205).Merge.
git merge-treeagainst main212d4b5fis clean. No other open PR touches tools/fuzz_cpu.py.@pigalot on GitHub · 2026-11-29 13:02 UTC · original · approved these changes
Independently reviewed
7f8935d4integrated overmainaf1cab5c(tree2fbcb886). The trial merge is clean andgit diff --checkis clean.What I traced. The PR adds only a generator, a checker and their tests; the translator is untouched. On
main,cpu_switch_aotalready performs every non-frame memory operand read through the volatileload_always, and an unused CMP/TEST read is kept bycapture(). The 24 generated functions at seed0xFA17hold 10movreads (four of them in two paired-load functions), 3test, 3cmp, 3bt m, imm, 2movsx, 2orand 3cmovcc, across[rcx],[rdx]and[rcx+disp]at all four widths. In each one the loaded value is overwritten before use, so only the fault and the stores around it can differ. The seven probes cover two valid layouts,PAGE_NOACCESSon either or both pointers,0x100and null.Build and tests. Built
cpu_fuzz_fault_reads,cpu_fuzz_fault_reads_liftedandcpu_fuzz_fault_reads_o2indevandrelease, then ranctest --test-dir out/build/<preset> --no-tests=error -j 1 -V -R '^(cpu_aot_fuzz_faults|tooling_fuzz_cpu_fault_check|tooling_fuzz_cpu_cli_check)$':3/3 passed in both presets, no skips. Both report
functions=29 inputs=7 comparisons=406 default and /O2 matchedandmutant drop_dead_read: 101/203 mismatches (101 dropped faults) in 25/29 functions, the same numbers as the PR body. IndevI also built the sibling fuzz targets and ran-R '^cpu_aot_fuzz': 11/11 passed. Onmainthe two new tests are not registered.Mutation tests (19 mutants,
dev, each restored afterwards;git diff --quietclean at the end).Translator mutants in
tools/cpu_switch_aot.py, rebuilt each time:operand()reads throughloadinstead ofload_always;bt m, regpath reads throughloadinstead ofload_always. The generator only emitsbt m, imm, which goes throughoperand(), so this path is not reached.Checker and generator mutants in
tools/fuzz_cpu.py:/O2-only comparison;fault_dropscheck dropped; missing-needle guard off; controls dropped from the generator.or diff is not None); native-must-fault check dropped; native valid-pointer control dropped; each of the threesaw_valid/saw_noaccess_fault/saw_low_faultend checks dropped; every mutant mismatch counted as a dropped fault; the mutant's buffer comparison dropped; the crash-retry condition in_run_fault_probe_subprocessreplaced byTrue.None of the survivors is a wrong result today: they are guards in the checker that no test exercises. Leyukaka's comment review named the first three groups by reading; I confirm them by running.
Non-blocking notes.
bt m, reg(and BTS/BTR/BTC on memory) has its ownload_alwayscall and is not generated here. One generated function with a register bit index would cover it.tests/fuzz_cpu_fault_check.pydiffer from the baseline only by status or return value. A case that differs only in the buffer, one where native does not fault on a bad pointer, and one with no valid pass would pin the nine surviving guards.docs/experiments.mdstill says, in the fuzz section, that dead reads and fault equivalence remain follow-ups, and every other area has a paragraph there. A short paragraph with the seed, the counts, the probe set and thectestcommand would bring it up to date.verify_compiled_dllssays the mutant's missingvolatileis verified; only the clean translation is checked there. The mutant is covered indirectly by the dropped-fault count.The
prpresets do not build or select the two new tests. That matches the other fuzz areas (onlycpu_aot_fuzz_smokeis in theprfilter), so I don't count it against this PR.No title run: the change is tooling and tests only.
Environment: Windows 11 25H2 build 26200.9974; MSVC 19.52.37029; Python 3.12.10. No GPU tests.
CI:
Build and test on Windowspassed on7f8935d4.Approving.
This reply was AI-assisted.
@JohnConnorNPC on GitHub · 2026-11-29 13:06 UTC · original
Independent review of head
7f8935d4againstmainaf1cab5c. Verdict: 0 MUST, 1 SHOULD, 1 NIT, merge. It was already merged as94b679e7while this review was being written, so the points below are follow-ups.Checked
git merge-tree --write-tree origin/main 7f8935d4exits 0. No commit onmainsince then touchestools/fuzz_cpu.pyor the two new test files.tools/fuzz_cpu.pyand tests change. The translator is untouched, so no default runtime or translation path moves.python -B tests/fuzz_cpu_fault_check.pygivesRan 5 tests ... OKand exit 0 (Linux, pe-env). The Windows end-to-end part was not run here. pigalot's run on the samemaincovers it.git diff --checkis clean. No binaries and no trailers.SHOULD
ctestcommand. Leyukaka raised this. The fuzz section still lists fault equivalence as to-do, and AGENTS.md asks for an update when a reproduction command changes.NIT
2. The checker guards that no test reaches, which Leyukaka listed by reading and pigalot measured, reproduce here too. Scratch mutants of the merged export leave
fuzz_cpu_fault_check.pygreen: droppingor diff is not None, passing when native does not fault, and dropping the "no valid-pointer pass" and "no PAGE_NOACCESS fault" end checks. None of these gives a wrong result today. A follow-up case for each would pin them.AI-assisted review.