Skip to content

[ICE]: expected abort due to worker thread errors with rediculous repr(align()) #158801

Description

@matthiaskrgr

auto-reduced (treereduce-rust):

//@compile-flags: -Zcodegen-backend=cranelift
#![crate_type = "lib"]
#[repr(align(536870912))]
struct A(i64);
pub extern "C" fn foo(x: A) {}

original:

#![crate_type="lib"]
#[repr(align(536870912))]
struct A(i64);
pub extern fn foo(x : A) {}

Version information

rustc 1.98.0-nightly (ea088e0a3 2026-07-05)
binary: rustc
commit-hash: ea088e0a3dd50c494b4589c3c121d7469dceec8f
commit-date: 2026-07-05
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.8

Possibly related line of code:

self.shared_emitter_main.check(sess, true);
let maybe_lto_modules = sess.time("join_worker_thread", || match self.coordinator.join() {
Ok(Ok(maybe_lto_modules)) => maybe_lto_modules,
Ok(Err(())) => {
sess.dcx().abort_if_errors();
panic!("expected abort due to worker thread errors")
}
Err(_) => {
bug!("panic during codegen/LLVM phase");
}
});

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc -Zcodegen-backend=cranelift

Program output

warning: unused variable: `x`
 --> /tmp/icemaker_global_tempdir.dsmHW5nahCx3/rustc_testrunner_tmpdir_reporting.pc5vt5iR4toU/mvce.rs:4:23
  |
4 | pub extern "C" fn foo(x: A) {}
  |                       ^ help: if this is intentional, prefix it with an underscore: `_x`
  |
  = note: `#[warn(unused_variables)]` (part of `#[warn(unused)]`) on by default

warning: type `A` is more private than the item `foo`
 --> /tmp/icemaker_global_tempdir.dsmHW5nahCx3/rustc_testrunner_tmpdir_reporting.pc5vt5iR4toU/mvce.rs:4:1
  |
4 | pub extern "C" fn foo(x: A) {}
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ function `foo` is reachable at visibility `pub`
  |
note: but type `A` is only usable at visibility `pub(crate)`
 --> /tmp/icemaker_global_tempdir.dsmHW5nahCx3/rustc_testrunner_tmpdir_reporting.pc5vt5iR4toU/mvce.rs:3:1
  |
3 | struct A(i64);
  | ^^^^^^^^
  = note: `#[warn(private_interfaces)]` on by default

warning: field `0` is never read
 --> /tmp/icemaker_global_tempdir.dsmHW5nahCx3/rustc_testrunner_tmpdir_reporting.pc5vt5iR4toU/mvce.rs:3:10
  |
3 | struct A(i64);
  |        - ^^^
  |        |
  |        field in this struct
  |
  = help: consider removing this field
  = note: `#[warn(dead_code)]` (part of `#[warn(unused)]`) on by default

warning: `extern` fn uses type `A`, which is not FFI-safe
 --> /tmp/icemaker_global_tempdir.dsmHW5nahCx3/rustc_testrunner_tmpdir_reporting.pc5vt5iR4toU/mvce.rs:4:26
  |
4 | pub extern "C" fn foo(x: A) {}
  |                          ^ not FFI-safe
  |
  = help: consider adding a `#[repr(C)]` or `#[repr(transparent)]` attribute to this struct
  = note: this struct has unspecified layout
note: the type is defined here
 --> /tmp/icemaker_global_tempdir.dsmHW5nahCx3/rustc_testrunner_tmpdir_reporting.pc5vt5iR4toU/mvce.rs:3:1
  |
3 | struct A(i64);
  | ^^^^^^^^
  = note: `#[warn(improper_ctypes_definitions)]` on by default

error: backend implementation limit exceeded while compiling _RNvCsgZ8Ewz1DOw_4mvce3foo


thread 'rustc' (2211523) panicked at /rustc-dev/ea088e0a3dd50c494b4589c3c121d7469dceec8f/compiler/rustc_codegen_ssa/src/back/write.rs:2109:17:
expected abort due to worker thread errors
stack backtrace:
   0:     0x7fa9208e5ea6 - <<std[1023ab8fe43ea5ab]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[ac254214b649f1de]::fmt::Display>::fmt
   1:     0x7fa92100ecc8 - core[ac254214b649f1de]::fmt::write
   2:     0x7fa9208fb28c - <std[1023ab8fe43ea5ab]::sys::stdio::unix::Stderr as std[1023ab8fe43ea5ab]::io::Write>::write_fmt
   3:     0x7fa9208ba30a - std[1023ab8fe43ea5ab]::panicking::default_hook::{closure#0}
   4:     0x7fa9208d85f3 - std[1023ab8fe43ea5ab]::panicking::default_hook
   5:     0x7fa91f8c45b8 - std[1023ab8fe43ea5ab]::panicking::update_hook::<alloc[e3e2338491c50a85]::boxed::Box<rustc_driver_impl[cdfcb04387bfb2d]::install_ice_hook::{closure#1}>>::{closure#0}
   6:     0x7fa9208d8a92 - std[1023ab8fe43ea5ab]::panicking::panic_with_hook
   7:     0x7fa9208ba3f4 - std[1023ab8fe43ea5ab]::panicking::panic_handler::{closure#0}
   8:     0x7fa9208ae8a9 - std[1023ab8fe43ea5ab]::sys::backtrace::__rust_end_short_backtrace::<std[1023ab8fe43ea5ab]::panicking::panic_handler::{closure#0}, !>
   9:     0x7fa9208bbd2d - __rustc[46920232926a116e]::rust_begin_unwind
  10:     0x7fa91d9b1a8c - core[ac254214b649f1de]::panicking::panic_fmt
  11:     0x7fa90e51ac3b - <rustc_codegen_cranelift[a537d954674463c0]::CraneliftCodegenBackend as rustc_codegen_ssa[13a9efabf4627478]::traits::backend::CodegenBackend>::join_codegen
  12:     0x7fa9222dd6ca - <rustc_interface[a6d30ce4ed30ee91]::queries::Linker>::link
  13:     0x7fa92215a087 - rustc_interface[a6d30ce4ed30ee91]::interface::run_compiler::<(), rustc_driver_impl[cdfcb04387bfb2d]::run_compiler::{closure#0}>::{closure#1}
  14:     0x7fa92219227a - std[1023ab8fe43ea5ab]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[a6d30ce4ed30ee91]::util::run_in_thread_with_globals<rustc_interface[a6d30ce4ed30ee91]::util::run_in_thread_pool_with_globals<rustc_interface[a6d30ce4ed30ee91]::interface::run_compiler<(), rustc_driver_impl[cdfcb04387bfb2d]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  15:     0x7fa92219202d - <std[1023ab8fe43ea5ab]::thread::lifecycle::spawn_unchecked<rustc_interface[a6d30ce4ed30ee91]::util::run_in_thread_with_globals<rustc_interface[a6d30ce4ed30ee91]::util::run_in_thread_pool_with_globals<rustc_interface[a6d30ce4ed30ee91]::interface::run_compiler<(), rustc_driver_impl[cdfcb04387bfb2d]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[ac254214b649f1de]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  16:     0x7fa922196450 - <std[1023ab8fe43ea5ab]::sys::thread::unix::Thread>::new::thread_start
  17:     0x7fa91ba981b9 - <unknown>
  18:     0x7fa91bb1d21c - <unknown>
  19:                0x0 - <unknown>

error: the compiler unexpectedly panicked. This is a bug

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: please make sure that you have updated to the latest nightly

note: rustc 1.98.0-nightly (ea088e0a3 2026-07-05) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z codegen-backend=cranelift -Z dump-mir-dir=dir

query stack during panic:
end of query stack
warning: 4 warnings emitted


Metadata

Metadata

Assignees

No one assigned

    Labels

    A-codegenArea: Code generationA-craneliftThings relevant to the [future] cranelift backendC-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions