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: 'Index 320440878 must be in bounds of vector type u16: [0, 2)', compiler/rustc_mir/src/interpret/intrinsics.rs:419:17 #83837

Closed
chengniansun opened this issue Apr 4, 2021 · 2 comments
Labels
C-bug Category: This is a bug. glacier ICE tracked in rust-lang/glacier. 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.

Comments

@chengniansun
Copy link

Code

#![feature(staged_api)]
struct u16x2(u16, u16);
extern "platform-intrinsic" {
    #[rustc_const_stable(feature = "foo", since = "1.3.37")]
    fn simd_insert(x: T, idx: u32, val: U);
}
fn main() {
    const U: u16x2 = u16x2(13, 14);
    const { simd_insert(U, 0x1319_8a2e, 42_u16) }
}

Meta

rustc --version --verbose:

rustc 1.53.0-nightly (0b417ab5c 2021-04-03)
binary: rustc
commit-hash: 0b417ab5cdfdedffd74fb22cf22d27033c851304
commit-date: 2021-04-03
host: x86_64-unknown-linux-gnu
release: 1.53.0-nightly
LLVM version: 12.0.0

Error output

error[E0412]: cannot find type `T` in this scope
 --> perses_node_priority_with_dfs_delta_reduced_mutant.rs:5:23
  |
5 |     fn simd_insert(x: T, idx: u32, val: U);
  |                       ^ not found in this scope

error[E0412]: cannot find type `U` in this scope
 --> perses_node_priority_with_dfs_delta_reduced_mutant.rs:5:41
  |
5 |     fn simd_insert(x: T, idx: u32, val: U);
  |                                         ^ not found in this scope

error[E0658]: inline-const is experimental
 --> perses_node_priority_with_dfs_delta_reduced_mutant.rs:9:5
  |
9 |     const { simd_insert(U, 0x1319_8a2e, 42_u16) }
  |     ^^^^^
  |
  = note: see issue #76001 <https://github.com/rust-lang/rust/issues/76001> for more information
  = help: add `#![feature(inline_const)]` to the crate attributes to enable

error[E0658]: platform intrinsics are experimental and possibly buggy
 --> perses_node_priority_with_dfs_delta_reduced_mutant.rs:3:8
  |
3 | extern "platform-intrinsic" {
  |        ^^^^^^^^^^^^^^^^^^^^
  |
  = note: see issue #27731 <https://github.com/rust-lang/rust/issues/27731> for more information
  = help: add `#![feature(platform_intrinsics)]` to the crate attributes to enable

warning: type `u16x2` should have an upper camel case name
 --> perses_node_priority_with_dfs_delta_reduced_mutant.rs:2:8
  |
2 | struct u16x2(u16, u16);
  |        ^^^^^ help: convert the identifier to upper camel case (notice the capitalization): `U16x2`
  |
  = note: `#[warn(non_camel_case_types)]` on by default

error[E0094]: intrinsic has wrong number of type parameters: found 0, expected 2
 --> perses_node_priority_with_dfs_delta_reduced_mutant.rs:5:19
  |
5 |     fn simd_insert(x: T, idx: u32, val: U);
  |                   ^ expected 2 type parameter

thread 'rustc' panicked at 'Index `320440878` must be in bounds of vector type `u16`: `[0, 2)`', compiler/rustc_mir/src/interpret/intrinsics.rs:419:17
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

error: internal compiler error: unexpected panic

note: 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, I-ICE, T-compiler&template=ice.md

note: rustc 1.53.0-nightly (0b417ab5c 2021-04-03) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [eval_to_allocation_raw] const-evaluating   checking `main::{constant#0}`
#1 [eval_to_const_value_raw] simplifying constant for the type system `main::{constant#0}`
end of query stack
error: aborting due to 5 previous errors; 1 warning emitted

Some errors have detailed explanations: E0094, E0412, E0658.
For more information about an error, try `rustc --explain E0094`.
Backtrace

error[E0412]: cannot find type `T` in this scope
 --> perses_node_priority_with_dfs_delta_reduced_mutant.rs:5:23
  |
5 |     fn simd_insert(x: T, idx: u32, val: U);
  |                       ^ not found in this scope

error[E0412]: cannot find type `U` in this scope
 --> perses_node_priority_with_dfs_delta_reduced_mutant.rs:5:41
  |
5 |     fn simd_insert(x: T, idx: u32, val: U);
  |                                         ^ not found in this scope

error[E0658]: inline-const is experimental
 --> perses_node_priority_with_dfs_delta_reduced_mutant.rs:9:5
  |
9 |     const { simd_insert(U, 0x1319_8a2e, 42_u16) }
  |     ^^^^^
  |
  = note: see issue #76001 <https://github.com/rust-lang/rust/issues/76001> for more information
  = help: add `#![feature(inline_const)]` to the crate attributes to enable

error[E0658]: platform intrinsics are experimental and possibly buggy
 --> perses_node_priority_with_dfs_delta_reduced_mutant.rs:3:8
  |
3 | extern "platform-intrinsic" {
  |        ^^^^^^^^^^^^^^^^^^^^
  |
  = note: see issue #27731 <https://github.com/rust-lang/rust/issues/27731> for more information
  = help: add `#![feature(platform_intrinsics)]` to the crate attributes to enable

warning: type `u16x2` should have an upper camel case name
 --> perses_node_priority_with_dfs_delta_reduced_mutant.rs:2:8
  |
2 | struct u16x2(u16, u16);
  |        ^^^^^ help: convert the identifier to upper camel case (notice the capitalization): `U16x2`
  |
  = note: `#[warn(non_camel_case_types)]` on by default

error[E0094]: intrinsic has wrong number of type parameters: found 0, expected 2
 --> perses_node_priority_with_dfs_delta_reduced_mutant.rs:5:19
  |
5 |     fn simd_insert(x: T, idx: u32, val: U);
  |                   ^ expected 2 type parameter

thread 'rustc' panicked at 'Index `320440878` must be in bounds of vector type `u16`: `[0, 2)`', compiler/rustc_mir/src/interpret/intrinsics.rs:419:17
stack backtrace:
   0: rust_begin_unwind
             at /rustc/0b417ab5cdfdedffd74fb22cf22d27033c851304/library/std/src/panicking.rs:493:5
   1: std::panicking::begin_panic_fmt
             at /rustc/0b417ab5cdfdedffd74fb22cf22d27033c851304/library/std/src/panicking.rs:435:5
   2: rustc_mir::interpret::intrinsics::<impl rustc_mir::interpret::eval_context::InterpCx<M>>::emulate_intrinsic
   3: <rustc_mir::const_eval::machine::CompileTimeInterpreter as rustc_mir::interpret::machine::Machine>::call_intrinsic
   4: rustc_mir::interpret::terminator::<impl rustc_mir::interpret::eval_context::InterpCx<M>>::eval_fn_call
   5: rustc_mir::interpret::step::<impl rustc_mir::interpret::eval_context::InterpCx<M>>::run
   6: rustc_mir::const_eval::eval_queries::eval_to_allocation_raw_provider
   7: rustc_query_impl::<impl rustc_query_system::query::config::QueryAccessors<rustc_query_impl::plumbing::QueryCtxt> for rustc_query_impl::queries::eval_to_allocation_raw>::compute
   8: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
   9: rustc_data_structures::stack::ensure_sufficient_stack
  10: rustc_query_system::query::plumbing::force_query_with_job
  11: rustc_query_system::query::plumbing::get_query_impl
  12: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::eval_to_allocation_raw
  13: rustc_mir::const_eval::eval_queries::eval_to_const_value_raw_provider
  14: rustc_query_impl::<impl rustc_query_system::query::config::QueryAccessors<rustc_query_impl::plumbing::QueryCtxt> for rustc_query_impl::queries::eval_to_const_value_raw>::compute
  15: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  16: rustc_data_structures::stack::ensure_sufficient_stack
  17: rustc_query_system::query::plumbing::force_query_with_job
  18: rustc_query_system::query::plumbing::get_query_impl
  19: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::eval_to_const_value_raw
  20: rustc_middle::mir::interpret::queries::<impl rustc_middle::ty::context::TyCtxt>::const_eval_global_id
  21: rustc_middle::mir::interpret::queries::<impl rustc_middle::ty::context::TyCtxt>::const_eval_resolve
  22: rustc_infer::infer::InferCtxt::const_eval_resolve
  23: rustc_trait_selection::traits::const_evaluatable::is_const_evaluatable
  24: rustc_trait_selection::traits::fulfill::FulfillProcessor::progress_changed_obligations
  25: rustc_data_structures::obligation_forest::ObligationForest<O>::process_obligations
  26: <rustc_trait_selection::traits::fulfill::FulfillmentContext as rustc_infer::traits::engine::TraitEngine>::select_where_possible
  27: rustc_infer::infer::InferCtxtBuilder::enter
  28: rustc_typeck::check::typeck
  29: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  30: rustc_data_structures::stack::ensure_sufficient_stack
  31: rustc_query_system::query::plumbing::force_query_with_job
  32: rustc_query_system::query::plumbing::get_query_impl
  33: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::typeck
  34: rustc_middle::ty::<impl rustc_middle::ty::context::TyCtxt>::par_body_owners
  35: rustc_typeck::check::typeck_item_bodies
  36: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  37: rustc_data_structures::stack::ensure_sufficient_stack
  38: rustc_query_system::query::plumbing::force_query_with_job
  39: rustc_query_system::query::plumbing::get_query_impl
  40: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::typeck_item_bodies
  41: rustc_session::utils::<impl rustc_session::session::Session>::time
  42: rustc_typeck::check_crate
  43: rustc_interface::passes::analysis
  44: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  45: rustc_data_structures::stack::ensure_sufficient_stack
  46: rustc_query_system::query::plumbing::force_query_with_job
  47: rustc_query_system::query::plumbing::get_query_impl
  48: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::analysis
  49: rustc_interface::passes::QueryContext::enter
  50: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
  51: rustc_span::with_source_map
  52: rustc_interface::interface::create_compiler_and_run
  53: scoped_tls::ScopedKey<T>::set
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

error: internal compiler error: unexpected panic

note: 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, I-ICE, T-compiler&template=ice.md

note: rustc 1.53.0-nightly (0b417ab5c 2021-04-03) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [eval_to_allocation_raw] const-evaluating   checking `main::{constant#0}`
#1 [eval_to_const_value_raw] simplifying constant for the type system `main::{constant#0}`
#2 [typeck] type-checking `main`
#3 [typeck_item_bodies] type-checking all item bodies
#4 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 5 previous errors; 1 warning emitted

Some errors have detailed explanations: E0094, E0412, E0658.
For more information about an error, try `rustc --explain E0094`.

@chengniansun chengniansun 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 Apr 4, 2021
fanninpm added a commit to fanninpm/glacier that referenced this issue Apr 9, 2021
@rust-lang-glacier-bot rust-lang-glacier-bot added the glacier ICE tracked in rust-lang/glacier. label Apr 10, 2021
@RalfJung
Copy link
Member

RalfJung commented Apr 10, 2021

FWIW, I don't think we guarantee "ICE-freedom" for programs incorrectly interacting with intrinsics directly. There are lot of ways to cause ICEs with incorrect intrinsic declarations, e.g. by using incorrect types or an incorrect number of arguments.

For intrinsics like simd_insert, it is the responsibility of the caller to ensure that the are never used with out-of-bounds indices.

@Alexendoo
Copy link
Member

No longer ICEs since #90734 (likely #89561)

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. glacier ICE tracked in rust-lang/glacier. 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.
Projects
None yet
Development

No branches or pull requests

4 participants