run_semantic_tests: name a failed module's exit code, and a crash that printed nothing (SEMANTIC-RUNNER-EXIT-CODE) #1051

Open
github-bot wants to merge 2 commits from github-bot/gh-1051 into main AGit
Owner

@⁠shwepz on GitHub · 2026-11-24 17:21 UTC · original
shwepz:semantic-runner-exit-code → main · +80 −3 · 2 files · 2 commits · open

Claimed in the coordination issue as: SEMANTIC-RUNNER-EXIT-CODE (#14)

What and why

scripts/run_semantic_tests.py printed a failed module as ==== FAILED: <name> followed by its output, but never its exit code. A module whose interpreter crashes prints nothing, so it showed up as a bare header with nothing under it, and the run gave no clue why it failed.

I hit this on a Windows 11 machine: a different 4-9 files failed each full run, every one as an empty ==== FAILED block. With the exit code printed they turned out to be python.exe exiting 0xC0000005 (access violation) in pure-Python tests that pass when run alone, and that pass in a 12-job run on Linux. So the fault is that machine, not the tests, but there was no way to tell from the runner's output.

The header now carries the exit code:

==== FAILED: test_f (exit code 1)
==== FAILED: test_crash (killed by SIGSEGV (-11))
==== FAILED: test_lds_src2 (exit code 0xC0000005, access violation (the process crashed))
(no output: the process ended before printing anything)
  • describe_exit(code): a POSIX signal by name, a Windows NTSTATUS (>= 0xC0000000) in hex with its meaning for the common crash codes (access violation, illegal instruction, out of memory, stack overflow, Ctrl+C, heap corruption, fail fast), otherwise exit code N.
  • A module that printed nothing gets the (no output ...) line.
  • Only the FAILED print in main() changes. run_module is untouched, so this does not overlap #662, which rewrites run_module's test counting. The existing tests match the header as a prefix (==== FAILED: test_f), so they still hold.

Tested

  • python -I tests/test_run_semantic_tests.py, three new tests:
    • test_a_failure_header_names_the_exit_code
    • test_a_crash_that_prints_nothing_is_named: a module that really dies on import, with SIGSEGV on POSIX and exit code 0xC0000005 on Windows
    • test_describe_exit
  • Linux (Ubuntu, Python 3.12.3): 22/22 OK.
  • Windows 11 (Python 3.11.6): the three new tests pass, 21/22 overall. The one failure, test_empty_package_alone_is_not_a_false_green (jobs=1), fails the same way on main without this change. Python 3.11's unittest discover exits 0 when nothing ran; the exit code 5 the test expects is 3.12+.
  • python -m compileall -q on both files.
  • On the Windows machine above, a full translator-suite run with an earlier debug copy of this change, which printed the raw code, named the 4 crashing files: test_control_flow_vcc, test_lds_src2, test_vs_readfirstlane and test_wave64_halves_soundness, each exit code 3221225477 (0xC0000005), 0 tests run, 0 chars of output. describe_exit(3221225477) turns that into the access-violation line above.

GPUs tested: n/a (no GPU code)

AI-assisted: yes

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (n/a: no translator change)

🤖 Generated with Claude Code

**@⁠shwepz** on GitHub · 2026-11-24 17:21 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1051) `shwepz:semantic-runner-exit-code` → `main` · +80 −3 · 2 files · 2 commits · open Claimed in the coordination issue as: SEMANTIC-RUNNER-EXIT-CODE (https://git.gtahub.st/github/ubiquitarianism--leonida/issues/14) ### What and why `scripts/run_semantic_tests.py` printed a failed module as `==== FAILED: <name>` followed by its output, but never its exit code. A module whose interpreter crashes prints nothing, so it showed up as a bare header with nothing under it, and the run gave no clue why it failed. I hit this on a Windows 11 machine: a different 4-9 files failed each full run, every one as an empty `==== FAILED` block. With the exit code printed they turned out to be `python.exe` exiting `0xC0000005` (access violation) in pure-Python tests that pass when run alone, and that pass in a 12-job run on Linux. So the fault is that machine, not the tests, but there was no way to tell from the runner's output. The header now carries the exit code: ``` ==== FAILED: test_f (exit code 1) ==== FAILED: test_crash (killed by SIGSEGV (-11)) ==== FAILED: test_lds_src2 (exit code 0xC0000005, access violation (the process crashed)) (no output: the process ended before printing anything) ``` - `describe_exit(code)`: a POSIX signal by name, a Windows NTSTATUS (>= 0xC0000000) in hex with its meaning for the common crash codes (access violation, illegal instruction, out of memory, stack overflow, Ctrl+C, heap corruption, fail fast), otherwise `exit code N`. - A module that printed nothing gets the `(no output ...)` line. - Only the FAILED print in `main()` changes. `run_module` is untouched, so this does not overlap #662, which rewrites `run_module`'s test counting. The existing tests match the header as a prefix (`==== FAILED: test_f`), so they still hold. ### Tested - `python -I tests/test_run_semantic_tests.py`, three new tests: - `test_a_failure_header_names_the_exit_code` - `test_a_crash_that_prints_nothing_is_named`: a module that really dies on import, with SIGSEGV on POSIX and exit code 0xC0000005 on Windows - `test_describe_exit` - Linux (Ubuntu, Python 3.12.3): 22/22 OK. - Windows 11 (Python 3.11.6): the three new tests pass, 21/22 overall. The one failure, `test_empty_package_alone_is_not_a_false_green (jobs=1)`, fails the same way on `main` without this change. Python 3.11's `unittest discover` exits 0 when nothing ran; the exit code 5 the test expects is 3.12+. - `python -m compileall -q` on both files. - On the Windows machine above, a full translator-suite run with an earlier debug copy of this change, which printed the raw code, named the 4 crashing files: `test_control_flow_vcc`, `test_lds_src2`, `test_vs_readfirstlane` and `test_wave64_halves_soundness`, each exit code 3221225477 (0xC0000005), 0 tests run, 0 chars of output. `describe_exit(3221225477)` turns that into the access-violation line above. GPUs tested: n/a (no GPU code) AI-assisted: yes ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [x] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. (n/a: no translator change) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
A failed module was printed as "==== FAILED: <name>" and its output, never its
exit code. A module whose interpreter crashes prints nothing, so it left a bare
header with nothing under it, and the run gave no clue why it failed.

The header now carries the exit code: "exit code 1" for a test failure, the
signal for a POSIX kill ("killed by SIGSEGV (-11)"), and the hexadecimal
NTSTATUS with its meaning for a Windows crash ("exit code 0xC0000005, access
violation (the process crashed)"). A module that printed nothing also gets a
"(no output: the process ended before printing anything)" line.

Only the FAILED print in main() changes; run_module is untouched.

Tests (tests/test_run_semantic_tests.py): the header of a plain failure, a
module that really crashes (SIGSEGV on POSIX, exit code 0xC0000005 on
Windows) and describe_exit itself.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
describe_exit labeled every code >= 0xC0000000 "the process crashed", but a
process can exit with any 32-bit value on purpose, so the range alone doesn't
show a crash. Only the NTSTATUS values in NTSTATUS_CRASHES (access violation,
illegal instruction, out of memory, stack overflow, heap corruption, fail
fast) get the crash label now. Ctrl+C (0xC000013A) is still named but not
called a crash, and any other value is just "exit code 0x...".

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:35:21 +00:00
Author
Owner

@⁠KernelSmoker on GitHub · 2026-11-24 17:27 UTC · original · requested changes

Verified on exact head 02118b22548d4c063949a707f349a71d0a34134f. tests/test_run_semantic_tests.py passes 22/22; changed-file no-game-data and git diff --check pass; merge-tree onto current main is clean. One correctness issue remains in describe_exit (scripts/run_semantic_tests.py:63): every code >= 0xC0000000 is labeled “the process crashed,” including unknown codes such as 0xC0001234 (the new test explicitly expects that wording). A child process can deliberately return an arbitrary 32-bit status, so the numeric range alone does not establish a crash. Please keep the crash label for recognized crash statuses and report unknown values neutrally as an exit code; update the unknown-code assertion accordingly. The reported Windows runs are author-provided; I ran the tests on Linux. No GPU/game data.

**@⁠KernelSmoker** on GitHub · 2026-11-24 17:27 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1051#pullrequestreview-6044169451) · **requested changes** Verified on exact head 02118b22548d4c063949a707f349a71d0a34134f. `tests/test_run_semantic_tests.py` passes 22/22; changed-file no-game-data and `git diff --check` pass; merge-tree onto current main is clean. One correctness issue remains in `describe_exit` (scripts/run_semantic_tests.py:63): every code >= 0xC0000000 is labeled “the process crashed,” including unknown codes such as 0xC0001234 (the new test explicitly expects that wording). A child process can deliberately return an arbitrary 32-bit status, so the numeric range alone does not establish a crash. Please keep the crash label for recognized crash statuses and report unknown values neutrally as an exit code; update the unknown-code assertion accordingly. The reported Windows runs are author-provided; I ran the tests on Linux. No GPU/game data.
Author
Owner

@⁠shwepz on GitHub · 2026-11-24 17:32 UTC · original

Thanks, agreed. A value in the NTSTATUS range is not proof of a crash. Fixed in 0c10c6b:

  • Only the statuses in NTSTATUS_CRASHES (access violation, illegal instruction, out of memory, stack overflow, heap corruption, fail fast) get "(the process crashed)".
  • Ctrl+C (0xC000013A) had the same problem: it's an interrupt, not a crash. It is now in a separate NTSTATUS_OTHER table, named but not called a crash: exit code 0xC000013A, interrupted with Ctrl+C.
  • Any other value is reported neutrally: exit code 0xC0001234 (hex above 0xFFFF, decimal below).
  • test_describe_exit now asserts the neutral form for 0xC0001234 and 0xDEADBEEF, plus the Ctrl+C case and a plain 255.

Re-run:

  • Linux (Python 3.12.3): tests/test_run_semantic_tests.py 22/22 OK; git diff --check and compileall clean.
  • Windows 11 (Python 3.11.6), two runs: only the pre-existing test_empty_package_alone_is_not_a_false_green (jobs=1) fails. It fails the same way on main, because 3.11's discover exits 0 when nothing ran.

AI-assisted.

**@⁠shwepz** on GitHub · 2026-11-24 17:32 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1051#issuecomment-7139336819) Thanks, agreed. A value in the NTSTATUS range is not proof of a crash. Fixed in 0c10c6b: - Only the statuses in `NTSTATUS_CRASHES` (access violation, illegal instruction, out of memory, stack overflow, heap corruption, fail fast) get "(the process crashed)". - Ctrl+C (`0xC000013A`) had the same problem: it's an interrupt, not a crash. It is now in a separate `NTSTATUS_OTHER` table, named but not called a crash: `exit code 0xC000013A, interrupted with Ctrl+C`. - Any other value is reported neutrally: `exit code 0xC0001234` (hex above 0xFFFF, decimal below). - `test_describe_exit` now asserts the neutral form for `0xC0001234` and `0xDEADBEEF`, plus the Ctrl+C case and a plain `255`. Re-run: - Linux (Python 3.12.3): `tests/test_run_semantic_tests.py` 22/22 OK; `git diff --check` and `compileall` clean. - Windows 11 (Python 3.11.6), two runs: only the pre-existing `test_empty_package_alone_is_not_a_false_green (jobs=1)` fails. It fails the same way on `main`, because 3.11's discover exits 0 when nothing ran. AI-assisted.
Author
Owner

@⁠KernelSmoker on GitHub · 2026-11-24 17:35 UTC · original · approved these changes

Thanks for addressing the crash-classification issue. On updated head 0c10c6b128beda0843fb8efff688a1259c9b506b, the runner now labels only enumerated NTSTATUS crash codes as crashes, treats Ctrl+C separately, and reports unknown high exit values neutrally. passes 22/22; the printed failing fixture is an intentional subprocess-output assertion fixture and the outer suite exits 0. No-game-data and diff checks pass; merge-tree onto current main is clean. Windows execution remains author-reported; this independent run was on Linux.

**@⁠KernelSmoker** on GitHub · 2026-11-24 17:35 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1051#pullrequestreview-6044294339) · **approved these changes** Thanks for addressing the crash-classification issue. On updated head 0c10c6b128beda0843fb8efff688a1259c9b506b, the runner now labels only enumerated NTSTATUS crash codes as crashes, treats Ctrl+C separately, and reports unknown high exit values neutrally. passes 22/22; the printed failing fixture is an intentional subprocess-output assertion fixture and the outer suite exits 0. No-game-data and diff checks pass; merge-tree onto current main is clean. Windows execution remains author-reported; this independent run was on Linux.
Author
Owner

@⁠shwepz on GitHub · 2026-11-25 08:46 UTC · original

Rebased onto current main (now 0f58c3e5) because of the needs rebase label.

The conflicts all came from main's rework of the test count (CHILD_PROGRAM, which reads the count from unittest's result object). I kept main's version and added this PR's pieces next to it: NTSTATUS_CRASHES / NTSTATUS_OTHER, describe_exit and the CRASH fixture. The changes this PR makes are the same as in the approved 0c10c6b. git range-diff shows only context changes.

Local results on Windows 11 with Python 3.12.10: python -I tests/test_run_semantic_tests.py passes 25/25, twice in a row.

Side note: on Python 3.11, three tests in that file fail on plain main as well (empty package initializer and -p/--pattern, exit code 5). That is not caused by this PR.

@⁠KernelSmoker, the force-push cleared your approval. Could you take another look when you get a chance?

**@⁠shwepz** on GitHub · 2026-11-25 08:46 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1051#issuecomment-7157452128) Rebased onto current `main` (now `0f58c3e5`) because of the `needs rebase` label. The conflicts all came from main's rework of the test count (`CHILD_PROGRAM`, which reads the count from unittest's result object). I kept main's version and added this PR's pieces next to it: `NTSTATUS_CRASHES` / `NTSTATUS_OTHER`, `describe_exit` and the `CRASH` fixture. The changes this PR makes are the same as in the approved `0c10c6b`. `git range-diff` shows only context changes. Local results on Windows 11 with Python 3.12.10: `python -I tests/test_run_semantic_tests.py` passes 25/25, twice in a row. Side note: on Python 3.11, three tests in that file fail on plain `main` as well (empty package initializer and `-p`/`--pattern`, exit code 5). That is not caused by this PR. @⁠KernelSmoker, the force-push cleared your approval. Could you take another look when you get a chance?
This pull request has changes conflicting with the target branch.
  • scripts/run_semantic_tests.py
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/1051/head:github-bot/gh-1051'
git switch 'github-bot/gh-1051'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1051'
git switch 'github-bot/gh-1051'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1051'
git switch 'github-bot/gh-1051'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1051'
git switch 'main'
git merge --squash 'github-bot/gh-1051'
git switch 'main'
git merge --ff-only 'github-bot/gh-1051'
git switch 'main'
git merge 'github-bot/gh-1051'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.