Skip to content

[ICE]: Result::unwrap() on an Err value: NulError(0, [0]) #155484

@matthiaskrgr

Description

@matthiaskrgr

Code

//@compile-flags: -Copt-level=1
#![crate_type = "lib"]
#[link(name = "libc.so.6", kind = "static")]
extern "C" {
    #[link_name = "\0"]
    pub fn exit_3();
}

Meta

rustc --version --verbose:

rustc 1.97.0-nightly (e9e32aca5 2026-04-17)
binary: rustc
commit-hash: e9e32aca5a4ffd08cbc29547b039d64b92a2c03b
commit-date: 2026-04-17
host: x86_64-unknown-linux-gnu
release: 1.97.0-nightly
LLVM version: 22.1.2

Error output

<output>
Backtrace

thread 'coordinator' (1815041) panicked at /rustc-dev/e9e32aca5a4ffd08cbc29547b039d64b92a2c03b/compiler/rustc_codegen_llvm/src/back/lto.rs:46:55:
called `Result::unwrap()` on an `Err` value: NulError(0, [0])
stack backtrace:
   0:     0x7ff25541c93b - <<std[ab5dd23a62e5ebc5]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[6403ce58e4e00ac6]::fmt::Display>::fmt
   1:     0x7ff255a2e988 - core[6403ce58e4e00ac6]::fmt::write
   2:     0x7ff255433936 - <std[ab5dd23a62e5ebc5]::sys::stdio::unix::Stderr as std[ab5dd23a62e5ebc5]::io::Write>::write_fmt
   3:     0x7ff2553f2c18 - std[ab5dd23a62e5ebc5]::panicking::default_hook::{closure#0}
   4:     0x7ff25540ffa3 - std[ab5dd23a62e5ebc5]::panicking::default_hook
   5:     0x7ff2543e3abc - std[ab5dd23a62e5ebc5]::panicking::update_hook::<alloc[6b8407d2afd8426e]::boxed::Box<rustc_driver_impl[a6df73e506a0ee75]::install_ice_hook::{closure#1}>>::{closure#0}
   6:     0x7ff255410282 - std[ab5dd23a62e5ebc5]::panicking::panic_with_hook
   7:     0x7ff2553f2cd8 - std[ab5dd23a62e5ebc5]::panicking::panic_handler::{closure#0}
   8:     0x7ff2553e7239 - std[ab5dd23a62e5ebc5]::sys::backtrace::__rust_end_short_backtrace::<std[ab5dd23a62e5ebc5]::panicking::panic_handler::{closure#0}, !>
   9:     0x7ff2553f473d - __rustc[8d41933af5f8f17a]::rust_begin_unwind
  10:     0x7ff251ef366c - core[6403ce58e4e00ac6]::panicking::panic_fmt
  11:     0x7ff251b00ac2 - core[6403ce58e4e00ac6]::result::unwrap_failed
  12:     0x7ff256dd5e46 - rustc_codegen_llvm[a7e612779add600b]::back::lto::prepare_lto
  13:     0x7ff256dd6c0a - <rustc_codegen_llvm[a7e612779add600b]::LlvmCodegenBackend as rustc_codegen_ssa[3d2ee748317b76d1]::traits::write::WriteBackendMethods>::run_thin_lto
  14:     0x7ff256b815f5 - rustc_codegen_ssa[3d2ee748317b76d1]::back::write::do_thin_lto::<rustc_codegen_llvm[a7e612779add600b]::LlvmCodegenBackend>
  15:     0x7ff256b8e5f4 - rustc_codegen_ssa[3d2ee748317b76d1]::back::write::start_executing_work::<rustc_codegen_llvm[a7e612779add600b]::LlvmCodegenBackend>::{closure#4}
  16:     0x7ff256b8d61d - std[ab5dd23a62e5ebc5]::sys::backtrace::__rust_begin_short_backtrace::<rustc_codegen_ssa[3d2ee748317b76d1]::back::write::start_executing_work<rustc_codegen_llvm[a7e612779add600b]::LlvmCodegenBackend>::{closure#4}, core[6403ce58e4e00ac6]::result::Result<rustc_codegen_ssa[3d2ee748317b76d1]::back::write::MaybeLtoModules<rustc_codegen_llvm[a7e612779add600b]::LlvmCodegenBackend>, ()>>
  17:     0x7ff256b86331 - <std[ab5dd23a62e5ebc5]::thread::lifecycle::spawn_unchecked<rustc_codegen_ssa[3d2ee748317b76d1]::back::write::start_executing_work<rustc_codegen_llvm[a7e612779add600b]::LlvmCodegenBackend>::{closure#4}, core[6403ce58e4e00ac6]::result::Result<rustc_codegen_ssa[3d2ee748317b76d1]::back::write::MaybeLtoModules<rustc_codegen_llvm[a7e612779add600b]::LlvmCodegenBackend>, ()>>::{closure#1} as core[6403ce58e4e00ac6]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  18:     0x7ff256b8752c - <std[ab5dd23a62e5ebc5]::sys::thread::unix::Thread>::new::thread_start
  19:     0x7ff2506a597a - <unknown>
  20:     0x7ff2507292bc - <unknown>
  21:                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: please attach the file at `/tmp/im/2/rustc-ice-2026-04-18T11_07_20-1815028.txt` to your bug report

note: rustc 1.97.0-nightly (e9e32aca5 2026-04-17) running on x86_64-unknown-linux-gnu

note: compiler flags: -C opt-level=1

query stack during panic:
end of query stack

thread 'rustc' (1815038) panicked at /rustc-dev/e9e32aca5a4ffd08cbc29547b039d64b92a2c03b/compiler/rustc_codegen_ssa/src/back/write.rs:2157:17:
/rustc-dev/e9e32aca5a4ffd08cbc29547b039d64b92a2c03b/compiler/rustc_codegen_ssa/src/back/write.rs:2157:17: panic during codegen/LLVM phase
stack backtrace:
   0:     0x7ff25541c93b - <<std[ab5dd23a62e5ebc5]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[6403ce58e4e00ac6]::fmt::Display>::fmt
   1:     0x7ff255a2e988 - core[6403ce58e4e00ac6]::fmt::write
   2:     0x7ff255433936 - <std[ab5dd23a62e5ebc5]::sys::stdio::unix::Stderr as std[ab5dd23a62e5ebc5]::io::Write>::write_fmt
   3:     0x7ff2553f2c18 - std[ab5dd23a62e5ebc5]::panicking::default_hook::{closure#0}
   4:     0x7ff25540ffa3 - std[ab5dd23a62e5ebc5]::panicking::default_hook
   5:     0x7ff2543e3abc - std[ab5dd23a62e5ebc5]::panicking::update_hook::<alloc[6b8407d2afd8426e]::boxed::Box<rustc_driver_impl[a6df73e506a0ee75]::install_ice_hook::{closure#1}>>::{closure#0}
   6:     0x7ff255410282 - std[ab5dd23a62e5ebc5]::panicking::panic_with_hook
   7:     0x7ff254a17c82 - std[ab5dd23a62e5ebc5]::panicking::begin_panic::<alloc[6b8407d2afd8426e]::string::String>::{closure#0}
   8:     0x7ff254a08bc6 - std[ab5dd23a62e5ebc5]::sys::backtrace::__rust_end_short_backtrace::<std[ab5dd23a62e5ebc5]::panicking::begin_panic<alloc[6b8407d2afd8426e]::string::String>::{closure#0}, !>
   9:     0x7ff254a03b0f - std[ab5dd23a62e5ebc5]::panicking::begin_panic::<alloc[6b8407d2afd8426e]::string::String>
  10:     0x7ff254a18076 - rustc_middle[2fad64f1b5773faf]::util::bug::opt_span_bug_fmt::<rustc_span[1be5eabc44024b06]::span_encoding::Span>::{closure#0}
  11:     0x7ff254a181f2 - rustc_middle[2fad64f1b5773faf]::ty::context::tls::with_opt::<rustc_middle[2fad64f1b5773faf]::util::bug::opt_span_bug_fmt<rustc_span[1be5eabc44024b06]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  12:     0x7ff254a0900b - rustc_middle[2fad64f1b5773faf]::ty::context::tls::with_context_opt::<rustc_middle[2fad64f1b5773faf]::ty::context::tls::with_opt<rustc_middle[2fad64f1b5773faf]::util::bug::opt_span_bug_fmt<rustc_span[1be5eabc44024b06]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  13:     0x7ff251b326c4 - rustc_middle[2fad64f1b5773faf]::util::bug::bug_fmt
  14:     0x7ff256cd5713 - <rustc_codegen_llvm[a7e612779add600b]::LlvmCodegenBackend as rustc_codegen_ssa[3d2ee748317b76d1]::traits::backend::CodegenBackend>::join_codegen
  15:     0x7ff25692c311 - <rustc_interface[c0ce4ed09eeec30a]::queries::Linker>::link
  16:     0x7ff256bb0c73 - rustc_interface[c0ce4ed09eeec30a]::interface::run_compiler::<(), rustc_driver_impl[a6df73e506a0ee75]::run_compiler::{closure#0}>::{closure#1}
  17:     0x7ff256b85fca - std[ab5dd23a62e5ebc5]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[c0ce4ed09eeec30a]::util::run_in_thread_with_globals<rustc_interface[c0ce4ed09eeec30a]::util::run_in_thread_pool_with_globals<rustc_interface[c0ce4ed09eeec30a]::interface::run_compiler<(), rustc_driver_impl[a6df73e506a0ee75]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  18:     0x7ff256b866ad - <std[ab5dd23a62e5ebc5]::thread::lifecycle::spawn_unchecked<rustc_interface[c0ce4ed09eeec30a]::util::run_in_thread_with_globals<rustc_interface[c0ce4ed09eeec30a]::util::run_in_thread_pool_with_globals<rustc_interface[c0ce4ed09eeec30a]::interface::run_compiler<(), rustc_driver_impl[a6df73e506a0ee75]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[6403ce58e4e00ac6]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  19:     0x7ff256b8752c - <std[ab5dd23a62e5ebc5]::sys::thread::unix::Thread>::new::thread_start
  20:     0x7ff2506a597a - <unknown>
  21:     0x7ff2507292bc - <unknown>
  22:                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: please attach the file at `/tmp/im/2/rustc-ice-2026-04-18T11_07_20-1815028.txt` to your bug report

note: rustc 1.97.0-nightly (e9e32aca5 2026-04-17) running on x86_64-unknown-linux-gnu

note: compiler flags: -C opt-level=1

query stack during panic:
end of query stack

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-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.needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.

    Type

    No type
    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