fix(images): set RUST_MIN_STACK to stop sccache-driven rustc SIGSEGV

The neuron CUDA builds SIGSEGV'd rustc in LLVM's SROA pass on candle-core
whenever sccache was the wrapper, but compiled fine without it. Root cause:
the workflow pre-starts the sccache server in a bare shell (`sccache
--start-server`), so per sccache's documented behaviour the orphaned server
creates its OWN jobserver with one slot per CPU core (24 on quadbrat),
ignoring Cargo's CARGO_BUILD_JOBS=8. rustc then runs up to 24-way parallel
LLVM codegen; on candle-core's huge cuda-feature functions the concurrent
SROA passes overflow the default 8 MiB codegen-thread stack and kill rustc
with SIGSEGV — the exact "set RUST_MIN_STACK" case rustc prints. Cargo's own
8-slot jobserver (the no-sccache path) stays within budget and compiles.

Set RUST_MIN_STACK=32 MiB in the standalone Rust images (runner-rust,
runner-cuda-13.0, runner-rust-ubuntu); the gtk3/ffmpeg/deb images inherit it.
It's rustc's own recommended mitigation, virtual-only until used, and protects
every repo regardless of how it drives sccache. Pair with raising the cuda
runner image's mem_request_mb so the parallel codegen has headroom.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-15 13:18:25 +03:00
parent c292d5a6c8
commit fcb1f3b033
3 changed files with 25 additions and 0 deletions

View File

@@ -20,6 +20,13 @@ ENV RUSTUP_HOME=/usr/local/rustup \
CARGO_HOME=/usr/local/cargo \
PATH=/usr/local/cargo/bin:$PATH
# Codegen-thread stack headroom — see images/runner-rust/Containerfile. A
# pre-started sccache server (no Cargo jobserver) fans rustc codegen out to
# every CPU core; on candle-core (cuda features) the concurrent LLVM SROA
# passes overflowed the default 8 MiB codegen stack and SIGSEGV'd rustc (the
# "set RUST_MIN_STACK" case). 32 MiB is virtual-only until used.
ENV RUST_MIN_STACK=33554432
RUN curl --proto '=https' --tlsv1.2 -fsSL https://sh.rustup.rs \
| sh -s -- -y --no-modify-path --profile minimal \
--default-toolchain stable \

View File

@@ -4,6 +4,13 @@ ARG SCCACHE_VERSION=0.15.0
ENV DEBIAN_FRONTEND=noninteractive
# Codegen-thread stack headroom — see images/runner-rust/Containerfile. A
# pre-started sccache server (no Cargo jobserver) fans rustc codegen out to
# every CPU core; the resulting concurrent LLVM passes can overflow the
# default 8 MiB codegen stack and SIGSEGV rustc. 32 MiB is virtual-only until
# used. Inherited by runner-deb.
ENV RUST_MIN_STACK=33554432
RUN apt-get update && apt-get install -y --no-install-recommends \
rustc \
cargo \

View File

@@ -18,6 +18,17 @@ ENV RUSTUP_HOME=/usr/local/rustup \
CARGO_HOME=/usr/local/cargo \
PATH=/usr/local/cargo/bin:$PATH
# Codegen-thread stack headroom. A pre-started sccache server (one launched
# outside a Cargo jobserver, e.g. `sccache --start-server` in a bare CI shell)
# creates its own jobserver with one slot PER CPU CORE, so rustc fans LLVM
# codegen out to every core instead of the job budget. On heavy crates
# (candle-core with cuda features) the resulting concurrent SROA passes have
# overflowed the default 8 MiB codegen-thread stack and killed rustc with
# SIGSEGV — exactly the "set RUST_MIN_STACK" case rustc prints. 32 MiB is
# virtual reservation (committed only as used), so this costs nothing on
# normal builds and protects every repo regardless of how it drives sccache.
ENV RUST_MIN_STACK=33554432
# Stable toolchain with gnu + musl targets and the usual lint components.
# Default channel "stable" matches repos pinning channel = "stable" in
# rust-toolchain.toml (no per-build re-resolution). World-writable so non-root