tests: check the launch tool's containment on a source-built probe #1261

Manually merged
github merged 2 commits from gh-pr/1261/head into gh-pr/1261/base 2026-11-26 22:53:16 +00:00
Owner

@⁠triggered02 on GitHub · 2026-11-24 05:56 UTC · original
triggered02:x2w-launch-containment → main · +197 −2 · 5 files · 2 commits · merged 2026-11-24 06:21 UTC

Change

tools/startup/launch.py runs one executable in a kill-on-close job with a timeout, a commit cap and captured stdout/stderr, but no source-built control read any of that back (#1149 asks for checks over tools/startup/). This adds one, with no GPU and no game files:

  • tests/startup_launch_probe.cpp — the only executable the check needs. Modes: report a known exit code while writing known bytes to stdout, stderr and X2W_TRAP_LOG; sleep so the timeout has to kill it; ask for more memory than the job cap allows; start a helper process; or do nothing.
  • tests/startup_launch_check.py (ctest startup_launch) — drives launch.py through each case:
    • finished run: exit code 0x00000007 in the report, and stdout.txt, stderr.txt and trap.log hold exactly the probe's bytes;
    • timeout: a 30 s child under --timeout 1 is reported as killed after 1 s timeout with exit code 0xdead0001, and the launcher returns in under 20 s;
    • commit cap: the same 1 GiB request fails under --memory-gib 0.5 (error=1455) and succeeds under --memory-gib 4 (allocate ok 1024 MiB);
    • process limit: the same helper is blocked under --max-processes 1 (error=1816) and starts under --max-processes 2;
    • a missing executable is reported as CreateProcess failed: error ... with launcher exit code 2 instead of looking like a finished run.
  • CMakePresets.json: the pr build preset builds startup_launch_probe and the pr test filter includes startup_launch, so the Windows jobs run it on pull requests. Main-branch runs pick it up with the rest of the suite.
  • docs/startup-runtime.md: a short "Launcher check" section with the ctest command.

Verification

Release configuration (MSVC 19.52, Windows 11, Ninja):

cmake --preset release
cmake --build --preset release --target startup_launch_probe
ctest --preset release --no-tests=error -R '^startup_launch$' -V
217: launch: exit code, stdout/stderr/trap capture, 1 s timeout kill, 0.5 GiB commit cap (and its 4 GiB control),
     1-process limit (and its 2-process control) and the missing-EXE path passed
1/1 Test #217: startup_launch ...   Passed    1.76 sec

Measured controls (the limits, not the request, are what the check measures):

case result
--memory-gib 0.5, allocate 1 GiB allocate failed error=1455
--memory-gib 4, allocate 1 GiB allocate ok 1024 MiB
--max-processes 1, spawn helper spawn failed error=1816
--max-processes 2, spawn helper spawn ok
missing executable CreateProcess failed: error 2, launcher exit 2

Negative controls: with the job memory and active-process limit flags removed from launch.py, the check fails at the commit-cap assertion with AssertionError: allocate ok 1024 MiB; with X2W_TRAP_LOG removed from the child environment it fails at the trap-log assertion with AssertionError: None. Both edits were reverted.

Neighbouring startup tests still pass: startup_draw_bmp (0.04 s) and startup_plane_refresh_warp / startup_plane_refresh_hardware.

I did not touch tools/startup/gfx2hlsl.py, tools/startup/debug_launch.py or src/startup_stubs/d3d12_xs_device.cpp. No game files, dumps or logs are involved; the probe and its output are source-built.

AI-assisted (Claude Code).

**@⁠triggered02** on GitHub · 2026-11-24 05:56 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/1261) `triggered02:x2w-launch-containment` → `main` · +197 −2 · 5 files · 2 commits · merged 2026-11-24 06:21 UTC ## Change `tools/startup/launch.py` runs one executable in a kill-on-close job with a timeout, a commit cap and captured stdout/stderr, but no source-built control read any of that back (#1149 asks for checks over `tools/startup/`). This adds one, with no GPU and no game files: - `tests/startup_launch_probe.cpp` — the only executable the check needs. Modes: report a known exit code while writing known bytes to stdout, stderr and `X2W_TRAP_LOG`; sleep so the timeout has to kill it; ask for more memory than the job cap allows; start a helper process; or do nothing. - `tests/startup_launch_check.py` (ctest `startup_launch`) — drives `launch.py` through each case: - finished run: `exit code 0x00000007` in the report, and `stdout.txt`, `stderr.txt` and `trap.log` hold exactly the probe's bytes; - timeout: a 30 s child under `--timeout 1` is reported as `killed after 1 s timeout` with `exit code 0xdead0001`, and the launcher returns in under 20 s; - commit cap: the same 1 GiB request fails under `--memory-gib 0.5` (`error=1455`) and succeeds under `--memory-gib 4` (`allocate ok 1024 MiB`); - process limit: the same helper is blocked under `--max-processes 1` (`error=1816`) and starts under `--max-processes 2`; - a missing executable is reported as `CreateProcess failed: error ...` with launcher exit code 2 instead of looking like a finished run. - `CMakePresets.json`: the `pr` build preset builds `startup_launch_probe` and the `pr` test filter includes `startup_launch`, so the Windows jobs run it on pull requests. Main-branch runs pick it up with the rest of the suite. - `docs/startup-runtime.md`: a short "Launcher check" section with the ctest command. ## Verification Release configuration (MSVC 19.52, Windows 11, Ninja): ```powershell cmake --preset release cmake --build --preset release --target startup_launch_probe ctest --preset release --no-tests=error -R '^startup_launch$' -V ``` ``` 217: launch: exit code, stdout/stderr/trap capture, 1 s timeout kill, 0.5 GiB commit cap (and its 4 GiB control), 1-process limit (and its 2-process control) and the missing-EXE path passed 1/1 Test #217: startup_launch ... Passed 1.76 sec ``` Measured controls (the limits, not the request, are what the check measures): | case | result | |---|---| | `--memory-gib 0.5`, allocate 1 GiB | `allocate failed error=1455` | | `--memory-gib 4`, allocate 1 GiB | `allocate ok 1024 MiB` | | `--max-processes 1`, spawn helper | `spawn failed error=1816` | | `--max-processes 2`, spawn helper | `spawn ok` | | missing executable | `CreateProcess failed: error 2`, launcher exit 2 | Negative controls: with the job memory and active-process limit flags removed from `launch.py`, the check fails at the commit-cap assertion with `AssertionError: allocate ok 1024 MiB`; with `X2W_TRAP_LOG` removed from the child environment it fails at the trap-log assertion with `AssertionError: None`. Both edits were reverted. Neighbouring startup tests still pass: `startup_draw_bmp` (0.04 s) and `startup_plane_refresh_warp` / `startup_plane_refresh_hardware`. I did not touch `tools/startup/gfx2hlsl.py`, `tools/startup/debug_launch.py` or `src/startup_stubs/d3d12_xs_device.cpp`. No game files, dumps or logs are involved; the probe and its output are source-built. AI-assisted (Claude Code).
tools/startup/launch.py runs one executable in a kill-on-close job with a
timeout, a commit cap and captured stdout/stderr, but nothing read any of
that back. tests/startup_launch_probe.cpp is the only executable the check
needs: it reports a known exit code and writes known bytes to both streams
and the trap log, or holds memory, spawns a child or stays alive so a job
limit has to stop it.

tests/startup_launch_check.py (ctest startup_launch) drives the launcher
through each case. The same 1 GiB allocation succeeds under a 4 GiB cap and
fails under 0.5 GiB, and the same helper process is blocked at 1 process and
starts at 2, so the limits are what the check measures. The missing-EXE path
is the control for the error report. The pr preset now builds the probe and
runs the test, so the Windows jobs cover it on pull requests.

Verified on a release configuration (MSVC 19.52, Windows 11):

  ctest --preset release --no-tests=error -R '^startup_launch$' -V
  1/1 Test #217: startup_launch ... Passed 1.76 sec
  launch: exit code, stdout/stderr/trap capture, 1 s timeout kill,
  0.5 GiB commit cap (and its 4 GiB control), 1-process limit (and its
  2-process control) and the missing-EXE path passed

Negative controls, each a temporary edit to launch.py that was reverted:
- dropping the job memory and active-process limit flags makes the check
  fail with AssertionError: allocate ok 1024 MiB;
- dropping X2W_TRAP_LOG from the child environment makes it fail with
  AssertionError: None for trap.log.

Neighbouring startup tests still pass: startup_draw_bmp, and
startup_plane_refresh on WARP and hardware.

Refs #1149
The probe read X2W_TRAP_LOG with GetEnvironmentVariableA and opened it
with fopen, and took its own path with GetModuleFileNameA and started
the helper process with CreateProcessA. A launcher temp or build folder
whose name holds characters outside the active ANSI code page turned the
launcher's Unicode trap-log path into an unusable one, so the trap-log
assertion in startup_launch_check.py failed there, and the spawn control
could break for a Unicode build path.

Use _wgetenv and _wfopen for the trap log, GetModuleFileNameW for the
module path and CreateProcessW for the helper, converting the command
line to UTF-16. The fixture's output text is unchanged, so the check
reads the same lines.

Verified on a release configuration (MSVC 19.52, Windows 11, ANSI code
page 1252), with TEMP under an out folder whose name contains characters
outside that code page:
- the previous build fails at the trap-log assertion with
  AssertionError: None;
- the new build passes the whole check with that temp folder and with
  the probe itself copied to a path containing the same characters;
- ctest --preset release --no-tests=error -R '^startup_launch$' -V:
  1/1 Test #217: startup_launch ... Passed 1.89 sec.

Refs #1149
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 22:53:14 +00:00
github manually merged commit 9d05702e6a into gh-pr/1261/base 2026-11-26 22:53:16 +00:00
Author
Owner

@⁠chatgpt-codex-connector[bot] on GitHub · 2026-11-24 05:57 UTC · original · edited 2026-11-24 06:00 UTC

Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-24T06:00:20.131661Z 7b9d561 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@⁠codex review" or "@⁠codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

**@⁠chatgpt-codex-connector[bot]** on GitHub · 2026-11-24 05:57 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/1261#issuecomment-7123428393) · edited 2026-11-24 06:00 UTC <!-- codex-pull-request-review-summary --> <!-- codex-review-state:v1 {"code_review":{"commit_sha":"7b9d561c8abafed512974f1caac25e99fd603e5b","has_any_findings":true,"has_unresolved_findings":true,"status":"completed"},"security_review":{"commit_sha":null,"has_any_findings":null,"has_unresolved_findings":null,"status":null}} --> <details> <summary><strong>Codex Review Summary</strong>: ✅ Completed</summary> This comment shows the latest Codex review activity on this pull request. | Review | Status | Commit | Review trigger | | --- | --- | --- | --- | | 📝 **Code Review** | ✅ **Completed** <relative-time datetime="2026-11-24T06:00:20.131661Z">2026-11-24T06:00:20.131661Z</relative-time> | `7b9d561` | PR opened | <details> <summary>ℹ️ About Codex in GitHub</summary> <br/> [Your team has set up Codex to review pull requests in this repo](https://chatgpt.com/codex/cloud/settings/general). Reviews are triggered when you - Open a pull request for review - Mark a draft as ready - Comment "@⁠codex review" or "@⁠codex security review". Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. </details> </details>
Author
Owner

@⁠triggered02 on GitHub · 2026-11-24 05:59 UTC · original

The pull-request Windows job ran it: run 45336851507 built startup_launch_probe ([158/169] linking) and ran 7/23 Test #217: startup_launch ... Passed 1.63 sec. The whole pr suite passed, so the pr preset wiring does put the test in front of every pull request.

AI-assisted (Claude Code).

**@⁠triggered02** on GitHub · 2026-11-24 05:59 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/1261#issuecomment-7123467626) The pull-request Windows job ran it: [run 45336851507](https://github.com/R0Y00/Xbox2Windows/actions/runs/45336851507/job/138250852226) built `startup_launch_probe` ([158/169] linking) and ran `7/23 Test #217: startup_launch ... Passed 1.63 sec`. The whole `pr` suite passed, so the `pr` preset wiring does put the test in front of every pull request. AI-assisted (Claude Code).
Author
Owner

@⁠chatgpt-codex-connector[bot] on GitHub · 2026-11-24 06:00 UTC · original

P2 Badge Preserve Unicode paths in the launcher probe

On a Windows host whose temp or build path contains characters outside the active ANSI code page, launch.py passes a Unicode X2W_TRAP_LOG path, but this ANSI API and the following fopen can turn it into an unusable path, causing the trap-log assertion in startup_launch_check.py to fail; GetModuleFileNameA/CreateProcessA can likewise break the spawn control for a Unicode build path. Use wide-character path APIs throughout the fixture.

