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

Merged
leonida/mandy
shwepz merged 2 commits from semantic-runner-exit-code into main 2026-11-28 08:01:54 +00:00

Pull request successfully merged and closed

shwepz commented 2026-11-24 17:21:04 +00:00

Claimed in the coordination issue as: SEMANTIC-RUNNER-EXIT-CODE (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7138999168)

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

Claimed in the coordination issue as: SEMANTIC-RUNNER-EXIT-CODE (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7138999168) ### 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)
KernelSmoker reviewed 2026-11-24 17:27:22 +00:00
KernelSmoker left a comment
No description provided.
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.
shwepz commented 2026-11-24 17:32:02 +00:00

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.

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.
KernelSmoker approved these changes 2026-11-24 17:35:56 +00:00
KernelSmoker left a comment

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.

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.
shwepz commented 2026-11-25 08:46:25 +00:00

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?

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?
MoonEyes commented 2026-11-28 02:56:36 +00:00

Hi @shwepz, thanks for this pull request. It currently conflicts with main (conflicting file(s): scripts/run_semantic_tests.py), so it carries the needs rebase label. CONTRIBUTING.md asks authors to rebase their branch on main; once it merges cleanly the label goes within the hour, and reviews start with the pull requests that do. Could you update the branch when you have a moment? If you no longer plan to continue with it, please say so here.

AI-assisted (Claude Code, Claude Opus 5.5).

Hi @shwepz, thanks for this pull request. It currently conflicts with `main` (conflicting file(s): `scripts/run_semantic_tests.py`), so it carries the `needs rebase` label. CONTRIBUTING.md asks authors to rebase their branch on `main`; once it merges cleanly the label goes within the hour, and reviews start with the pull requests that do. Could you update the branch when you have a moment? If you no longer plan to continue with it, please say so here. AI-assisted (Claude Code, Claude Opus 5.5).
DadaCap commented 2026-11-28 08:01:57 +00:00

Merged into main (merge commit 77d7d4ebb), approved by DadaCap (maintainer). Thanks!

Checked before merging: tests/test_run_semantic_tests.py passes with main merged in (28 passed, 1 skipped). The merge was pinned to the head commit that was tested (8bde3ce19).

AI-assisted (Claude Code), posted for DadaCap.

Merged into `main` (merge commit 77d7d4ebb), approved by DadaCap (maintainer). Thanks! Checked before merging: `tests/test_run_semantic_tests.py` passes with main merged in (28 passed, 1 skipped). The merge was pinned to the head commit that was tested (8bde3ce19). _AI-assisted (Claude Code), posted for DadaCap._
Sign in to join this conversation.
No description provided.