runtime: add upfront CLI guards and atomic writes to bink_heap_aot with CLI suite #2619
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2627"
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 Ammmae0x on 2026-11-25T23:33:44Z.
Change
Add upfront CLI validation and atomic sibling-temp writes in
tools/bink_heap_aot.pyand add a pure-Python CLI/error test suite intests/bink_heap_aot_cli_check.py(registered asruntime_bink_heap_aot_cli_checkinCMakeLists.txtwithTIMEOUT 60):main(argv=None) -> intreturn0and propagate viaraise SystemExit(main())under__main__.args.imageupfront (reject directories and missing/non-regular files), reject negative--entriesRVAs and blank--group-entrystrings, and validateargs.output(require.cppsuffix, reject symlinks, directories, non-directory parent/ancestors, and same-path / hardlink-samefilecollisions withargs.image) before callinggenerate().args.output.write_text(...)with sibling-temp_write_atomic(...)creating missing parent directories and unlinking the temporary file on any failure (0 leftover.tmpfiles), catching(ValueError, OSError, struct.error, pefile.PEFormatError)cleanly on stderr with no tracebacks and preservingtests/bink_heap_aot_check.py.AI-assisted.
Verification
Tested on commit
e766269c(rebased onupstream/main) without\pe-env\Scripts\python.exe -B:out\pe-env\Scripts\python.exe -B tests\bink_heap_aot_check.py -v: 12 tests OK (exit 0).out\pe-env\Scripts\python.exe -B tests\bink_heap_aot_cli_check.py -v: 8 tests OK (exit 0), covering nested-dir atomic.cppcreation and overwrite with 0.tmpfiles,--entries/--group-entryforwarding,sys.argv/__main__entrypoint, dir/missing image, invalid PE bytes, negative--entries, empty/blank--group-entry, non-.cpp/dir/symlink/file-parent/samefile output guards, atomic replace failure cleanup, and Python 3.14-safeargparseerrors.--entries, blank--group-entry,output.is_symlink(), andtmp_path.unlinkcleanup); 4/4 mutations killed bytests\bink_heap_aot_cli_check.pyand restored cleanly.out\pe-env\Scripts\python.exe -B tests\form_coverage_check.py: passed (exit 0).out\pe-env\Scripts\python.exe -B tests\docs_links_check.py: passed (exit 0).out\pe-env\Scripts\python.exe -B tests\bidi_controls_check.py: passed (exit 0).Evidence and follow-up
All fixtures in
tests/bink_heap_aot_cli_check.pyare pure-Python synthetic placeholders and invalid-PE controls (MIT License). No existing CLI flags, exit codes, or build prerequisites changed.Checklist
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T23:37:29Z.
Review: COMMENTED
Review of head
e766269c(comment only).Result: sound, no blocking findings.
What I checked
tools/bink_heap_aot.py:_validate_argsruns beforegenerate();_write_atomicwrites a sibling temp file and replaces it, and removes the temp file on any failure.main()now returns 0 and exits viaSystemExit(main()). The old suffix/same-path check is kept, now with a hardlinksamefilecheck too.tests/bink_heap_aot_cli_check.pyis registered inCMakeLists.txtnext tobink_heap_aot_check, with a 60 s timeout. The existing suite is untouched.Commands run locally (Linux, pefile + iced-x86 in a throwaway venv)
python3 -B tests/bink_heap_aot_check.py: 12 tests OKpython3 -B tests/bink_heap_aot_cli_check.py: 8 tests OKpython3 tests/docs_links_check.py: OKpython3 tests/bidi_controls_check.py: OKgit diff --check origin/main...HEAD: cleanmkdir(parents=True): 1 failure--entriescheck: 1 failureNot covered by this review: Windows run (CMake registration is exercised only by the Windows CTest run).
AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T23:38:12Z.
Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit
e766269c43789d5d67cc0dd1a366bfbe76bd89cc:--preset dev):cmake --build --preset dev --target cpu_bink_descriptors_lifted cpu_bink_frame_to_heap_objects cpu_bink_heap_lifted -- -j 2):0.87s(configure2.27s)ctest --preset dev -R 'bink_heap_aot' --parallel 4 --no-tests=error --output-on-failure): 2/2 passed (6.41s:bink_heap_aot_check1.45s,runtime_bink_heap_aot_cli_check6.26s)/O2(--preset release):cmake --build --preset release --target cpu_bink_descriptors_lifted cpu_bink_frame_to_heap_objects cpu_bink_heap_lifted -- -j 2):6.42s(configure2.32s)ctest --preset release -R 'bink_heap_aot' --parallel 4 --no-tests=error --output-on-failure): 2/2 passed (6.48s:bink_heap_aot_check1.38s,runtime_bink_heap_aot_cli_check6.33s)sccache: 61/64 hits; wall24.2sAI-assisted; commands listed were executed locally.