Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ICE: no MIR available for DefId #133578

Closed
cpu opened this issue Nov 28, 2024 · 3 comments
Closed

ICE: no MIR available for DefId #133578

cpu opened this issue Nov 28, 2024 · 3 comments
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ S-needs-info Status: The issue lacks details necessary to triage or act on it. S-needs-repro Status: This issue has no reproduction and needs a reproduction to make progress. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@cpu
Copy link

cpu commented Nov 28, 2024

Code

I haven't been able to make a minimal reproducer yet, but you can reliably trigger the issue with this branch of Rustls by building the ech-client.rs example. The only change I've made in that branch is to fix the Cargo.lock to allow building the example crate with 1.71 by downgrading the clap dev-dep:

On that branch cargo run --locked -p rustls-examples --bin ech-client with 1.71 or 1.72 will produce an ICE.

By removing this static at the bottom of ech-client.rs (and removing the referencing code) the ICE goes away. The generic code that's failing to compile is located here in rustls/src/crypto/aws_lc_rs/hpke.rs. If I add a similar static inside of the rustls crate I don't see an ICE, just when I have a cross-crate static reference (?) from an integration test, an example, or another dependent crate.

I can reproduce this issue with both 1.72 and 1.71, but not 1.73, or nightly:

Possibly related to #111321 and #111320 ?

Thanks for your help!

Meta

rustc --version --verbose:

rustc 1.72.1 (d5c2e9c34 2023-09-13)
binary: rustc
commit-hash: d5c2e9c342b358556da91d61ed4133f6f50fc0c3
commit-date: 2023-09-13
host: x86_64-unknown-linux-gnu
release: 1.72.1
LLVM version: 16.0.5

rustc --version --verbose:

 rustc --version --verbose
rustc 1.71.1 (eb26296b5 2023-08-03)
binary: rustc
commit-hash: eb26296b556cef10fb713a38f3d16b9886080f26
commit-date: 2023-08-03
host: x86_64-unknown-linux-gnu
release: 1.71.1
LLVM version: 16.0.5

Error output

For 1.72, running cargo run --locked -p rustls-examples --bin ech-client

1.72 Backtrace

[nix-shell:~/Code/Rust/rustls/examples]$ RUST_BACKTRACE=1 cargo build --locked -p rustls-examples --bin ech-client
warning: cargo:rustc-check-cfg requires -Zcheck-cfg=output flag
warning: cargo:rustc-check-cfg requires -Zcheck-cfg=output flag
   Compiling rustls-examples v0.0.1 (/home/daniel/Code/Rust/rustls/examples)
error: internal compiler error: compiler/rustc_monomorphize/src/collector.rs:962:9: no MIR available for DefId(137:1887 ~ rustls[11db]::crypto::aws_lc_rs::hpke::generate_x25519_key_pair)

thread 'rustc' panicked at 'Box<dyn Any>', /rustc/d5c2e9c342b358556da91d61ed4133f6f50fc0c3/compiler/rustc_errors/src/lib.rs:1651:9
stack backtrace:
   0: std::panicking::begin_panic::<rustc_errors::ExplicitBug>
   1: <rustc_errors::HandlerInner>::bug::<alloc::string::String>
   2: <rustc_errors::Handler>::bug::<alloc::string::String>
   3: rustc_middle::util::bug::opt_span_bug_fmt::<rustc_span::span_encoding::Span>::{closure#0}
   4: rustc_middle::ty::context::tls::with_opt::<rustc_middle::util::bug::opt_span_bug_fmt<rustc_span::span_encoding::Span>::{closure#0}, !>::{closure#0}
   5: rustc_middle::ty::context::tls::with_context_opt::<rustc_middle::ty::context::tls::with_opt<rustc_middle::util::bug::opt_span_bug_fmt<rustc_span::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
   6: rustc_middle::util::bug::bug_fmt
   7: rustc_monomorphize::collector::collect_used_items
   8: rustc_monomorphize::collector::collect_items_rec
   9: rustc_monomorphize::collector::collect_items_rec
  10: rustc_monomorphize::collector::collect_items_rec
  11: rustc_monomorphize::collector::collect_items_rec
  12: rustc_monomorphize::collector::collect_items_rec
  13: rustc_monomorphize::collector::collect_items_rec
  14: rustc_monomorphize::collector::collect_items_rec
  15: rustc_monomorphize::collector::collect_items_rec
  16: rustc_monomorphize::collector::collect_items_rec
  17: rustc_monomorphize::collector::collect_items_rec
  18: rustc_monomorphize::collector::collect_items_rec
  19: rustc_monomorphize::collector::collect_items_rec
  20: rustc_monomorphize::collector::collect_items_rec
  21: rustc_monomorphize::collector::collect_items_rec
  22: rustc_monomorphize::collector::collect_items_rec
  23: rustc_monomorphize::collector::collect_items_rec
  24: <rustc_session::session::Session>::time::<(), rustc_monomorphize::collector::collect_crate_mono_items::{closure#1}>
  25: rustc_monomorphize::collector::collect_crate_mono_items
  26: rustc_monomorphize::partitioning::collect_and_partition_mono_items
  27: rustc_codegen_ssa::base::codegen_crate::<rustc_codegen_llvm::LlvmCodegenBackend>
  28: <rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_ssa::traits::backend::CodegenBackend>::codegen_crate
  29: <rustc_session::session::Session>::time::<alloc::boxed::Box<dyn core::any::Any>, rustc_interface::passes::start_codegen::{closure#0}>
  30: rustc_interface::passes::start_codegen
  31: <rustc_middle::ty::context::GlobalCtxt>::enter::<<rustc_interface::queries::Queries>::ongoing_codegen::{closure#0}, core::result::Result<alloc::boxed::Box<dyn core::any::Any>, rustc_span::ErrorGuaranteed>>
  32: <rustc_interface::interface::Compiler>::enter::<rustc_driver_impl::run_compiler::{closure#1}::{closure#2}, core::result::Result<core::option::Option<rustc_interface::queries::Linker>, rustc_span::ErrorGuaranteed>>
  33: rustc_span::set_source_map::<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#1}>::{closure#0}::{closure#0}>
  34: <scoped_tls::ScopedKey<rustc_span::SessionGlobals>>::set::<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

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: rustc 1.72.1 (d5c2e9c34 2023-09-13) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type bin -C embed-bitcode=no -C debuginfo=2 -C incremental=[REDACTED]

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
#0 [collect_and_partition_mono_items] collect_and_partition_mono_items
end of query stack
error: could not compile `rustls-examples` (bin "ech-client")
<backtrace>

For 1.71, running cargo run --locked -p rustls-examples --bin ech-client

1.71 Backtrace

Compiling rustls-examples v0.0.1 (/home/daniel/Code/Rust/rustls/examples)
error: internal compiler error: compiler/rustc_monomorphize/src/collector.rs:1038:9: no MIR available for DefId(137:1887 ~ rustls[a163]::crypto::aws_lc_rs::hpke::generate_x25519_key_pair)

thread 'rustc' panicked at 'Box<dyn Any>', /rustc/eb26296b556cef10fb713a38f3d16b9886080f26/compiler/rustc_errors/src/lib.rs:1651:9
stack backtrace:
   0: std::panicking::begin_panic::<rustc_errors::ExplicitBug>
   1: <rustc_errors::HandlerInner>::bug::<alloc::string::String>
   2: <rustc_errors::Handler>::bug::<alloc::string::String>
   3: rustc_middle::util::bug::opt_span_bug_fmt::<rustc_span::span_encoding::Span>::{closure#0}
   4: rustc_middle::ty::context::tls::with_opt::<rustc_middle::util::bug::opt_span_bug_fmt<rustc_span::span_encoding::Span>::{closure#0}, !>::{closure#0}
   5: rustc_middle::ty::context::tls::with_context_opt::<rustc_middle::ty::context::tls::with_opt<rustc_middle::util::bug::opt_span_bug_fmt<rustc_span::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
   6: rustc_middle::util::bug::bug_fmt
   7: rustc_monomorphize::collector::collect_neighbours
   8: rustc_monomorphize::collector::collect_items_rec
   9: rustc_monomorphize::collector::collect_items_rec
  10: rustc_monomorphize::collector::collect_items_rec
  11: rustc_monomorphize::collector::collect_items_rec
  12: rustc_monomorphize::collector::collect_items_rec
  13: rustc_monomorphize::collector::collect_items_rec
  14: rustc_monomorphize::collector::collect_items_rec
  15: rustc_monomorphize::collector::collect_items_rec
  16: rustc_monomorphize::collector::collect_items_rec
  17: rustc_monomorphize::collector::collect_items_rec
  18: rustc_monomorphize::collector::collect_items_rec
  19: rustc_monomorphize::collector::collect_items_rec
  20: rustc_monomorphize::collector::collect_items_rec
  21: rustc_monomorphize::collector::collect_items_rec
  22: rustc_monomorphize::collector::collect_items_rec
  23: rustc_monomorphize::collector::collect_items_rec
  24: rustc_data_structures::sync::par_for_each_in::<alloc::vec::Vec<rustc_middle::mir::mono::MonoItem>, rustc_monomorphize::collector::collect_crate_mono_items::{closure#1}::{closure#0}>
  25: <rustc_session::session::Session>::time::<(), rustc_monomorphize::collector::collect_crate_mono_items::{closure#1}>
  26: rustc_monomorphize::collector::collect_crate_mono_items
  27: rustc_monomorphize::partitioning::collect_and_partition_mono_items
  28: rustc_codegen_ssa::base::codegen_crate::<rustc_codegen_llvm::LlvmCodegenBackend>
  29: <rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_ssa::traits::backend::CodegenBackend>::codegen_crate
  30: <rustc_session::session::Session>::time::<alloc::boxed::Box<dyn core::any::Any>, rustc_interface::passes::start_codegen::{closure#0}>
  31: rustc_interface::passes::start_codegen
  32: <rustc_middle::ty::context::GlobalCtxt>::enter::<<rustc_interface::queries::Queries>::ongoing_codegen::{closure#0}::{closure#0}, core::result::Result<alloc::boxed::Box<dyn core::any::Any>, rustc_span::ErrorGuaranteed>>
  33: <rustc_interface::queries::Queries>::ongoing_codegen
  34: <rustc_interface::interface::Compiler>::enter::<rustc_driver_impl::run_compiler::{closure#1}::{closure#2}, core::result::Result<core::option::Option<rustc_interface::queries::Linker>, rustc_span::ErrorGuaranteed>>
  35: rustc_span::set_source_map::<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#1}>::{closure#0}::{closure#0}>
  36: <scoped_tls::ScopedKey<rustc_span::SessionGlobals>>::set::<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

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: rustc 1.71.1 (eb26296b5 2023-08-03) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type bin -C embed-bitcode=no -C debuginfo=2 -C incremental=[REDACTED]

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
#0 [collect_and_partition_mono_items] collect_and_partition_mono_items
end of query stack
error: could not compile `rustls-examples` (bin "ech-client")

@cpu cpu added C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Nov 28, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Nov 28, 2024
@cpu
Copy link
Author

cpu commented Nov 28, 2024

@ctz mentioned #115052 to me and similar to that issue adding #[used] attributes on four statics in hpke.rs seems to resolve the ICE for both 1.71 and 1.72

@saethlin
Copy link
Member

The latest stable is 1.83. We are not going to fix bugs in 1.71 or 1.72. Can you reproduce this bug with the latest stable compiler?

@jieyouxu jieyouxu added S-needs-repro Status: This issue has no reproduction and needs a reproduction to make progress. S-needs-info Status: The issue lacks details necessary to triage or act on it. and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Nov 30, 2024
@cpu
Copy link
Author

cpu commented Nov 30, 2024

We are not going to fix bugs in 1.71 or 1.72.

Very reasonable.

Can you reproduce this bug with the latest stable compiler?

No, I can't.

@cpu cpu closed this as not planned Won't fix, can't repro, duplicate, stale Nov 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ S-needs-info Status: The issue lacks details necessary to triage or act on it. S-needs-repro Status: This issue has no reproduction and needs a reproduction to make progress. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

4 participants