Useful? React with 👍 / 👎.

**@⁠chatgpt-codex-connector[bot]** on GitHub · 2026-11-24 06:00 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/1261#discussion_r4676108743) **<sub><sub>![P2 Badge](https://img.shields.io/badge/P2-yellow?style=flat)</sub></sub> Preserve Unicode paths in the launcher probe** On a Windows host whose temp or build path contains characters outside the active ANSI code page, `launch.py` passes a Unicode `X2W_TRAP_LOG` path, but this ANSI API and the following `fopen` can turn it into an unusable path, causing the trap-log assertion in `startup_launch_check.py` to fail; `GetModuleFileNameA`/`CreateProcessA` can likewise break the spawn control for a Unicode build path. Use wide-character path APIs throughout the fixture. Useful? React with 👍 / 👎. <!-- codex-code-review-finding:v1 -->
Author
Owner

@⁠triggered02 on GitHub · 2026-11-24 06:02 UTC · original

Fixed in 9d05702e. The fixture now reads X2W_TRAP_LOG with _wgetenv and opens it with _wfopen, takes its module path with GetModuleFileNameW, and starts the helper with CreateProcessW on a UTF-16 command line. The printed lines are unchanged, so startup_launch_check.py reads the same output.

Measured on Windows 11 with ANSI code page 1252, TEMP under an out folder whose name contains characters outside that code page:

  • before: AssertionError: None at the trap-log assertion;
  • after: the whole check passes, including the spawn control run from a probe copied to a path with those characters;
  • ctest --preset release --no-tests=error -R '^startup_launch$' -V: 1/1 Test #217: startup_launch ... Passed 1.89 sec.

Only tests/startup_launch_probe.cpp changed; tools/startup/launch.py and the other launcher files are untouched.

**@⁠triggered02** on GitHub · 2026-11-24 06:02 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/1261#discussion_r4676121433) Fixed in 9d05702e. The fixture now reads `X2W_TRAP_LOG` with `_wgetenv` and opens it with `_wfopen`, takes its module path with `GetModuleFileNameW`, and starts the helper with `CreateProcessW` on a UTF-16 command line. The printed lines are unchanged, so `startup_launch_check.py` reads the same output. Measured on Windows 11 with ANSI code page 1252, `TEMP` under an `out` folder whose name contains characters outside that code page: - before: `AssertionError: None` at the trap-log assertion; - after: the whole check passes, including the spawn control run from a probe copied to a path with those characters; - `ctest --preset release --no-tests=error -R '^startup_launch$' -V`: `1/1 Test #217: startup_launch ... Passed 1.89 sec`. Only `tests/startup_launch_probe.cpp` changed; `tools/startup/launch.py` and the other launcher files are untouched.
Author
Owner

@⁠triggered02 on GitHub · 2026-11-24 06:04 UTC · original

The Codex P2 finding is addressed in 9d05702e and the thread is resolved: the probe now reads X2W_TRAP_LOG with _wgetenv, opens it with _wfopen, takes its module path with GetModuleFileNameW and starts the helper with CreateProcessW on a UTF-16 command line, with the printed lines unchanged. Only ests/startup_launch_probe.cpp changed.

Local release run after the change: 1/1 Test #217: startup_launch ... Passed 1.89 sec. The pull-request Windows job rebuilt the probe at this head and ran 7/23 Test #222: startup_launch ... Passed 1.45 sec (run 45337467187); the whole job passed.

AI-assisted (Claude Code).

**@⁠triggered02** on GitHub · 2026-11-24 06:04 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/1261#issuecomment-7123562299) The Codex P2 finding is addressed in 9d05702e and the thread is resolved: the probe now reads X2W_TRAP_LOG with _wgetenv, opens it with _wfopen, takes its module path with GetModuleFileNameW and starts the helper with CreateProcessW on a UTF-16 command line, with the printed lines unchanged. Only ests/startup_launch_probe.cpp changed. Local release run after the change: 1/1 Test #217: startup_launch ... Passed 1.89 sec. The pull-request Windows job rebuilt the probe at this head and ran 7/23 Test #222: startup_launch ... Passed 1.45 sec ([run 45337467187](https://github.com/R0Y00/Xbox2Windows/actions/runs/45337467187/job/138252834530)); the whole job passed. AI-assisted (Claude Code).
Author
Owner

@⁠chatgpt-codex-connector[bot] on GitHub · 2026-11-24 06:00 UTC · original · reviewed

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7b9d561c8a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@⁠codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@⁠codex address that feedback".

**@⁠chatgpt-codex-connector[bot]** on GitHub · 2026-11-24 06:00 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/1261#pullrequestreview-6034416986) · **reviewed** <!-- codex-review-receipt:v1 --> ### 💡 Codex Review Here are some automated review suggestions for this pull request. **Reviewed commit:** `7b9d561c8a` <details> <summary>ℹ️ About Codex in GitHub</summary> <br/> [Your team has set up Codex to review pull requests in this repo](https://chatgpt.com/codex/cloud/settings/general). Reviews are triggered when you - Open a pull request for review - Mark a draft as ready - Comment "@⁠codex review". If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@⁠codex address that feedback". </details>
Author
Owner

@⁠tedin7 on GitHub · 2026-11-24 06:05 UTC · original · reviewed

Dual-platform peer review at 9d05702e6a7a232c120538610a7c12506aa73894:

Checks

  • Linux (x2w-rev-venv):
    • git diff --check HEAD~1..HEAD — passed
    • python -B tests/docs_links_check.py — passed (16 Markdown files, 281 links)
    • python -B tests/bidi_controls_check.py — passed (1057 tracked files)
    • python -B -m py_compile tests/startup_launch_check.py — passed
  • Windows Server 2025 (MSVC 14.44):
    • Target: startup_launch_probe
    • ctest --preset dev --no-tests=error -R '^startup_launch$': 1/1 passed (startup_launch, 2.80 s)
    • ctest --preset release --no-tests=error -R '^startup_launch$': 1/1 passed (startup_launch, 1.90 s)

Review Notes

  • tests/startup_launch_probe.cpp and tests/startup_launch_check.py form a self-contained, source-built fixture covering all five containment behaviors in tools/startup/launch.py: exit code + stdout.txt/stderr.txt/trap.log capture, 1 s timeout termination (0xdead0001), 0.5 GiB commit cap vs. 4 GiB control, 1-process limit vs. 2-process control, and missing-executable error reporting (exit code 2).
  • The update to wide-character APIs (_wgetenv, _wfopen, GetModuleFileNameW, CreateProcessW) in tests/startup_launch_probe.cpp ensures Unicode paths from launch.py and temp/build directories work reliably.
  • Minor note (non-blocking): tests/startup_launch_check.py and tests/startup_launch_probe.cpp are missing a trailing newline at EOF.
**@⁠tedin7** on GitHub · 2026-11-24 06:05 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/1261#pullrequestreview-6034464477) · **reviewed** Dual-platform peer review at `9d05702e6a7a232c120538610a7c12506aa73894`: ### Checks - **Linux (`x2w-rev-venv`)**: - `git diff --check HEAD~1..HEAD` — passed - `python -B tests/docs_links_check.py` — passed (16 Markdown files, 281 links) - `python -B tests/bidi_controls_check.py` — passed (1057 tracked files) - `python -B -m py_compile tests/startup_launch_check.py` — passed - **Windows Server 2025 (MSVC 14.44)**: - Target: `startup_launch_probe` - `ctest --preset dev --no-tests=error -R '^startup_launch$'`: **1/1 passed** (`startup_launch`, 2.80 s) - `ctest --preset release --no-tests=error -R '^startup_launch$'`: **1/1 passed** (`startup_launch`, 1.90 s) ### Review Notes - `tests/startup_launch_probe.cpp` and `tests/startup_launch_check.py` form a self-contained, source-built fixture covering all five containment behaviors in `tools/startup/launch.py`: exit code + `stdout.txt`/`stderr.txt`/`trap.log` capture, 1 s timeout termination (`0xdead0001`), 0.5 GiB commit cap vs. 4 GiB control, 1-process limit vs. 2-process control, and missing-executable error reporting (exit code 2). - The update to wide-character APIs (`_wgetenv`, `_wfopen`, `GetModuleFileNameW`, `CreateProcessW`) in `tests/startup_launch_probe.cpp` ensures Unicode paths from `launch.py` and temp/build directories work reliably. - Minor note (non-blocking): `tests/startup_launch_check.py` and `tests/startup_launch_probe.cpp` are missing a trailing newline at EOF.
This discussion has been locked. Commenting is limited to contributors.
No description provided.