scripts: red_green.py tells a crashed compiler from a build error (TEST-RED-GREEN-COMPILER-CRASH) #2814

Merged
TheGeogeo merged 1 commit from upstream-pr/2814 into main 2026-12-01 14:06:19 +00:00
TheGeogeo commented 2026-12-01 00:49:48 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by TheGeogeo on 2026-12-01T00:49:48Z.


Claimed in the coordination issue as: TEST-RED-GREEN-COMPILER-CRASH (https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7296727648)

What and why

A verifier's only trial of scripts/red_green.py (#2787) said "red does not build". In fact rustc had crashed (0xC0000005). That verdict claims the test needs the new code, which says nothing about a compiler that died. Now:

  • A side whose cargo output shows a crashed compiler builds again once, and the report says so. A crashed compiler is any of:
    • rustc or a build script ending with a Windows crash status (0xC0000005 access violation, 0xC00000FD stack overflow, 0xC0000409 abort, ...);
    • an internal compiler error;
    • a failed memory allocation.
  • If it crashes a second time, the verdict is compiler crashed (exit 1), not red does not build. The JSON gives compiler_crashed and rerun_after per side.
  • A test binary that crashes is not the compiler: it stays a test result.
  • docs/testing.md and the script's docstring describe the rule.

Tested

On Windows 11 Pro 10.0, Python 3.12:

  • tests/test_red_green.py: 16 tests OK. Three are new, and fail with main's red_green.py (one error, two failures):
    • a stub cargo whose rustc crashes once: the side runs again and the verdict is red then green, with the crash in rerun_after;
    • one that always crashes: compiler crashed, exit 1, no "does not build";
    • which lines count as a crash: a crashed rustc or build script, an internal compiler error, a failed allocation. These do not: a crashed test binary, rustc's ordinary exit 1, a compile error.
  • The docs tests, test_tool_stdout_encoding.py and scripts/check_no_game_data.py on the changed files are clean.

GPUs tested: n/a

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)
<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5576613089 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2814). Originally posted by [TheGeogeo](https://github.com/TheGeogeo) on 2026-12-01T00:49:48Z. --- Claimed in the coordination issue as: TEST-RED-GREEN-COMPILER-CRASH (https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7296727648) ### What and why A verifier's only trial of `scripts/red_green.py` (#2787) said "red does not build". In fact rustc had crashed (0xC0000005). That verdict claims the test needs the new code, which says nothing about a compiler that died. Now: - A side whose cargo output shows a crashed compiler builds again once, and the report says so. A crashed compiler is any of: - rustc or a build script ending with a Windows crash status (0xC0000005 access violation, 0xC00000FD stack overflow, 0xC0000409 abort, ...); - an internal compiler error; - a failed memory allocation. - If it crashes a second time, the verdict is `compiler crashed` (exit 1), not `red does not build`. The JSON gives `compiler_crashed` and `rerun_after` per side. - A test binary that crashes is not the compiler: it stays a test result. - `docs/testing.md` and the script's docstring describe the rule. ### Tested On Windows 11 Pro 10.0, Python 3.12: - `tests/test_red_green.py`: 16 tests OK. Three are new, and fail with `main`'s `red_green.py` (one error, two failures): - a stub cargo whose rustc crashes once: the side runs again and the verdict is `red then green`, with the crash in `rerun_after`; - one that always crashes: `compiler crashed`, exit 1, no "does not build"; - which lines count as a crash: a crashed rustc or build script, an internal compiler error, a failed allocation. These do not: a crashed test binary, rustc's ordinary exit 1, a compile error. - The docs tests, `test_tool_stdout_encoding.py` and `scripts/check_no_game_data.py` on the changed files are clean. GPUs tested: n/a 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)
OreoFR commented 2026-12-01 00:51:24 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-12-01T00:51:24Z.


Verified by OreoFR on macOS 27.2.1, Apple M5, Python 3.12, head f442c3dfb, main d920d850d. CPU only.

MEASURED

  • Red (main + only this PR's tests/test_red_green.py): 3 failed, 13 passed. The failures are the three CompilerCrash tests: test_what_counts_as_a_crashed_compiler, test_a_compiler_that_crashes_once_is_run_again, test_a_compiler_that_crashes_twice_is_not_a_build_error.
  • Green (main + this PR, merge-tree): 16 passed.

READ IN CODE

  • COMPILER_CRASH matches only rustc or build-script-* ending with a 0xC… status, an internal compiler error, an unexpected compiler panic, or a failed allocation. A crash of a test binary is left as a test result, as the comment says.
  • cargo_tests runs a crashed side once more. If it crashes again, the verdict is compiler crashed instead of a build error, and both crash statuses are printed. That answers enlighted's report on the bridge (their #2588 run said "red does not build" after rustc crashed with 0xC0000005).

AI-assisted: Claude Code

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7296818491 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2814#issuecomment-7296818491). Originally posted by [OreoFR](https://github.com/OreoFR) on 2026-12-01T00:51:24Z. --- Verified by OreoFR on macOS 27.2.1, Apple M5, Python 3.12, head `f442c3dfb`, main `d920d850d`. CPU only. **MEASURED** - Red (main + only this PR's `tests/test_red_green.py`): 3 failed, 13 passed. The failures are the three `CompilerCrash` tests: `test_what_counts_as_a_crashed_compiler`, `test_a_compiler_that_crashes_once_is_run_again`, `test_a_compiler_that_crashes_twice_is_not_a_build_error`. - Green (main + this PR, merge-tree): 16 passed. **READ IN CODE** - `COMPILER_CRASH` matches only rustc or `build-script-*` ending with a `0xC…` status, an internal compiler error, an unexpected compiler panic, or a failed allocation. A crash of a test binary is left as a test result, as the comment says. - `cargo_tests` runs a crashed side once more. If it crashes again, the verdict is `compiler crashed` instead of a build error, and both crash statuses are printed. That answers enlighted's report on the bridge (their #2588 run said "red does not build" after rustc crashed with 0xC0000005). AI-assisted: Claude Code
KelboLive commented 2026-12-01 04:32:13 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by KelboLive on 2026-12-01T04:32:13Z.

Review: COMMENTED


Tested on Windows / Python 3.12 with stub cargo output and direct calls to cargo_once / cargo_tests (I did not crash a real rustc):

python -I tests/test_red_green.py                      Ran 16 tests, OK (88 s)
real rustc error[E0425]                                no_build set, crash None      -> no retry
rustc (exit code: 0xc0000005, STATUS_ACCESS_VIOLATION) crash set, cargo called 2x, rerun_after set -> red then green
that same crash twice                                  cargo_crashed set, no_build empty  -> compiler crashed (exit 1)
rustc (exit code: 1) / Python traceback                crash None                    -> build error
test binary (exit code: 0xc0000005)                    crash None                    -> stays a test result

The headline claim holds, and the JSON/report fields come out as documented.

Two gaps worth fixing:

  1. A crash is ignored once the side has printed any test line. scripts/red_green.py:303 gates detection on no_build (crash = COMPILER_CRASH.search(out) if no_build else None), and no_build is false as soon as one test line parses. I reproduced a red side that prints one test … ok, then the rustc crash: no retry, no compiler_crashed, no report line, verdict no red. This is reachable in practice because cargo compiles doctests after the unit tests. Only the generic phrases need the no_build gate; the rustc/build-script alternative can be matched regardless.
  2. The generic allocator phrase misclassifies a test binary. scripts/red_green.py:282 matches memory allocation of \d+ bytes failed, which a test binary that aborts before printing a test line emits too. I saw such a side retried and reported compiler crashed, which contradicts the PR's own "a test binary that crashes stays a test result". Gate the generic phrases (or drop them); the unit test only covers the access-violation variant.

Minor: a test binary that dies before printing a test line still reports does not build (pre-existing, but the new docs sentence reads as if that case were a test result), and a Unix rustc SIGSEGV is not matched — fine if the tool is Windows-only, but then the retry does nothing in Linux CI.

No conflict with #2817: it contains this commit, both branches merge cleanly with today's origin/main 86c30fcea, and both orders produce the same tree.

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6125135612 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2814#pullrequestreview-6125135612). Originally posted by [KelboLive](https://github.com/KelboLive) on 2026-12-01T04:32:13Z. **Review:** COMMENTED --- Tested on Windows / Python 3.12 with stub cargo output and direct calls to `cargo_once` / `cargo_tests` (I did not crash a real rustc): ``` python -I tests/test_red_green.py Ran 16 tests, OK (88 s) real rustc error[E0425] no_build set, crash None -> no retry rustc (exit code: 0xc0000005, STATUS_ACCESS_VIOLATION) crash set, cargo called 2x, rerun_after set -> red then green that same crash twice cargo_crashed set, no_build empty -> compiler crashed (exit 1) rustc (exit code: 1) / Python traceback crash None -> build error test binary (exit code: 0xc0000005) crash None -> stays a test result ``` The headline claim holds, and the JSON/report fields come out as documented. Two gaps worth fixing: 1. **A crash is ignored once the side has printed any test line.** `scripts/red_green.py:303` gates detection on `no_build` (`crash = COMPILER_CRASH.search(out) if no_build else None`), and `no_build` is false as soon as one test line parses. I reproduced a red side that prints one `test … ok`, then the rustc crash: no retry, no `compiler_crashed`, no report line, verdict **`no red`**. This is reachable in practice because cargo compiles doctests *after* the unit tests. Only the generic phrases need the `no_build` gate; the rustc/build-script alternative can be matched regardless. 2. **The generic allocator phrase misclassifies a test binary.** `scripts/red_green.py:282` matches `memory allocation of \d+ bytes failed`, which a test binary that aborts before printing a test line emits too. I saw such a side retried and reported `compiler crashed`, which contradicts the PR's own "a test binary that crashes stays a test result". Gate the generic phrases (or drop them); the unit test only covers the access-violation variant. Minor: a test binary that dies before printing a test line still reports `does not build` (pre-existing, but the new docs sentence reads as if that case were a test result), and a Unix rustc `SIGSEGV` is not matched — fine if the tool is Windows-only, but then the retry does nothing in Linux CI. No conflict with #2817: it contains this commit, both branches merge cleanly with today's `origin/main` `86c30fcea`, and both orders produce the same tree.
aegish-zagi commented 2026-12-01 04:50:39 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aegish-zagi on 2026-12-01T04:50:39Z.


Verification — VERIFY-2814

Verdict: PASS

  • PR: #2814 | head sha: f442c3dfba5dca9dcf144ef71f1c52b6b3bd1cf1 | merge state vs main: clean merge with current main 5dd6d444f in a scratch worktree (merge commit dc2eb1f67), no conflicts. Diff: scripts/red_green.py (+41/−), tests/test_red_green.py (+69), docs/testing.md (7 lines).
  • Tests run: python -I tests/test_red_green.py
    • On PR (merged with main): 16 tests, OK
    • On plain main: 13 tests, OK
    • Red check (MEASURED): the PR's own 16-test file run against main's unmodified scripts/red_green.py FAILED (failures=2, errors=1) — the three new CompilerCrash cases fail without the fix and pass with it, exactly the red→green pattern required.
  • Audit (READ IN CODE): the diff adds a COMPILER_CRASH pattern (rustc/build-script Windows crash statuses, ICE, compiler panic, failed allocation), splits cargo_tests into cargo_once + one retry, and adds a compiler crashed verdict that takes precedence over build-error verdicts only when a side crashes twice. A single crash triggers one rerun and is recorded as rerun_after; test-binary crashes are not matched (pattern anchors on rustc/build-script processes). Scope matches the PR description; no game data.
  • Platform: Linux, Python 3.12.3, no GPU, no cargo (tests use a fake cargo script, as designed).

AI-assisted: yes (Muse Wonder, Muse by Meta)

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7301159263 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2814#issuecomment-7301159263). Originally posted by [aegish-zagi](https://github.com/aegish-zagi) on 2026-12-01T04:50:39Z. --- ## Verification — VERIFY-2814 **Verdict: PASS** - PR: #2814 | head sha: `f442c3dfba5dca9dcf144ef71f1c52b6b3bd1cf1` | merge state vs main: clean merge with current main `5dd6d444f` in a scratch worktree (merge commit `dc2eb1f67`), no conflicts. Diff: `scripts/red_green.py` (+41/−), `tests/test_red_green.py` (+69), `docs/testing.md` (7 lines). - Tests run: `python -I tests/test_red_green.py` - On PR (merged with main): **16 tests, OK** - On plain main: **13 tests, OK** - Red check (MEASURED): the PR's own 16-test file run against main's unmodified `scripts/red_green.py` **FAILED (failures=2, errors=1)** — the three new CompilerCrash cases fail without the fix and pass with it, exactly the red→green pattern required. - Audit (READ IN CODE): the diff adds a `COMPILER_CRASH` pattern (rustc/build-script Windows crash statuses, ICE, compiler panic, failed allocation), splits `cargo_tests` into `cargo_once` + one retry, and adds a `compiler crashed` verdict that takes precedence over build-error verdicts only when a side crashes twice. A single crash triggers one rerun and is recorded as `rerun_after`; test-binary crashes are not matched (pattern anchors on rustc/build-script processes). Scope matches the PR description; no game data. - Platform: Linux, Python 3.12.3, no GPU, no cargo (tests use a fake cargo script, as designed). AI-assisted: yes (Muse Wonder, Muse by Meta)
TheGeogeo commented 2026-12-01 05:36:33 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by TheGeogeo on 2026-12-01T05:36:33Z.


Thanks @KelboLive and @aegish-zagi. Both of KelboLive's points hold in the code:

  1. scripts/red_green.py:303 only looks for a compiler crash when no test line was printed (if no_build), so a crash after some tests ran (a rustdoc crash while doc tests compile, for instance) is reported as test results.
  2. memory allocation of \d+ bytes failed is what any Rust binary prints when an allocation fails, test binaries included, so a test binary that aborts before its first test line is taken for a compiler crash and run again.

The Unix SIGSEGV case is not matched either; the tool's crash statuses are the Windows ones for now.

To keep this verified head as it is, I will fix these in a follow-up pull request once this one is merged: crash detection independent of whether tests ran, the allocation message counted only when it comes from rustc or a build script, and a test for each case. If a maintainer prefers a new head here instead, say so.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7301948229 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2814#issuecomment-7301948229). Originally posted by [TheGeogeo](https://github.com/TheGeogeo) on 2026-12-01T05:36:33Z. --- Thanks @KelboLive and @aegish-zagi. Both of KelboLive's points hold in the code: 1. `scripts/red_green.py:303` only looks for a compiler crash when no test line was printed (`if no_build`), so a crash after some tests ran (a rustdoc crash while doc tests compile, for instance) is reported as test results. 2. `memory allocation of \d+ bytes failed` is what any Rust binary prints when an allocation fails, test binaries included, so a test binary that aborts before its first test line is taken for a compiler crash and run again. The Unix `SIGSEGV` case is not matched either; the tool's crash statuses are the Windows ones for now. To keep this verified head as it is, I will fix these in a follow-up pull request once this one is merged: crash detection independent of whether tests ran, the allocation message counted only when it comes from `rustc` or a build script, and a test for each case. If a maintainer prefers a new head here instead, say so.
MoonEyes commented 2026-12-01 14:06:15 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-01T14:06:15Z.


Merging. Head f442c3dfb merges cleanly with main 3e7b34a52 and does not force a rebase of #2566. CI green on this head and on main. I ran it on main 19d62a98d + PR (Windows): 16 tests OK, 2 failures and 1 error without the change, docs tests OK. Verified on it by OreoFR and aegish-zagi. The two limits KelboLive found are for the author's announced follow-up. Merged by MoonEyes.

AI-assisted (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7313697940 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2814#issuecomment-7313697940). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-12-01T14:06:15Z. --- Merging. Head `f442c3dfb` merges cleanly with `main` `3e7b34a52` and does not force a rebase of #2566. CI green on this head and on main. I ran it on main 19d62a98d + PR (Windows): 16 tests OK, 2 failures and 1 error without the change, docs tests OK. Verified on it by OreoFR and aegish-zagi. The two limits KelboLive found are for the author's announced follow-up. Merged by MoonEyes. AI-assisted (Claude Code).
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
ProjectLeonida/mandy!2814
No description provided.