runtime: validate CLI arguments and numeric options in launch.py with dedicated unit suite #2054
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2061"
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-24T23:46:53Z.
Change
Validate CLI arguments and numeric options in
tools/startup/launch.py, harden handle cleanup, and add a pure-Python unit and CLI test suite (tests/startup_launch_cli_check.py) registered inCMakeLists.txt(startup_launch_cli_check,TIMEOUT 30):parse_args(argv)andmain(argv=None) -> intintools/startup/launch.py.<3or empty positional arguments (before--), unpaired trailing option flags (instead of silently dropping them viadict(zip(...))), unknown option flags, and invalid numeric options (--timeoutnon-numeric/<= 0/non-finite,--memory-gibnon-numeric/< 0/non-finite,--max-processesnon-integer/< 0) with a concise stderr diagnostic and exit code2before creatinglogdiror spawning processes.JOB_OBJECT_LIMIT_JOB_MEMORY(0x200) whenmemory > 0so--memory-gib 0cleanly disables the job memory cap (matching--max-processes 0).CreateProcess failed: error <N>stdout output and exit code2, and close all opened Win32 handles (out,err,thread_handle,process_handle,job) infinally.tests/startup_launch_cli_check.pycovering defaults, explicit options,--pass-through,quote_argument,prepare_storage_path,check_shader_cache_warning,format_fast_fail_diagnostic, stubbed kernel32 exit/timeout/failure paths, subprocess CLI rejections, and negative controls pinning exit code2with zero raw tracebacks and no filesystem writes on validation failure.Verification
Tested on commit
e59c15d4(rebased onupstream/main489d5797, Windows x64, Python viaout/pe-env):.\out\pe-env\Scripts\python.exe -B tests/startup_launch_cli_check.pyRan 7 tests in 0.332s—OK(exit 0)..\out\pe-env\Scripts\python.exe -B tests/startup_launch_check.py --unitlaunch-unit: storage fallback/preservation, stale shader cache warning, fast-fail diagnostics and argument quoting passed(exit 0)..\out\pe-env\Scripts\python.exe -B tests/startup_tools_lint_check.pyPASS: 7 files under tools/startup parse; control snippet rejected and valid snippet accepted(exit 0)..\out\pe-env\Scripts\python.exe -B tests/form_coverage_check.pyform coverage checks passed(exit 0)..\out\pe-env\Scripts\python.exe -B tests/docs_links_check.pySelf-test passed. Checked 18 Markdown files and 391 links.(exit 0)..\out\pe-env\Scripts\python.exe -B tests/bidi_controls_check.pySelf-test passed. Checked 1408 tracked source, script and build/CI files: no bidirectional controls.(exit 0).Note: No C++ targets were modified;
startup_launch_cli_checkis pure Python and registered next tostartup_launchinCMakeLists.txt.Evidence and follow-up
tests/startup_launch_cli_check.pyare synthetic and self-contained (Win32 handle lifecycle is exercised with a fake kernel32 stub plus real subprocess CLI checks); existingstartup_launchend-to-end probe containment tests remain intact.2, zero Python tracebacks, nologdircreation on invalid arguments, exactCreateProcess failed: error ...stdout preservation, and zero leaked handles onCreateProcessW/SetInformationJobObject/AssignProcessToJobObjectfailures.Checklist
AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-25T00:07:14Z.
I added Win32 conversion boundaries before any filesystem or process side effect. The launcher rejects the infinite wait sentinel, DWORD process-count overflow, and positive memory caps that would round to zero or exceed size_t. Explicit zero caps still disable their limits. Windows Release startup_launch and startup_launch_cli_check passed 2/2, including the real source-built child and the malformed input cases.