ICE: codegenprepare pass segfaults
Open
Nobody has claimed this yet.
A-LLVM
C-bug
I-crash
T-compiler
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
Code
fn main() {
println!("Hello, world!");
}
Compiling the above with rustc -C no-prepopulate-passes -C passes=codegenprepare main.rs segfaults.
A similar issue also happens with ´codegenprepare´.
Meta
rustc --version --verbose:
rustc 1.87.0-nightly (f5a1ef712 2025-03-07)
binary: rustc
commit-hash: f5a1ef7121ad661b5a21a1d02941c8064d54ee0b
commit-date: 2025-03-07
host: x86_64-unknown-linux-gnu
release: 1.87.0-nightly
LLVM version: 20.1.0
Error output
error: rustc interrupted by SIGSEGV, printing backtrace
/home/thomas/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-e3b06f91230294e6.so(+0x374941f) [0x751f65d4941f]
/usr/lib/libc.so.6(+0x3dcd0) [0x751f6244bcd0]
/home/thomas/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/libLLVM.so.20.1-rust-1.87.0-nightly(+0x82a6c05) [0x751f60aa6c05]
/home/thomas/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/libLLVM.so.20.1-rust-1.87.0-nightly(_ZN4llvm18CodeGenPreparePass3runERNS_8FunctionERNS_15AnalysisManagerIS1_JEEE+0x190) [0x751f5e00cec0]
/home/thomas/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/libLLVM.so.20.1-rust-1.87.0-nightly(+0x6a6226d) [0x751f5f26226d]
/home/thomas/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/libLLVM.so.20.1-rust-1.87.0-nightly(_ZN4llvm11PassManagerINS_8FunctionENS_15AnalysisManagerIS1_JEEEJEE3runERS1_RS3_+0x70d) [0x751f60619b69]
/home/thomas/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/libLLVM.so.20.1-rust-1.87.0-nightly(_ZN4llvm27ModuleToFunctionPassAdaptor3runERNS_6ModuleERNS_15AnalysisManagerIS1_JEEE+0x296) [0x751f6068b728]
/home/thomas/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/libLLVM.so.20.1-rust-1.87.0-nightly(+0x7e8b48d) [0x751f6068b48d]
/home/thomas/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/libLLVM.so.20.1-rust-1.87.0-nightly(_ZN4llvm11PassManagerINS_6ModuleENS_15AnalysisManagerIS1_JEEEJEE3runERS1_RS3_+0x21f) [0x751f60d2fe5f]
/home/thomas/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-e3b06f91230294e6.so(+0x5e323c1) [0x751f684323c1]
/home/thomas/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-e3b06f91230294e6.so(+0x5e2b818) [0x751f6842b818]
/home/thomas/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-e3b06f91230294e6.so(_RNvXs1_Cs4GJg65wqyXp_18rustc_codegen_llvmNtB5_18LlvmCodegenBackendNtNtNtCs2qsHfWh5y4Q_17rustc_codegen_ssa6traits5write19WriteBackendMethods8optimize+0x186) [0x751f6839fce4]
/home/thomas/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-e3b06f91230294e6.so(_RINvNtNtCsaJNBDtcVlXq_3std3sys9backtrace28___rust_begin_short_backtraceNCINvXs0_Cs4GJg65wqyXp_18rustc_codegen_llvmNtB1g_18LlvmCodegenBackendNtNtNtCs2qsHfWh5y4Q_17rustc_codegen_ssa6traits7backend19ExtraBackendMethods18spawn_named_threadNCINvNtNtB2k_4back5write10spawn_workB1O_E0uE0uEB1g_+0x187) [0x751f6839c5c7]
/home/thomas/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-e3b06f91230294e6.so(+0x5d95edc) [0x751f68395edc]
/home/thomas/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-e3b06f91230294e6.so(+0x5d96277) [0x751f68396277]
/usr/lib/libc.so.6(+0x9570a) [0x751f624a370a]
/usr/lib/libc.so.6(+0x119aac) [0x751f62527aac]
note: we would appreciate a report at https://github.com/rust-lang/rust
help: you can increase rustc's stack size by setting RUST_MIN_STACK=16777216
[1] 445041 segmentation fault (core dumped) rustc -C no-prepopulate-passes -C passes=codegenprepare a.rs
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the crash with the reported rustc command and nightly toolchain, then follow the backtrace into LLVM's CodeGenPreparePass. The issue is resolved when compiling the minimal Rust program with these flags no longer segfaults.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100