Repository navigation
startup: return the debugger's exit code from run.ps1 - #1603
Merged
Merged
Conversation
tools/startup/run.ps1 never read $LASTEXITCODE, so it exited 0 whatever tools/startup/debug_launch.py returned. A caller saw success when the debugger printed "CreateProcess failed" and returned 2. The script now stores $LASTEXITCODE right after the debugger call, prints the first five lines of <LogDir>.out as before and exits with the stored code. The debugger still returns 0 for a run it reported on, whatever the process did; that is not changed. tests/startup_run_ps1_check.py (ctest startup_run_ps1) runs a copy of the script on a stub debug_launch.py under Windows PowerShell 5.1 and pwsh, for stub exit codes 2, 0 and 7, and checks the exit code, the printed log head, <LogDir>.out and the arguments the debugger received. On a host other than Windows, or without a PowerShell, it checks the text after the debugger call instead. Three mutated copies of the script must fail in either mode. Refs R0Y00#1149
2 tasks done
denn0x
added a commit
to denn0x/Xbox2Windows
that referenced
this pull request
Nov 25, 2026
Conflicts resolved keeping both sides: - d3d12_draw.inl: mip comment line, upstream's wording (R0Y00#1630). - d3d12_xs_device.cpp: Pass keeps local compute root state and upstream viewport/scissor flags (R0Y00#1657); local ExecuteIndirect trace (slot 61) and upstream list_root_cbv (slot 42, R0Y00#1654) both kept. - xcrdapi.cpp: local failure tally, RDS5 shift/slice and stream cache kept next to upstream's BCPack census (R0Y00#1622); queue worker is upstream's CreateThread worker (R0Y00#1410), the local tally_failure("exception") moved into fail_entry. - run.ps1: upstream venv python and exit code (R0Y00#1535/R0Y00#1603) with local --fast-exit/--log-repeats. - gfx2hlsl.py image(): local 1D lowering (load, sample, sample_l, a16) kept over upstream's sample-only 1D guard; startup_image_sample_l_check keeps the local 1D SampleLevel expectation, startup_image_3d_check keeps the local 1D assertions plus upstream's cube-dimension refusal. Tests adjusted for local behaviour: startup_run_ps1_check expects the two local debugger arguments, startup_translator_check's StubPipeline has ps_entry_reads, and the coverage check's hand-built Pipeline sets packed_position_vgpr (new in R0Y00#1634).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Change
tools/startup/run.ps1never read$LASTEXITCODE, so it exited 0 whatevertools/startup/debug_launch.pyreturned. A caller or wrapper saw success when the debugger printedCreateProcess failed <error>and returned 2. Under PowerShell 7 the same held when the debugger ended with an uncaught Python exception.run.ps1now stores$LASTEXITCODEright after the debugger call, prints the first five lines of<LogDir>.outas before, and ends withexit $debuggerExit. Two added lines; parameters, environment switches and the debugger call itself are unchanged.tests/startup_run_ps1_check.py(cteststartup_run_ps1, registered next tostartup_triage_run; also added as one line aftertests/startup_triage_run_check.py \in the singletools/run_checks_parallel.pycommand of the platform-independent Python job). On Windows it copiesrun.ps1into a temporary tree whosedebug_launch.pyis a stub, with empty placeholder files for the eight stand-in DLLs and the executable, and runs it under every PowerShell found (powershellandpwsh). For stub exit codes 2, 0 and 7 it checks the script's exit code, that exactly the first five of the stub's seven lines are printed, that<LogDir>.outholds all seven, and that the debugger received<exe> <datadir> <logdir> --timeout 9 --memory-gib 3 --trace-files 1 --continue-asserts 4. On a host other than Windows, without a PowerShell, or with--text-only, it checks the text after the debugger call instead (a$LASTEXITCODEcapture, the log head, a finalexitof that variable). The call is found as the one statement that namesdebug_launch.py, however the interpreter is spelled. Three mutated copies of the script (no capture and no exit, a fixedexit 2, exit before the log head) must fail in whichever mode runs.docs/startup-runtime.mdgets one paragraph with the exit status and the check command.Not changed:
debug_launch.py. It returns 2 when the process cannot be created and 0 after a run it reported on, whatever the process did, sorun.ps1still exits 0 for such a run.Verification
Environment: Windows 11, Windows PowerShell 5.1.26100.9818, PowerShell 7.7.0, Python 3.14.5, base
a3ac47a9. The realdebug_launch.pywas never started; every run used a stub.Before (unmodified
run.ps1, stubimport sys; print("stub: CreateProcess failed 193"); sys.exit(2), run from the scratch tree):pwsh -NoProfile -File tools/startup/run.ps1 -Exe run/t.exe -DataDir data -LogDir lg7 -BuildDir bld: printsstub: CreateProcess failed 193, exit code 0.powershell -NoProfile -ExecutionPolicy Bypass -File tools/startup/run.ps1 -Exe run/t.exe -DataDir data -LogDir lg5 -BuildDir bld: same line, exit code 0.After (same commands): both print the same line and exit 2. Inside a session,
pwsh -NoProfile -Command "& ./tools/startup/run.ps1 ...; 'after=' + $LASTEXITCODE"printsafter=2in both shells, soexitends only the script; the same holds for.\tools\startup\run.ps1 ...and for a dot-sourced call. With-Commandand the script as the last statement, the host exits 1 (0 before).Checks after the change:
out/pe-env/Scripts/python.exe -B tests/startup_run_ps1_check.py:startup run.ps1 exit code: 0 failed (executed with powershell, pwsh), about 10 s.out/pe-env/Scripts/python.exe -B tests/startup_run_ps1_check.py --text-only:startup run.ps1 exit code: 0 failed (text only: requested). WithPATHreduced to the Python directory:0 failed (text only: no PowerShell found).cmake --preset dev -B out/build/dev -DINTAKE_PYTHON=<venv python>, thenctest --test-dir out/build/dev --no-tests=error -R "^startup_(run_ps1|triage_run)$": 2 of 2 passed (startup_run_ps111.24 s).[System.Management.Automation.Language.Parser]::ParseFileon the editedrun.ps1: 0 errors in both shells. The file keeps CRLF line endings, no byte order mark, ASCII only;git diff --statshows 2 insertions.tests/startup_triage_run_check.py:0 failed.tests/dev_ps1_sccache_check.py:ok (executed with pwsh).tests/docs_links_check.py: 16 Markdown files, 347 links.tests/bidi_controls_check.py: 1260 files, no bidirectional controls.ast.parse(source, feature_version=(3, 11))accepts the new check.Negative control 1, the new check on
run.ps1fromorigin/main:With
--text-only:FAIL text: the statement after the debugger call does not store $LASTEXITCODE, exit code 1. Only the exit code fails there: the log head,<LogDir>.outand the argument list already pass on the old script.Negative control 2, edited scratch copies of the fixed script:
exitline removed, orexit 0: the same fourexited 0failures; text mode:the script does not end with 'exit $debuggerExit'.exit 2:stub debugger exited 0, run.ps1 exited 2andstub debugger exited 7, run.ps1 exited 2in both shells.exitmoved beforeGet-Content:printed [] instead of the first 5 debugger linesfor all three codes in both shells.-TotalCount 3:printed ['stub debugger line 1', 'stub debugger line 2', 'stub debugger line 3'] instead of the first 5 debugger lines.Rebased onto
origin/mainata3ac47a9before opening this pull request and re-run there:tests/startup_run_ps1_check.py0 failed (executed with powershell, pwsh);tests/docs_links_check.py(16 Markdown files, 347 links) andtests/bidi_controls_check.py(1260 files) pass;tools/run_checks_parallel.py tests/startup_triage_run_check.py tests/startup_run_ps1_check.py tests/run_checks_parallel_check.pyall 3 checks passed; the check onrun.ps1fromorigin/mainfails with 4 failures (exited 0for stub exit codes 2 and 7 in both shells); on a trial merge with #1535 the check reports0 failedin both modes.Not run: the real
debug_launch.py(it starts a process under a debugger); a CMake build and the full test suite; the check on a real Linux or macOS host (the text mode was only run on Windows, on the CRLF file and on an LF-only copy of its text); Python 3.11 and 3.12 (syntax only, see above).Evidence and follow-up
Refs #1149 (a specific untested launcher behavior with a device-free control: the stub debugger).
& $python, the repository environment's interpreter when present) anddocs/startup-runtime.md; it does not touch the exit status. A trial merge of its head48a04876with this branch (git merge-tree --write-tree, ona3ac47a9) is textually clean. On the mergedrun.ps1the check passes in both modes (0 failed (executed with powershell, pwsh)and0 failed (text only: requested)), and each of the three mutants is still reported by the text mode and by both shells. On startup: run the debugger with the repository Python #1535's ownrun.ps1, without this change, the check fails the same way as onorigin/main.run.ps1(it adds arguments) and does not touch the exit status. A trial merge of its headad94c950with this branch conflicts inrun.ps1and inCMakeLists.txt(the test registration;docs/startup-runtime.mdand.github/workflows/windows.ymlmerge automatically): the two lines added here sit directly after the line it changes, so whichever lands second resolves a small conflict in each file. On a scratch copy of itsrun.ps1with these two lines added by hand, the check passes in both modes and the three mutants are reported; without-MapDrivethe debugger still receives exactly the argument list the check expects, under both shells..github/workflows/windows.yml: the open pull requests ci: run the full Windows suites with CTest in parallel #1173 and Textures: build and verify a standalone Rust DDS batch exporter #836 also edit it; trial merges of their heads (97a524a6,4b253aca) with this branch are textually clean.CMakeLists.txtanddocs/startup-runtime.mdare edited by many open PRs; the hunks here are 2 and 6 lines.startup_triage_runis not in theprtest preset, sostartup_run_ps1is not either. On pull requests only the text mode in the Linux job runs; the executing mode runs with the full Windows suite. Adding it to theprfilter needs no build target; the test took about 10 s on this PC.$ErrorActionPreference = "Stop"with*>turns the debugger's first stderr line into a terminatingNativeCommandError. With a stub that prints one line and raises, Windows PowerShell 5.1 exits 1 without printing the log head, before and after this change (4 of 4 runs each). PowerShell 7 prints the log head and exited 0 before, 1 after.AI-assisted.