Skip to content

server: don't panic when a finished compile has neither code nor signal - #2776

Closed
jetm wants to merge 1 commit into
mozilla:mainfrom
jetm:dist-server-signalless-panic
Closed

jetm wants to merge 1 commit into
mozilla:mainfrom
jetm:dist-server-signalless-panic

Conversation

@jetm

@jetm jetm commented Jul 21, 2026 •

Copy link
Copy Markdown
Contributor

Part of #2775 (splitting the OpenEmbedded/Yocto sccache-dist work into focused
PRs; replaces the closed #2750).

Rebased onto current main (dac6c80); the branch is still the single commit.

Problem

get_signal did status.signal().expect("must have signal"), assuming the Unix
invariant that an ExitStatus with no exit code was terminated by a signal. That
does not always hold: an ExitStatus reconstructed for a distributed compile (or
an abnormal wait status such as WIFSTOPPED) can report neither a code nor a
signal. When that happened the expect() panicked the compile task, which the
server surfaced as a misleading "Failed to bind socket" and, under load,
repeatedly fell back to local compilation. Found under a Yocto/BitBake host-mode
distributed build.

Approach

Return Option<i32> from get_signal and assign it straight into res.signal,
so a compile that reports neither code nor signal leaves res.signal unset
instead of crashing the in-flight task. The Windows arm returns None rather
than panicking; ExitStatus::code() is always Some there, so the signal branch
is never reached anyway.

Test

Adds a unit test covering a real terminating signal (SIGKILL) and the
neither-code-nor-signal case (WIFSTOPPED via from_raw), which previously
panicked. On the rebased branch the format check, the build, the unit tests and the
Docker-based dist tests all pass.

Evidence

The unit test reproduces the neither-code-nor-signal state directly and panics on
the old code. I have no separate benchmark for this change alone: it ships in the
wave-1 build described on #2777, which completed 25,156 distributed compiles.

@codecov-commenter

codecov-commenter commented Jul 28, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 50.00000% with 10 lines in your changes missing coverage. Please review.
✅ Project coverage is 78.55%. Comparing base (dac6c80) to head (210bc7c).
⚠️ Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
src/server.rs 50.00% 10 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2776      +/-   ##
==========================================
+ Coverage   78.54%   78.55%   +0.01%     
==========================================
  Files          74       74              
  Lines       44039    44045       +6     
==========================================
+ Hits        34591    34601      +10     
+ Misses       9448     9444       -4     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@codspeed

codspeed Bot commented Jul 28, 2026 •

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

1 warning

⚠️ 1 benchmark is dominated by system calls

System calls cannot be simulated consistently and are left out of the measure. The reported value understates the real cost. Switch to the Walltime instrument to measure them.

Learn more about system calls

See affected benchmarks

✅ 62 untouched benchmarks
⏩ 6 skipped benchmarks1


Comparing jetm:dist-server-signalless-panic (210bc7c) with main (dac6c80)

Open in CodSpeed

Footnotes

  1. 6 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

@jetm
jetm force-pushed the dist-server-signalless-panic branch from 32fc12f to 5cf5942 Compare August 21, 2026 16:20
@jetm

jetm commented Aug 21, 2026

Copy link
Copy Markdown
Contributor Author

The dist-tests failure here was pre-existing on the base I branched from rather than from this change: main at 7cd4f2c fails the same two tests with nothing applied (test_dist_cargo_build and test_dist_cargo_makeflags, both expecting dist_compiles == 1 and getting 0): https://github.com/mozilla/sccache/actions/runs/29833785987. I have rebased onto current main, which includes the dist test fixes and the MSRV bump. The new runs need an approval before they start.

On the CodSpeed report: it flags the same 46% regression on this PR and on #2777, and it also notes "Different runtime environments detected". This change turns one expect() into an Option and adds a test, so I read that number as a baseline artifact rather than a real regression. Happy to dig in if you think otherwise.

@jetm
jetm force-pushed the dist-server-signalless-panic branch from 5cf5942 to 0a35d3b Compare September 3, 2026 22:09
@sylvestre
sylvestre force-pushed the dist-server-signalless-panic branch from 0a35d3b to 40e2f96 Compare October 24, 2026 09:55
get_signal did `status.signal().expect("must have signal")`, assuming the
Unix invariant that an ExitStatus with no exit code was terminated by a
signal. That does not always hold: an ExitStatus reconstructed for a
distributed compile (or an abnormal wait status such as WIFSTOPPED) can
report neither a code nor a signal. When that happened the expect() panicked
the compile task, which the server surfaced as a misleading "Failed to bind
socket" and, under load, repeatedly fell back to local compilation.

Return Option<i32> from get_signal and assign it straight into res.signal, so
a compile that reports neither code nor signal leaves res.signal unset
instead of crashing the in-flight task. The Windows arm returns None rather
than panicking; ExitStatus::code() is always Some there, so the signal branch
is never reached anyway.

Add a unit test covering a real terminating signal (SIGKILL) and the
neither-code-nor-signal case (WIFSTOPPED via from_raw), which previously
panicked.

Signed-off-by: Javier Tia <javier@peridio.com>
Comment thread src/server.rs Resolved
@jetm jetm closed this Nov 2, 2026
@jetm
jetm deleted the dist-server-signalless-panic branch November 2, 2026 18:03
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.

3 participants