Skip to content

ICE in --emit mir: expected allocation ID to point to memory #66930

Closed
@bjorn3

Description

@bjorn3

Minimal reproducer:

static UTF8_CHAR_WIDTH: [u8; 0] = [];

pub fn utf8_char_width(b: u8) -> usize {
    UTF8_CHAR_WIDTH[b as usize] as usize
}

Make sure to run rustc with --emit mir to reproduce!

original issue

error: internal compiler error: src/librustc/mir/interpret/mod.rs:473: expected allocation ID 337 to point to memory

thread 'rustc' panicked at 'Box<Any>', src/librustc_errors/lib.rs:892:9
stack backtrace:
   0: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt
   1: core::fmt::write
   2: std::io::Write::write_fmt
   3: std::panicking::default_hook::{{closure}}
   4: std::panicking::default_hook
   5: rustc_driver::report_ice
   6: std::panicking::rust_panic_with_hook
   7: std::panicking::begin_panic
   8: rustc_errors::HandlerInner::bug
   9: rustc_errors::Handler::bug
  10: rustc::util::bug::opt_span_bug_fmt::{{closure}}
  11: rustc::ty::context::tls::with_opt::{{closure}}
  12: rustc::ty::context::tls::with_opt
  13: rustc::util::bug::opt_span_bug_fmt
  14: rustc::util::bug::bug_fmt
  15: <rustc::ty::print::pretty::FmtPrinter<F> as rustc::ty::print::Printer>::print_const
  16: rustc::ty::print::pretty::<impl core::fmt::Display for &rustc::ty::sty::Const>::fmt
  17: core::fmt::write
  18: core::fmt::Formatter::write_fmt
  19: <rustc::mir::Constant as core::fmt::Display>::fmt
  20: core::fmt::write
  21: core::fmt::Formatter::write_fmt
  22: <&T as core::fmt::Debug>::fmt
  23: core::fmt::write
  24: core::fmt::Formatter::write_fmt
  25: <rustc::mir::Operand as core::fmt::Debug>::fmt
  26: core::fmt::write
  27: core::fmt::Formatter::write_fmt
  28: <rustc::mir::Rvalue as core::fmt::Debug>::fmt
  29: core::fmt::write
  30: core::fmt::Formatter::write_fmt
  31: <rustc::mir::Statement as core::fmt::Debug>::fmt
  32: <&T as core::fmt::Debug>::fmt
  33: core::fmt::write
  34: alloc::fmt::format
  35: rustc_codegen_cranelift::base::trans_stmt
  36: rustc_codegen_cranelift::base::codegen_fn_content
  37: rustc_codegen_cranelift::base::trans_fn
  38: rustc_codegen_cranelift::driver::trans_mono_item
  39: rustc_codegen_cranelift::driver::codegen_mono_items::{{closure}}::{{closure}}
  40: rustc_codegen_cranelift::unimpl::try_unimpl::{{closure}}::{{closure}}
  41: <std::panic::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
  42: std::panicking::try::do_call
  43: __rust_maybe_catch_panic
  44: std::panicking::try
  45: std::panic::catch_unwind
  46: rustc_codegen_cranelift::unimpl::try_unimpl::{{closure}}
  47: std::thread::local::LocalKey<T>::try_with
  48: std::thread::local::LocalKey<T>::with
  49: rustc_codegen_cranelift::unimpl::try_unimpl
  50: rustc_codegen_cranelift::driver::codegen_mono_items::{{closure}}
  51: rustc_codegen_cranelift::driver::time
  52: rustc_codegen_cranelift::driver::codegen_mono_items
  53: rustc_codegen_cranelift::driver::codegen_cgus
  54: rustc_codegen_cranelift::driver::run_aot
  55: rustc_codegen_cranelift::driver::codegen_crate
  56: <rustc_codegen_cranelift::CraneliftCodegenBackend as rustc_codegen_utils::codegen_backend::CodegenBackend>::codegen_crate
  57: rustc_interface::passes::start_codegen::{{closure}}
  58: rustc_interface::passes::start_codegen
  59: rustc::ty::context::tls::enter_global
  60: rustc_interface::passes::BoxedGlobalCtxt::access::{{closure}}
  61: rustc_interface::passes::create_global_ctxt::{{closure}}
  62: rustc_interface::passes::BoxedGlobalCtxt::enter
  63: rustc_interface::queries::Query<T>::compute
  64: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::ongoing_codegen
  65: rustc_interface::interface::run_compiler_in_existing_thread_pool
  66: std::thread::local::LocalKey<T>::with
  67: scoped_tls::ScopedKey<T>::set
  68: syntax::with_globals
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports

note: rustc 1.41.0-nightly (25d8a9494 2019-11-29) running on x86_64-apple-darwin

note: compiler flags: -Z panic-abort-tests -Z codegen-backend=/Users/bjorn/Documents/rustc_codegen_cranelift/target/debug/librustc_codegen_cranelift.dylib -Z force-unstable-if-unmarked -C debuginfo=2 -C incremental -C panic=abort -C debuginfo=2 --crate-type lib

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

query stack during panic:
end of query stack
Instance { def: Item(DefId(0:6927 ~ core[c569]::str[0]::utf8_char_width[0])), substs: [] } _ZN4core3str15utf8_char_width17h59697a8cf43d24a0E
error: aborting due to previous error

error: could not compile `core`.

Using -Zmir-opt-level=0 doesn't fix this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-MIRArea: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.htmlA-prettyArea: Pretty printing (including `-Z unpretty`)C-bugCategory: This is a bug.E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.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.glacierICE tracked in rust-lang/glacier.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions