tooling: harden atomic writes, path guards, and CLI entry in cpu_call_aot with synthetic PE32+ suite #3128
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!3128
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3126"
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-27 16:18 UTC · original
Ammmae0x:cpu/call-aot-cli→main· +988 −6 · 4 files · 1 commits · merged 2026-11-27 20:55 UTCChange
Harden
tools/cpu_call_aot.pyCLI validation, import-binding guards, and atomic file writes, and add a standalone pure-Python synthetic PE32+ verification suite:main(argv=None) -> intand runraise SystemExit(main())underif __name__ == "__main__"._validate_paths(image exists and is not a directory, non-empty export string,.cppoutput suffix, output is not a symlink or directory, no output ancestor is a file/non-directory, valid--bind/--link-namecombinations, and output does not alias image or provider viaresolve()orsamefile()).link_nameand non-file provider paths directly inresolve_import()andtranslate().write_textwith sibling-temp atomic writes in_write_atomic(creating missing parent directories and unlinking temp files on any failure).tests/cpu_call_aot_cli_check.py(direct & ordinal IAT--link-namesynthesis, mixed/overlapping/non-pointer R8/out-of-trace/non-exec refusals, hostile paths,os.replacefailure, and fast self-mutation tests) and registercpu_call_aot_cli_checkviatests/cmake/cpu_call_aot_cli.cmakeandtests/checks/python-linux/cpu_call_aot_cli.txt.Verification
Verified on commit
48f0572cin the primary workspace:out\pe-env\Scripts\python.exe -B tests/cpu_call_aot_cli_check.py -v->Ran 7 tests ... OK(exit 0, including 10 fast mutations).out\pe-env\Scripts\python.exe -B tests/cpu/malformed_pe_check.py->ok(exit 0).out\pe-env\Scripts\python.exe -B -c "import sys; sys.path.insert(0, 'tests/cpu'); import repeat_call_check; repeat_call_check.check_mixed_calls()"->mixed direct/import calls and two distinct IAT slots are rejected(exit 0).out\pe-env\Scripts\python.exe -B tests/run_checks_fragments_check.py->run_checks_fragments_check ok(exit 0).out\pe-env\Scripts\python.exe -B tests/form_coverage_check.py->form coverage checks passed(exit 0).out\pe-env\Scripts\python.exe -B tests/docs_links_check.py->Self-test passed. Checked 96 Markdown files and 586 links.(exit 0).out\pe-env\Scripts\python.exe -B tests/bidi_controls_check.py->Self-test passed. Checked 2311 tracked source, script and build/CI files: no bidirectional controls.(exit 0).tools/cpu_call_aot.py: 3/3 mutations killed (_validate_pathsbypassed -> exit 1, 25 failures;link_nameempty guard bypassed inresolve_import()-> exit 1, 2 failures;_write_atomicreplaced -> exit 1, 4 failures).Evidence and follow-up
All synthetic PE32+ fixtures are generated directly in
tests/cpu_call_aot_cli_check.py; no external binaries or game files are used.Checklist
AI-assisted.
github-bot referenced this pull request2026-11-27 16:21:57 +00:00
@KelboLive on GitHub · 2026-11-27 18:50 UTC · original · approved these changes
Consistent hardening of
cpu_call_aot.pymatching the established pattern: extractedmain(argv), comprehensive path validation, atomic writes with proper cleanup, and thorough synthetic PE32+ test suite covering hostile paths, binding guards, and mutation survival. Approved.@pigalot on GitHub · 2026-11-27 20:55 UTC · original · approved these changes
I reviewed
48f0572cmerged over currentmain9e7eab5b. The merge is clean (tree01677bc0) andgit diff --cached --checkis clean.What I traced.
Command-line callers: the only ones are the
cpu_translation(... cpu_call_aot ...)rules inCMakeLists.txt(call_mix,call_twice,call_pair, and thePROVIDERvariants). Each writes${BIND_NAME}.cpp, and--bindalways gets a built provider DLL, so the new upfront guards refuse nothing the build does.resolve_import: it is also imported bycpu_exe_aot.py,cpu_switch_aot.pyandtests/cpu/import_check.py. The newPath(provider)and thelink_nameguard accept every call they make.Changed error messages:
translatenow checks the provider before parsing the image. Two refusals therefore reportmissing provider for <dll>!<symbol>when the provider is absent, where main gave a different message:provider binding supplied for a direct call);unbound import ...).Both are still refused, and no existing test pins the older message.
Line endings: as in #3111, the output changes from CRLF to LF on Windows (main's
write_texttranslates newlines).What I ran.
dev: full build, thenAll 300 pass, including
cpu_call_aot_cli_check. One capability skip,cpu_aot_sysdesc, doesn't use this tool.release: full build, then the call tests:cpu_call_aot_cli_check,cpu_aot_direct_call,cpu_aot_call_pair,cpu_aot_repeated_call,cpu_aot_import_call,cpu_aot_ordinal_import,cpu_aot_import_tail_jump,cpu_aot_exe_call_targetsandcpu_aot_exe_nested_calls. 9/9 pass.Mutants in
tools/cpu_call_aot.py, each run againsttests/cpu_call_aot_cli_check.py:translateprovideris_file()check removed_validate_pathsprovideris_file()check removedresolve_importemptylink_nameguard removed_validate_paths.suffix.lower()→.suffixresolve()samefile()except BaseException→except Exceptionnewline="\n"removedNon-blocking.
KeyboardInterruptraised from the patchedos.replacewould pin theBaseExceptioncleanup, and a byte check would pin LF output.link_namechecks appear in both_validate_pathsandtranslate. The copy intranslatecovers library callers, so keeping both is defensible, but one shared helper would stop the two copies from drifting apart.Verdict: approve on
48f0572c.Environment: Windows 11 25H2 build 26200.9974; MSVC 19.52.37029; Python 3.12.10.
CI:
Build and test on Windows,Assemble and translate gfx1013 fixturesandRun platform-independent Python checks on Linuxpass on48f0572c.This reply was AI-assisted.