tooling: reject malformed debug_launch.py option values before launching #2796

Merged
RenzoWit35 merged 1 commit from upstream-pr/2804 into main 2026-11-26 11:07:57 +00:00
RenzoWit35 commented 2026-11-26 11:00:29 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by RenzoWit35 on 2026-11-26T11:00:29Z.


Change

tools/startup/debug_launch.py converted --timeout, --memory-gib and --continue-asserts before its validation block:

  • --timeout abc, --memory-gib abc, --continue-asserts x ended in a ValueError traceback.
  • --memory-gib inf ended in an OverflowError traceback and --memory-gib nan in a ValueError traceback.
  • --memory-gib -1, 0, 1e-12 and 1e30 reached CreateProcess with a negative, zero or truncated job memory limit.

The three conversions are now inside a try, and --memory-gib must be finite, at least one byte and below the size_t range. Each bad value prints one expected ... 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 in launch.py: this tool always sets JOB_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 with expected , no Traceback, 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 CTest startup_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.
  • Negative control: the same check pointed at the origin/main copy of the tool (with its launch.py and host_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|1e30 and --continue-asserts -2 reached CreateProcess failed 2 or 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.py and tests/startup_host_cpu_debug_check.py need a built probe; they pass only valid --timeout and --continue-asserts values. CTest registration was not configured locally. python -B tests/startup_run_sh_check.py exits 77 on Windows (a POSIX launcher), so the Wine path is not covered here.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6625189732 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2804). Originally posted by [RenzoWit35](https://github.com/RenzoWit35) on 2026-11-26T11:00:29Z. --- ## Change `tools/startup/debug_launch.py` converted `--timeout`, `--memory-gib` and `--continue-asserts` before its validation block: - `--timeout abc`, `--memory-gib abc`, `--continue-asserts x` ended in a `ValueError` traceback. - `--memory-gib inf` ended in an `OverflowError` traceback and `--memory-gib nan` in a `ValueError` traceback. - `--memory-gib -1`, `0`, `1e-12` and `1e30` reached `CreateProcess` with a negative, zero or truncated job memory limit. The three conversions are now inside a `try`, and `--memory-gib` must be finite, at least one byte and below the `size_t` range. Each bad value prints one `expected ...` 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 in `launch.py`: this tool always sets `JOB_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 with `expected `, no `Traceback`, 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 CTest `startup_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. - Negative control: the same check pointed at the `origin/main` copy of the tool (with its `launch.py` and `host_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|1e30` and `--continue-asserts -2` reached `CreateProcess failed 2` or 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.py` and `tests/startup_host_cpu_debug_check.py` need a built probe; they pass only valid `--timeout` and `--continue-asserts` values. CTest registration was not configured locally. `python -B tests/startup_run_sh_check.py` exits 77 on Windows (a POSIX launcher), so the Wine path is not covered here. AI-assisted.
upstream-sync closed this pull request 2026-11-26 12:04:44 +00:00
tedin7 commented 2026-11-26 12:04:44 +00:00 (Migrated from github.com)

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 one try; nan and inf fail the 1 <= x * 2**30 < 2**(8*sizeof(size_t)) test (comparisons with nan are false, inf is not below the bound), 0, negatives and 1e-12 fail the lower bound, 1e30 fails the upper bound. Each path returns 2 before the log directory, job object or process exists. The timeout and assertion-limit rule is unchanged.
  • Sibling check: the launch.py difference (zero allowed there) is explained in the body and is right for a tool that always sets the job memory limit.
  • Test: tests/startup_debug_launch_args_check.py covers 15 bad values and asserts exit code 2, one expected line, no traceback and no log directory. It is registered through the tests/cmake/*.cmake glob and skips with 77 off Windows, so it can only prove the behavior on a Windows host.
  • No other open or merged PR covers this option block.

Commands run locally (Linux):

  • git diff --check origin/main...HEAD: clean
  • python3 tests/docs_links_check.py: ok
  • python3 tests/bidi_controls_check.py: ok
  • python3 -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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6073051800 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2804#pullrequestreview-6073051800). Originally posted by [tedin7](https://github.com/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 one `try`; `nan` and `inf` fail the `1 <= x * 2**30 < 2**(8*sizeof(size_t))` test (comparisons with nan are false, inf is not below the bound), `0`, negatives and `1e-12` fail the lower bound, `1e30` fails the upper bound. Each path returns 2 before the log directory, job object or process exists. The timeout and assertion-limit rule is unchanged. - Sibling check: the `launch.py` difference (zero allowed there) is explained in the body and is right for a tool that always sets the job memory limit. - Test: `tests/startup_debug_launch_args_check.py` covers 15 bad values and asserts exit code 2, one `expected ` line, no traceback and no log directory. It is registered through the `tests/cmake/*.cmake` glob and skips with 77 off Windows, so it can only prove the behavior on a Windows host. - No other open or merged PR covers this option block. Commands run locally (Linux): - `git diff --check origin/main...HEAD`: clean - `python3 tests/docs_links_check.py`: ok - `python3 tests/bidi_controls_check.py`: ok - `python3 -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.
tedin7 commented 2026-11-26 12:04:54 +00:00 (Migrated from github.com)

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:

  • Debug (--preset dev):
    • Build (cmake --build --preset dev --target startup_debug_calls -- -j 2): 0.17s (configure 2.53s)
    • Test (ctest --preset dev -R 'startup_debug_launch_args' --parallel 2 --no-tests=error --output-on-failure): 1/1 passed (1.36s: startup_debug_launch_args 1.20s)
  • Release /O2 (--preset release):
    • Build (cmake --build --preset release --target startup_debug_calls -- -j 2): 1.37s (configure 2.43s)
    • Test (ctest --preset release -R 'startup_debug_launch_args' --parallel 2 --no-tests=error --output-on-failure): 1/1 passed (1.43s: startup_debug_launch_args 1.31s)
  • Windows Python checks: tests/startup_debug_launch_args_check.py ok (1.3s)
  • sccache: 1/9 hits; wall 15.2s

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7190309660 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2804#issuecomment-7190309660). Originally posted by [tedin7](https://github.com/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`: - **Debug (`--preset dev`)**: - Build (`cmake --build --preset dev --target startup_debug_calls -- -j 2`): `0.17s` (configure `2.53s`) - Test (`ctest --preset dev -R 'startup_debug_launch_args' --parallel 2 --no-tests=error --output-on-failure`): **1/1 passed** (`1.36s`: `startup_debug_launch_args` `1.20s`) - **Release `/O2` (`--preset release`)**: - Build (`cmake --build --preset release --target startup_debug_calls -- -j 2`): `1.37s` (configure `2.43s`) - Test (`ctest --preset release -R 'startup_debug_launch_args' --parallel 2 --no-tests=error --output-on-failure`): **1/1 passed** (`1.43s`: `startup_debug_launch_args` `1.31s`) - **Windows Python checks**: `tests/startup_debug_launch_args_check.py` ok (`1.3s`) - `sccache`: 1/9 hits; wall `15.2s` AI-assisted; commands listed were executed locally.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
R0Y00/Xbox2Windows!2796
No description provided.