startup: preserve debugger stderr and exit status #2859

Merged
louisdibiasi merged 4 commits from upstream-pr/2867 into main 2026-11-28 02:22:29 +00:00
louisdibiasi commented 2026-11-26 14:58:59 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by louisdibiasi on 2026-11-26T14:58:59Z.


Change

On Windows PowerShell 5.1, a debugger that writes to stderr can trigger NativeCommandError under the launcher's stop-on-error preference. The launcher then exits 1 before printing its summary, even when the debugger returned 0 or another exit code. Scope Continue to the debugger invocation and capture its exit code before returning to the launcher's normal error handling.

#2822 edits the same invocation to add capture arguments, and #2820 also changes this script and its check. These are separate behaviors; whichever lands later may need to carry both changes.

Verification

Windows, base b505c32b, patch head a4d2114e:

  • out\pe-env\Scripts\python.exe -B tests\startup_run_ps1_check.py — passed with Windows PowerShell 5.1 and PowerShell 7. Synthetic debugger cases cover stderr with exit 0 and 7, the watcher cleanup path, and missing Python. A source-built debugger log-open failure checks that its PermissionError reaches the summary; the no-stderr path is a control.
  • out\pe-env\Scripts\python.exe -B tests\startup_run_ps1_check.py --text-only — passed.
  • out\pe-env\Scripts\python.exe -B tests\bidi_controls_check.py — passed.
  • . .\tools\dev.ps1; cmake --build --preset pr; ctest --preset pr --no-tests=error — build passed; 36 tests passed and four min-LOD WARP tests skipped. dev.ps1 reported that vswhere.exe was not on PATH; the configured build completed.
  • git diff --check upstream/main — passed.

The first sandboxed launcher check failed to remove a still-open synthetic watcher log; the host rerun above passed. No title executable or hardware behavior was tested.

Evidence and follow-up

The debugger stub and failure input are generated by the test; the real debugger case uses repository source and a synthetic directory at the log-file path. On the unpatched script, the PowerShell 5.1 stderr cases returned 1 and missed the summary; PowerShell 7 served as a control.

AI-assisted.

Checklist

  • This pull request covers one reviewable behavior.
  • I included the exact command and result for every check I ran.
  • I considered a negative control or failure case for a new fixture.
  • I updated README/docs when a capability or build requirement changed (not applicable).
  • I did not include game files, dumps, distribution links or secrets.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:5512334734 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2867). Originally posted by [louisdibiasi](https://github.com/louisdibiasi) on 2026-11-26T14:58:59Z. --- ## Change On Windows PowerShell 5.1, a debugger that writes to stderr can trigger `NativeCommandError` under the launcher's stop-on-error preference. The launcher then exits 1 before printing its summary, even when the debugger returned 0 or another exit code. Scope `Continue` to the debugger invocation and capture its exit code before returning to the launcher's normal error handling. #2822 edits the same invocation to add capture arguments, and #2820 also changes this script and its check. These are separate behaviors; whichever lands later may need to carry both changes. ## Verification Windows, base `b505c32b`, patch head `a4d2114e`: - `out\pe-env\Scripts\python.exe -B tests\startup_run_ps1_check.py` — passed with Windows PowerShell 5.1 and PowerShell 7. Synthetic debugger cases cover stderr with exit 0 and 7, the watcher cleanup path, and missing Python. A source-built debugger log-open failure checks that its `PermissionError` reaches the summary; the no-stderr path is a control. - `out\pe-env\Scripts\python.exe -B tests\startup_run_ps1_check.py --text-only` — passed. - `out\pe-env\Scripts\python.exe -B tests\bidi_controls_check.py` — passed. - `. .\tools\dev.ps1; cmake --build --preset pr; ctest --preset pr --no-tests=error` — build passed; 36 tests passed and four min-LOD WARP tests skipped. `dev.ps1` reported that `vswhere.exe` was not on PATH; the configured build completed. - `git diff --check upstream/main` — passed. The first sandboxed launcher check failed to remove a still-open synthetic watcher log; the host rerun above passed. No title executable or hardware behavior was tested. ## Evidence and follow-up The debugger stub and failure input are generated by the test; the real debugger case uses repository source and a synthetic directory at the log-file path. On the unpatched script, the PowerShell 5.1 stderr cases returned 1 and missed the summary; PowerShell 7 served as a control. AI-assisted. ## Checklist - [x] This pull request covers one reviewable behavior. - [x] I included the exact command and result for every check I ran. - [x] I considered a negative control or failure case for a new fixture. - [x] I updated README/docs when a capability or build requirement changed (not applicable). - [x] I did not include game files, dumps, distribution links or secrets.
R0Y00 commented 2026-11-27 08:03:14 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-27T08:03:14Z.

Review: COMMENTED


The integration trial for a4d2114e after #2870 conflicts in tests/startup_run_ps1_check.py; tools/startup/run.ps1 merges cleanly. Please update against current main (3b6c38a8) and keep both the stderr/exit-status cases and #2870's three manifest controls, including the stub's title ID and storage quota fields. I’ll rerun the full fixture under Windows PowerShell 5.1 and PowerShell 7 on the updated head.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6085122555 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2867#pullrequestreview-6085122555). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-27T08:03:14Z. **Review:** COMMENTED --- The integration trial for `a4d2114e` after #2870 conflicts in `tests/startup_run_ps1_check.py`; `tools/startup/run.ps1` merges cleanly. Please update against current `main` (`3b6c38a8`) and keep both the stderr/exit-status cases and #2870's three manifest controls, including the stub's title ID and storage quota fields. I’ll rerun the full fixture under Windows PowerShell 5.1 and PowerShell 7 on the updated head.
pigalot commented 2026-11-28 02:15:20 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by pigalot on 2026-11-28T02:15:20Z.


I merged main 50e4f763 into this branch as 3dc23410 (a merge commit on top of 0f3da303; no rebase and no force-push). Against main, the branch still changes only tools/startup/run.ps1 and tests/startup_run_ps1_check.py.

Conflicts and how I resolved them.

  • tools/startup/run.ps1: main added --capture-every (@captureArgs) to the debugger call. I kept this branch's Windows PowerShell 5.1 wrapper (& { $ErrorActionPreference = "Continue"; ... $script:debuggerExit = $LASTEXITCODE } *> "$LogDir.out") and passed @traceArgs @captureArgs inside it.
  • tests/startup_run_ps1_check.py:
    • run_case now takes both sides' parameters: emit_stderr, missing_python and real_log_error from this branch, and native and cache_files from main.
    • In the output comparison, this branch's .out summary handling comes first, then main's stale shader-cache warning check.

One change outside the conflict hunks. main's debug_launch.py now imports hook_window and window_capture at the top. The real-debugger-log case copied only debug_launch.py, launch.py and host_cpu.py, so on top of main it failed:

  • with real debugger log error was not captured in the summary;
  • under both powershell and pwsh.

I added the two modules to that case's copy list. With that, tests/startup_run_ps1_check.py reports 0 failed (executed with powershell, pwsh).

What I ran. I built the whole tree in dev and release, then ran:

ctest --test-dir out/build/<preset> --no-tests=error -j 4 --output-on-failure -R '^(startup_debug.*|startup_hook.*|startup_run_ps1.*|startup_run_sh.*|startup_host_cpu_debug.*|startup_window_capture.*|startup_launch.*|startup_runtime_target.*|startup_shader_cache_revision.*)$'

14 of 15 pass in Debug and in Release /O2. startup_run_sh reports a capability skip (77), as on every Windows host; the Ubuntu job runs it.

git diff --check origin/main...HEAD is clean.

R0Y00's request on a4d2114e was to keep both the stderr/exit-status cases and #2870's manifest controls, and both are still there. This needs a review from someone other than me before it can be merged.

Environment: Windows 11 25H2 build 26200.9974, MSVC 19.52.37029, Python 3.12.10, Windows PowerShell 5.1 and PowerShell 7.

This reply was AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7232238466 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2867#issuecomment-7232238466). Originally posted by [pigalot](https://github.com/pigalot) on 2026-11-28T02:15:20Z. --- I merged `main` `50e4f763` into this branch as `3dc23410` (a merge commit on top of `0f3da303`; no rebase and no force-push). Against `main`, the branch still changes only `tools/startup/run.ps1` and `tests/startup_run_ps1_check.py`. **Conflicts and how I resolved them.** - `tools/startup/run.ps1`: `main` added `--capture-every` (`@captureArgs`) to the debugger call. I kept this branch's Windows PowerShell 5.1 wrapper (`& { $ErrorActionPreference = "Continue"; ... $script:debuggerExit = $LASTEXITCODE } *> "$LogDir.out"`) and passed `@traceArgs @captureArgs` inside it. - `tests/startup_run_ps1_check.py`: - `run_case` now takes both sides' parameters: `emit_stderr`, `missing_python` and `real_log_error` from this branch, and `native` and `cache_files` from `main`. - In the output comparison, this branch's `.out` summary handling comes first, then `main`'s stale shader-cache warning check. **One change outside the conflict hunks.** `main`'s `debug_launch.py` now imports `hook_window` and `window_capture` at the top. The real-debugger-log case copied only `debug_launch.py`, `launch.py` and `host_cpu.py`, so on top of `main` it failed: - with `real debugger log error was not captured in the summary`; - under both `powershell` and `pwsh`. I added the two modules to that case's copy list. With that, `tests/startup_run_ps1_check.py` reports `0 failed (executed with powershell, pwsh)`. **What I ran.** I built the whole tree in `dev` and `release`, then ran: ```powershell ctest --test-dir out/build/<preset> --no-tests=error -j 4 --output-on-failure -R '^(startup_debug.*|startup_hook.*|startup_run_ps1.*|startup_run_sh.*|startup_host_cpu_debug.*|startup_window_capture.*|startup_launch.*|startup_runtime_target.*|startup_shader_cache_revision.*)$' ``` 14 of 15 pass in Debug and in Release `/O2`. `startup_run_sh` reports a capability skip (77), as on every Windows host; the Ubuntu job runs it. `git diff --check origin/main...HEAD` is clean. R0Y00's request on `a4d2114e` was to keep both the stderr/exit-status cases and #2870's manifest controls, and both are still there. This needs a review from someone other than me before it can be merged. Environment: Windows 11 25H2 build 26200.9974, MSVC 19.52.37029, Python 3.12.10, Windows PowerShell 5.1 and PowerShell 7. This reply was AI-assisted.
R0Y00 commented 2026-11-28 02:22:22 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-28T02:22:22Z.

Review: APPROVED


Reviewed 3dc23410db integrated on main f9286e7d (tree 65eb01655e). The rebased fixture retains the three manifest controls from #2870. ErrorActionPreference is scoped to the debugger invocation, its exit code is captured before cleanup, and the launcher reports it after the finally block.

On Windows 11 26200.9974, tests/startup_run_ps1_check.py passed on Windows PowerShell 5.1 and PowerShell 7. The stderr-with-exit-0 and stderr-with-exit-7 cases preserved the summary and status, the source-built debugger log-open error reached the summary, and the watcher-cleanup and missing-build controls passed. The text-only and bidi checks also passed:

python -B tests/startup_run_ps1_check.py
python -B tests/startup_run_ps1_check.py --text-only
python -B tests/bidi_controls_check.py

Hosted Windows, Linux Python and gfx1013 checks passed. These were source-built launcher checks.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6095173370 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2867#pullrequestreview-6095173370). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-28T02:22:22Z. **Review:** APPROVED --- Reviewed 3dc23410dbd4 integrated on main f9286e7d (tree 65eb01655e0e91089c30235488d624a0b5aef757). The rebased fixture retains the three manifest controls from #2870. ErrorActionPreference is scoped to the debugger invocation, its exit code is captured before cleanup, and the launcher reports it after the finally block. On Windows 11 26200.9974, tests/startup_run_ps1_check.py passed on Windows PowerShell 5.1 and PowerShell 7. The stderr-with-exit-0 and stderr-with-exit-7 cases preserved the summary and status, the source-built debugger log-open error reached the summary, and the watcher-cleanup and missing-build controls passed. The text-only and bidi checks also passed: ``` python -B tests/startup_run_ps1_check.py python -B tests/startup_run_ps1_check.py --text-only python -B tests/bidi_controls_check.py ``` Hosted Windows, Linux Python and gfx1013 checks passed. These were source-built launcher checks.
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!2859
No description provided.