Skip to content

fix(build-engine): name the signal when the cache kills a compiler - #2255

Merged
zackees merged 1 commit into
mainfrom
agent/1630-signal-attribution
Dec 5, 2026
Merged

zackees merged 1 commit into
mainfrom
agent/1630-signal-attribution

Conversation

@zackees

@zackees zackees commented Dec 5, 2026

Copy link
Copy Markdown
Member

Name the signal when the compile cache kills a compiler

What was wrong

The embedded compile cache (zccache) encodes a Unix signal kill as
-(128 + signal) — zccache's platform::process::exit sets
exit_code = -128 - signal, so a SIGKILL'd compiler reaches fbuild as
-137, not -9.

fbuild_core::termination::termination() read every negative code as the plain
-signal form, so -137 became "signal 137". Worse, the parallel compile loop
never asked at all: a failed compile was reported as

compilation failed for src/main.ino.cpp:

with the exit code dropped entirely — which is why a watchdog kill (fbuild#1630
cell 2, "zccache reports 137 rather than the child's true signal") looked like a
silent source failure.

What changed (additive)

  • fbuild_core::termination: termination() now recognises the third
    convention, -(128 + signal), mapping -137 -> SIGKILL (signal 9). The
    Termination struct gains negated_shell_code and log_line() names the
    convention. -signal and 128 + signal are unchanged; Windows still answers
    None (no signal number exists there).
  • fbuild_build_engine::parallel: the failure report is built by
    compile_failure_message(), which appends the signal kill line
    (was killed by SIGKILL (signal 9) — …not a source or compiler error…) when
    the exit code classifies as a kill. An ordinary exit code 1 failure with
    rustc diagnostics is byte-identical to before.

Tests (RED first)

  • termination::tests::negated_shell_codes_name_the_true_signal and
    a_negated_shell_code_is_still_a_kill_on_windows — failed to compile before
    the field existed.
  • parallel::tests::a_killed_compile_names_the_signal and
    an_ordinary_compile_failure_is_unchanged.
cargo test -p fbuild-core --lib termination   -> 10 passed; 0 failed
cargo test -p fbuild-build-engine --lib parallel -> 10 passed; 0 failed

cargo clippy -p fbuild-core -p fbuild-build-engine --all-targets -- -D warnings
clean; cargo fmt applied.

Scope

Client-side reporting only — the kill itself was fixed upstream (zccache 1.15.22
flush guard + 1.15.23 no-abort lock watchdog, pinned here by #2254; #1866 is
closed). #1630 stays open for the upstream failure-caching half.

…1630)

zccache encodes a signal kill as -(128+signal) (SIGKILL -> -137); termination() read every negative code as -signal, and the parallel compile report dropped the exit code entirely. Recognise the negated shell convention and append the kill line to the failure message.
@zackees
zackees added this pull request to the merge queue Dec 5, 2026
Merged via the queue into main with commit 9f474eb Dec 5, 2026
38 checks passed
@zackees zackees mentioned this pull request Dec 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

1 participant