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

internal compiler error: src/librustc_mir/interpret/place.rs:41: expected wide pointer extra data (e.g. slice length or trait object vtable) #68538

Closed
bjorn3 opened this issue Jan 25, 2020 · 9 comments · Fixed by #110943
Labels
A-MIR Area: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.html C-bug Category: This is a bug. F-unsized_fn_params `#![feature(unsized_fn_params)]` F-unsized_locals `#![feature(unsized_locals)]` glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@bjorn3
Copy link
Member

bjorn3 commented Jan 25, 2020

#![feature(unsized_fn_params)]

pub fn take_unsized_slice(s: [u8]) {
    s[0];
}

(Playground)

Errors:

error: internal compiler error: src/librustc_mir/interpret/place.rs:41: expected wide pointer extra data (e.g. slice length or trait object vtable)

thread 'rustc' panicked at 'Box<Any>', src/librustc_errors/lib.rs:882: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_mir::interpret::eval_context::InterpCx<M>::size_and_align_of
  16: rustc_mir::interpret::place::<impl rustc_mir::interpret::eval_context::InterpCx<M>>::force_allocation_maybe_sized
  17: rustc_mir::interpret::step::<impl rustc_mir::interpret::eval_context::InterpCx<M>>::eval_rvalue_into_place
  18: <rustc_mir::transform::const_prop::ConstPropagator as rustc::mir::visit::MutVisitor>::visit_statement
  19: <rustc_mir::transform::const_prop::ConstProp as rustc_mir::transform::MirPass>::run_pass
  20: rustc_mir::transform::run_passes
  21: rustc_mir::transform::run_optimization_passes
  22: rustc_mir::transform::optimized_mir
  23: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::optimized_mir>::compute
  24: rustc::dep_graph::graph::DepGraph::with_task_impl
  25: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  26: rustc::ty::<impl rustc::ty::context::TyCtxt>::instance_mir
  27: rustc_mir::monomorphize::collector::collect_items_rec
  28: rustc_mir::monomorphize::collector::collect_items_rec
  29: rustc_session::utils::<impl rustc_session::session::Session>::time
  30: rustc_mir::monomorphize::collector::collect_crate_mono_items
  31: rustc_mir::monomorphize::partitioning::collect_and_partition_mono_items
  32: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::collect_and_partition_mono_items>::compute::{{closure}}
  33: rustc::ty::query::__query_compute::collect_and_partition_mono_items
  34: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::collect_and_partition_mono_items>::compute
  35: rustc::dep_graph::graph::DepGraph::with_task_impl
  36: rustc::dep_graph::graph::DepGraph::with_eval_always_task
  37: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::force_query_with_job::{{closure}}::{{closure}}
  38: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::start_query::{{closure}}::{{closure}}
  39: rustc::ty::context::tls::enter_context::{{closure}}
  40: rustc::ty::context::tls::set_tlv
  41: rustc::ty::context::tls::enter_context
  42: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::start_query::{{closure}}
  43: rustc::ty::context::tls::with_related_context::{{closure}}
  44: rustc::ty::context::tls::with_context::{{closure}}
  45: rustc::ty::context::tls::with_context_opt
  46: rustc::ty::context::tls::with_context
  47: rustc::ty::context::tls::with_related_context
  48: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::force_query_with_job::{{closure}}
  49: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  50: rustc_codegen_cranelift::driver::codegen_cgus
  51: rustc_codegen_cranelift::driver::run_aot
  52: rustc_codegen_cranelift::driver::codegen_crate
  53: <rustc_codegen_cranelift::CraneliftCodegenBackend as rustc_codegen_utils::codegen_backend::CodegenBackend>::codegen_crate
  54: rustc_session::utils::<impl rustc_session::session::Session>::time
  55: rustc_interface::passes::QueryContext::enter
  56: rustc_interface::queries::Queries::ongoing_codegen
  57: rustc_interface::interface::run_compiler_in_existing_thread_pool
  58: scoped_tls::ScopedKey<T>::set
  59: 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.42.0-nightly (c2d141df5 2020-01-24) running on x86_64-apple-darwin
@rustbot rustbot added A-MIR Area: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.html C-bug Category: This is a bug. requires-nightly This issue requires a nightly compiler in some way. labels Jan 25, 2020
@jonas-schievink jonas-schievink added F-unsized_locals `#![feature(unsized_locals)]` 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 Jan 25, 2020
@rust-lang-glacier-bot rust-lang-glacier-bot added the glacier ICE tracked in rust-lang/glacier. label Jan 26, 2020
@JohnTitor JohnTitor added F-unsized_fn_params `#![feature(unsized_fn_params)]` and removed F-unsized_locals `#![feature(unsized_locals)]` labels Oct 29, 2020
@JohnTitor
Copy link
Member

Triage: This now occurs on unsized_fn_params.

@DutchGhost
Copy link
Contributor

Triage: This now occurs on unsized_fn_params.

Also still with unsized_locals:

#![feature(unsized_locals)]

struct Bug {
    V1: [(); {
        let f: [u8];
        f.len()
    }],
}

fn main() {}

@JohnTitor JohnTitor added the F-unsized_locals `#![feature(unsized_locals)]` label Nov 4, 2020
@ouz-a
Copy link
Contributor

ouz-a commented Jul 10, 2022

This doesn't ICE anymore

@bjorn3
Copy link
Member Author

bjorn3 commented Jul 11, 2022

#![feature(unsized_fn_params)]

pub fn take_unsized_slice(s: [u8]) {
    s[0];
}

now crashes with

thread 'rustc' panicked at 'const-prop encountered formatting error: unsized locals are not supported', compiler/rustc_mir_transform/src/const_prop_lint.rs:463:17

cc @RalfJung I think this is caused by your PR to remove unsized locals support from miri.

@RalfJung
Copy link
Member

Hm yeah seems related -- but shouldn't that code be rejected? It has an unsized local, not just an unsized argument, so the unsized_fn_params feature flag is not enough.

@bjorn3
Copy link
Member Author

bjorn3 commented Jul 11, 2022

Where is the unsized local? s is an unsized argument, not an unsized local and s[0] evaluates to a sized value.

@RalfJung
Copy link
Member

RalfJung commented Jul 11, 2022

Ah you are right. The problem is again ConstProp violating some interpreter invariants.

The fix is fairly easy though: add a new UnsizedLocal variant here

pub enum UnsupportedOpInfo {

and then throw that instead of a free-form string here

throw_unsup_format!("unsized locals are not supported");

That should entirely get rid of the ICE.

@matthiaskrgr
Copy link
Member

This now crashes with error: internal compiler error: /rustc/28a29282f6dde2e4aba6e1e4cfea5c9430a00217/compiler/rustc_const_eval/src/interpret/place.rs:274:13: OpTy of type [u8] was immediate when it was expected to be an MPlace

@rustbot

This comment was marked as off-topic.

@bors bors closed this as completed in 8b7080b May 3, 2023
RalfJung pushed a commit to RalfJung/miri that referenced this issue May 5, 2023
interpret: fail more gracefully on uninit unsized locals

r? `@oli-obk`

Fixes rust-lang/rust#68538
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-MIR Area: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.html C-bug Category: This is a bug. F-unsized_fn_params `#![feature(unsized_fn_params)]` F-unsized_locals `#![feature(unsized_locals)]` glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants