tooling: add a jump-table switch area to the CPU differential fuzz #1322
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1329"
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?
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T08:16:25Z.
What
Adds
--area switchestotools/fuzz_cpu.pyand the CTestcpu_aot_fuzz_switches(same structure ascpu_aot_fuzz_frames/calls/chains, own seedCPU_FUZZ_SWITCHES_SEED=0x5717 andCPU_FUZZ_SWITCHES_FUNCTIONS=48).cpu_switch_aot.pydocuments andtests/cpu/switch*.asmalready exercise: MSVC image-relative and LLVM relative tables,JA/JAEand invertedJBE/JBbound branches, tables of 2 to 24 entries, index from ECX, RCX, anANDmask,MOVZX CL/CXor a signed clamp (TEST+CMOVS), shared and distinct arms, tables in and out of order, fall-through arms, arms with their ownRET, default before or after the check, 32- and 64-bit arms. Every arm writes its own marker word. All 48 layout x bound x index-source combinations appear once.refusedmechanism: no bound check, signedJGbound, index not zero-extended after a 32-bit compare, table base not RIP-relative.table_rotate(each table entry read one slot late); the test fails unless it differs from native.inputs_forgets an optional area argument: forswitchesthe first inputs are selectors 0 to 39 plus selectors with upper bits set. Other areas get byte-identical inputs and emitted MASM.emitdeclaresEXTERN __ImageBase:BYTEwhen a function uses it.docs/experiments.md: new paragraph after the chains one.Why
The switch lowering is only covered by hand-written fixtures; a generated set varies case counts, bound forms, index sources and arm layouts against native execution.
Tested
Windows (not run locally):
Ran on Linux:
py_compile,tests/docs_links_check.py,tests/bidi_controls_check.py,git diff --check,x2w_pipe.py preflight(OK). Generator output deterministic per seed and different across seeds.emitoutput of the four existing areas unchanged versus origin/main.Also on Linux, as a stand-in for MSVC/ML64: the generated MASM was rewritten (
IMAGERELto@IMGREL,LABEL DWORDto a plain label,LEAof a label to[rip+label]), assembled withllvm-ml-19, linked withlld-link-19, translated with the realcpu_switch_aot, built with MinGW at -O0 and -O2 and compared against native under Wine with a small loader. Default seed: 48 exports x 313 inputs = 15,024 comparisons per build, no mismatch. Seeds 0x1, 0x2, 0xBEEF at 96 exports: 30,048 each, no refusal, no mismatch. The four controls refused with the expected messages. The planted fault differed in 4,028 of 15,024 calls, in all 48 exports.NOT run locally: MSVC, ML64, the Windows
ctest, and the Pythoncheckcommand itself (it loads PE DLLs with ctypes, Windows only). The native-vs-lifted comparison above used the loader, notrun_check.Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T08:19:48Z.
Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207) at commit
632b893940b6c92eb9adf527d7824e9428dcb665:--preset dev):cpu_fuzz*targets):4.92s(configure1.54s)ctest --preset dev -R '^(cpu_aot_fuzz_calls|cpu_aot_fuzz_chains|cpu_aot_fuzz_frames|cpu_aot_fuzz_smoke|cpu_aot_fuzz_switches)$' --parallel 4 --no-tests=error --output-on-failure): 5/5 passed (1.35s:cpu_aot_fuzz_frames0.38s,cpu_aot_fuzz_smoke0.41s,cpu_aot_fuzz_chains0.39s,cpu_aot_fuzz_calls0.70s,cpu_aot_fuzz_switches0.89s)/O2(--preset release):cpu_fuzz*targets):2.42s(configure1.69s)ctest --preset release -R '^(cpu_aot_fuzz_calls|cpu_aot_fuzz_chains|cpu_aot_fuzz_frames|cpu_aot_fuzz_smoke|cpu_aot_fuzz_switches)$' --parallel 4 --no-tests=error --output-on-failure): 5/5 passed (1.35s:cpu_aot_fuzz_frames0.38s,cpu_aot_fuzz_chains0.38s,cpu_aot_fuzz_smoke0.41s,cpu_aot_fuzz_calls0.67s,cpu_aot_fuzz_switches0.89s)Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T08:20:01Z.
Codex Review Summary: ✅ Completed
This comment shows the latest Codex review activity on this pull request.
632b893ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.