Skip to content

startup: preserve debugger stderr and exit status - #2867

Merged
R0Y00 merged 4 commits into
R0Y00:mainfrom
louisdibiasi:louis/startup-debugger-stderr
Nov 28, 2026
Merged

R0Y00 merged 4 commits into
R0Y00:mainfrom
louisdibiasi:louis/startup-debugger-stderr

Conversation

@louisdibiasi

Copy link
Copy Markdown
Contributor

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.

@R0Y00 R0Y00 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

sm5 and others added 2 commits November 27, 2026 10:33
# Conflicts:
#	tests/startup_run_ps1_check.py
Resolved conflicts:
- tools/startup/run.ps1: kept the branch's Windows PowerShell 5.1 wrapper around the debugger call and passed main's --capture-every arguments (@captureArgs) inside it.
- tests/startup_run_ps1_check.py: run_case takes both sides' parameters (emit_stderr, missing_python, real_log_error, native, cache_files); the branch's .out summary comparison is followed by main's stale shader cache check.

Also: the real debugger log case copies hook_window.py and window_capture.py, which main's debug_launch.py now imports.
@pigalot

pigalot commented Nov 28, 2026

Copy link
Copy Markdown
Collaborator

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.

@R0Y00 R0Y00 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 3dc2341 integrated on main f9286e7 (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.

@R0Y00
R0Y00 merged commit 24eb18b into R0Y00:main Nov 28, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants