Skip to content

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

Merged
MoonEyes merged 1 commit into
ProjectLeonida:mainfrom
TheGeogeo:test-red-green-compiler-crash
Dec 1, 2026
Merged

MoonEyes merged 1 commit into
ProjectLeonida:mainfrom
TheGeogeo:test-red-green-compiler-crash

Conversation

@TheGeogeo

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue as: TEST-RED-GREEN-COMPILER-CRASH (#2570 (comment))

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)

…ST-RED-GREEN-COMPILER-CRASH)

A verification's only trial said "red does not build" while rustc had crashed (0xC0000005). A side whose
cargo output shows rustc or a build script ending with a Windows crash status, an internal compiler
error or a failed allocation now builds again once, and the report says so; a second crash gives the
verdict `compiler crashed` (exit 1), not `red does not build`. A test binary that crashes stays a test
result.
@OreoFR

OreoFR commented Dec 1, 2026

Copy link
Copy Markdown
Collaborator

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 GPU: pipeline workers get a 64 MB stack for the driver's compiler #2588 run said "red does not build" after rustc crashed with 0xC0000005).

AI-assisted: Claude Code

@KelboLive KelboLive left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown
Contributor

Verification — VERIFY-2814

Verdict: PASS

  • PR: scripts: red_green.py tells a crashed compiler from a build error (TEST-RED-GREEN-COMPILER-CRASH) #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

Copy link
Copy Markdown
Contributor Author

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

MoonEyes commented Dec 1, 2026

Copy link
Copy Markdown
Collaborator

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 19d62a9 + 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).

@MoonEyes
MoonEyes merged commit b3910e5 into ProjectLeonida:main Dec 1, 2026
8 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.

5 participants