tooling: reject malformed debug_launch.py option values before launching #2796
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2804"
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 RenzoWit35 on 2026-11-26T11:00:29Z.
Change
tools/startup/debug_launch.pyconverted--timeout,--memory-giband--continue-assertsbefore its validation block:--timeout abc,--memory-gib abc,--continue-asserts xended in aValueErrortraceback.--memory-gib infended in anOverflowErrortraceback and--memory-gib nanin aValueErrortraceback.--memory-gib -1,0,1e-12and1e30reachedCreateProcesswith a negative, zero or truncated job memory limit.The three conversions are now inside a
try, and--memory-gibmust be finite, at least one byte and below thesize_trange. Each bad value prints oneexpected ...line and returns 2 before the log directory, the job object or the process exists. The existing timeout and assertion-limit rule is unchanged.Zero is rejected for
--memory-gib, unlike inlaunch.py: this tool always setsJOB_OBJECT_LIMIT_JOB_MEMORY(0x200), so a limit of 0 would deny the process any commit instead of meaning "no limit".Unknown options are still ignored, so open changes that add options to this file are not affected. The diff is limited to the option block in
main.Verification
New check
tests/startup_debug_launch_args_check.py(15 bad values; asserts exit code 2, a single line starting withexpected, noTraceback, no log directory created). The tool imports Windows-only ctypes entry points, so the check exits 77 on other hosts and is registered only as CTeststartup_debug_launch_args(tests/cmake/startup_debug_launch_args.cmake).python -B tests/startup_debug_launch_args_check.py->15 malformed option values rejected, exit 0.origin/maincopy of the tool (with itslaunch.pyandhost_cpu.py) in a scratch directory,python -B tests/startup_debug_launch_args_check.py <scratch>/debug_launch.py-> exit 1. Tracebacks for--timeout abc,--memory-gib abc|inf|-inf|nan,--continue-asserts x|1.5;--memory-gib -1|0|1e-12|1e30and--continue-asserts -2reachedCreateProcess failed 2or created the log directory.python -B tests/startup_run_ps1_check.py --text-only-> 0 failed (it uses a stub tool and valid values).Evidence and follow-up
Not run:
tests/startup_debug_check.pyandtests/startup_host_cpu_debug_check.pyneed a built probe; they pass only valid--timeoutand--continue-assertsvalues. CTest registration was not configured locally.python -B tests/startup_run_sh_check.pyexits 77 on Windows (a POSIX launcher), so the Wine path is not covered here.AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T11:07:22Z.
Review: COMMENTED
Review of head
0001feed(comment only).Checked against origin/main:
tools/startup/debug_launch.py: the three conversions are now inside onetry;nanandinffail the1 <= x * 2**30 < 2**(8*sizeof(size_t))test (comparisons with nan are false, inf is not below the bound),0, negatives and1e-12fail the lower bound,1e30fails the upper bound. Each path returns 2 before the log directory, job object or process exists. The timeout and assertion-limit rule is unchanged.launch.pydifference (zero allowed there) is explained in the body and is right for a tool that always sets the job memory limit.tests/startup_debug_launch_args_check.pycovers 15 bad values and asserts exit code 2, oneexpectedline, no traceback and no log directory. It is registered through thetests/cmake/*.cmakeglob and skips with 77 off Windows, so it can only prove the behavior on a Windows host.Commands run locally (Linux):
git diff --check origin/main...HEAD: cleanpython3 tests/docs_links_check.py: okpython3 tests/bidi_controls_check.py: okpython3 -B tests/startup_debug_launch_args_check.py: exit 77 (Windows-only skip, as designed)Windows run follows in a receipt.
AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T11:07:52Z.
Win2025 WARP receipt for head
0001feed.real-GPU run not available (RunPod stopped); not a shader change.
Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit
0001feed6a967abfe20cfdca3a1fbf0ed46efe32:--preset dev):cmake --build --preset dev --target startup_debug_calls -- -j 2):0.17s(configure2.53s)ctest --preset dev -R 'startup_debug_launch_args' --parallel 2 --no-tests=error --output-on-failure): 1/1 passed (1.36s:startup_debug_launch_args1.20s)/O2(--preset release):cmake --build --preset release --target startup_debug_calls -- -j 2):1.37s(configure2.43s)ctest --preset release -R 'startup_debug_launch_args' --parallel 2 --no-tests=error --output-on-failure): 1/1 passed (1.43s:startup_debug_launch_args1.31s)tests/startup_debug_launch_args_check.pyok (1.3s)sccache: 1/9 hits; wall15.2sAI-assisted; commands listed were executed locally.