rust-lang / rust-lang/rust

SIGSEGV with -Cremark=all on aarch64-apple-darwin

Open
#149,996 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-LLVM C-bug I-crash O-AArch64 T-compiler
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

When compiling with -Cremark=all, rustc crashes with SIGSEGV in LLVM's optimization remarks infrastructure.

Code
# Cargo.toml
[package]
name = "rustc-crash"
version = "0.1.0"
edition = "2024"

[dependencies]
serde_derive = "1.0.228"
// src/main.rs
fn main() {
    println!("Hello, world!");
}

Build command:

RUSTFLAGS="-Cremark=all" cargo build --release
Meta

rustc --version --verbose (stable):

rustc 1.91.1 (ed61e7d7e 2025-11-07)
binary: rustc
commit-hash: ed61e7d7e242494fb7057f2657300d9e77bb4fcb
commit-date: 2025-11-07
host: aarch64-apple-darwin
release: 1.91.1
LLVM version: 21.1.2

Also reproduces on nightly:

rustc 1.94.0-nightly (430d8297c 2025-12-13)
binary: rustc
commit-hash: 430d8297c712ca7e8a4866d7ddccf1b71ba5d4d3
commit-date: 2025-12-13
host: aarch64-apple-darwin
release: 1.94.0-nightly
LLVM version: 21.1.5
Error output
error: could not compile `serde_derive` (lib); 1 warning emitted

Caused by:
  process didn't exit successfully: `rustc --crate-name serde_derive --edition=2021 ~/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/serde_derive-1.0.228/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type proc-macro --emit=dep-info,link -C prefer-dynamic -C embed-bitcode=no -C debug-assertions=off --cfg 'feature="default"' --check-cfg 'cfg(docsrs,test)' --check-cfg 'cfg(feature, values("default", "deserialize_in_place"))' -C metadata=2aaebbc6abf19169 -C extra-filename=-2e610fdd5c6d87b9 --out-dir /private/tmp/rustc-crash-final/target/release/deps -C strip=debuginfo -L dependency=/private/tmp/rustc-crash-final/target/release/deps --extern proc_macro2=/private/tmp/rustc-crash-final/target/release/deps/libproc_macro2-f8c95172c18a4071.rlib --extern quote=/private/tmp/rustc-crash-final/target/release/deps/libquote-7d7d8a774396dc6e.rlib --extern syn=/private/tmp/rustc-crash-final/target/release/deps/libsyn-678f1af0fcf23e31.rlib --extern proc_macro --cap-lints allow -Cremark=all` (signal: 11, SIGSEGV: invalid memory reference)

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
Backtrace

There was no Rust backtrace only the native backtrace from macOS crash report:

Crashed Thread:        7  opt cgu.11

Exception Type:        EXC_BAD_ACCESS (SIGSEGV)
Exception Codes:       KERN_INVALID_ADDRESS at 0xa90667fad102c417 -> 0x000067fad102c417 (possible pointer authentication failure)

Thread 7 Crashed:: opt cgu.11
0   librustc_driver-98675b6d366d1d69.dylib  0x1117f71d8 llvm::MachineOptimizationRemarkAnalysis::isEnabled() const + 64
1   librustc_driver-98675b6d366d1d69.dylib  0x113823f80 LLVMRustContextConfigureDiagnosticHandler::RustDiagnosticHandler::handleDiagnostics(llvm::DiagnosticInfo const&) + 64
2   librustc_driver-98675b6d366d1d69.dylib  0x1135ff2f4 llvm::LLVMContext::diagnose(llvm::DiagnosticInfo const&) + 200
3   librustc_driver-98675b6d366d1d69.dylib  0x11294d808 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) + 1472
4   librustc_driver-98675b6d366d1d69.dylib  0x113609ed8 llvm::FPPassManager::runOnFunction(llvm::Function&) + 668
5   librustc_driver-98675b6d366d1d69.dylib  0x1136105a4 llvm::FPPassManager::runOnModule(llvm::Module&) + 60
6   librustc_driver-98675b6d366d1d69.dylib  0x11360a90c llvm::legacy::PassManagerImpl::run(llvm::Module&) + 2008
7   librustc_driver-98675b6d366d1d69.dylib  0x1138186ac LLVMRustWriteOutputFile + 528
8   librustc_driver-98675b6d366d1d69.dylib  0x10e7b5bdc _RNvNtNtCs3o6FctvUe2b_18rustc_codegen_llvm4back5write17write_output_file + 268
9   librustc_driver-98675b6d366d1d69.dylib  0x10e7b8d8c _RNvNtNtCs3o6FctvUe2b_18rustc_codegen_llvm4back5write7codegen + 3532
10  librustc_driver-98675b6d366d1d69.dylib  0x10e7392f8 _RINvNtNtCskrnul4B7SZq_17rustc_codegen_ssa4back5write26execute_optimize_work_itemNtCs3o6FctvUe2b_18rustc_codegen_llvm18LlvmCodegenBackendEB1i_ + 676
11  librustc_driver-98675b6d366d1d69.dylib  0x10e739848 ... + 284
12  librustc_driver-98675b6d366d1d69.dylib  0x10e76d660 ... + 496
13  librustc_driver-98675b6d366d1d69.dylib  0x110ab5a80 std::sys::thread::unix::Thread::new::thread_start + 52
14  libsystem_pthread.dylib                 0x18bad7c0c _pthread_start + 136
15  libsystem_pthread.dylib                 0x18bad2b80 thread_start + 8

Thread 7 crashed with ARM Thread State (64-bit):
    x8: 0xa90667fad102c3ff (invalid pointer - PAC failure)
    pc: 0x00000001117f71d8 cpsr: 0x60000000
   far: 0xa90667fad102c417  esr: 0x92000004 (Data Abort) byte read Translation fault

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the crash with the provided Cargo project and RUSTFLAGS="-Cremark=all" on aarch64-apple-darwin. Start at LLVM's MachineOptimizationRemarkAnalysis::isEnabled and rustc_codegen_llvm's write_output_file path, then verify that the same build completes without SIGSEGV.

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
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.