Skip to content

ICE: index out of bounds: the len is 1 but the index is 1 -Cinstrument-coverage #102989

New issue

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

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

Already on GitHub? # to your account

Closed
matthiaskrgr opened this issue Oct 12, 2022 · 1 comment · Fixed by #103003
Closed
Assignees
Labels
A-code-coverage Area: Source-based code coverage (-Cinstrument-coverage) C-bug Category: This is a bug. F-no_core `#![feature(no_core)]` 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

@matthiaskrgr
Copy link
Member

Code

found via fuzzing

#![no_core]
#![feature(no_core, lang_items)]
#[lang="sized"]
trait Sized { }

fn ref_Struct(self: &Struct, f: &u32) -> &u32 {
    let x = x << 1;
}

Meta

rustc --version --verbose:

rustc 1.66.0-nightly (c0983a9aa 2022-10-12)
binary: rustc
commit-hash: c0983a9aac889d16722a12602ac678051e62c3fb
commit-date: 2022-10-12
host: x86_64-unknown-linux-gnu
release: 1.66.0-nightly
LLVM version: 15.0.2

Error output

rustc -Cinstrument-coverage file.rs

error: `self` parameter is only allowed in associated functions
 --> icemaker_87671.rs:6:15
  |
6 | fn ref_Struct(self: &Struct, f: &u32) -> &u32 {
  |               ^^^^ not semantically valid as function parameter
  |
  = note: associated functions are those in `impl` or `trait` definitions

error[E0412]: cannot find type `Struct` in this scope
 --> icemaker_87671.rs:6:22
  |
6 | fn ref_Struct(self: &Struct, f: &u32) -> &u32 {
  |                      ^^^^^^ not found in this scope

error[E0425]: cannot find value `x` in this scope
 --> icemaker_87671.rs:7:13
  |
7 |     let x = x << 1;
  |             ^ help: a local variable with a similar name exists: `f`

error: `profiler_builtins` crate (required by compiler options) is not compatible with crate attribute `#![no_core]`

error[E0601]: `main` function not found in crate `icemaker_87671`
 --> icemaker_87671.rs:8:2
  |
8 | }
  |  ^ consider adding a `main` function to `icemaker_87671.rs`

error[E0152]: found duplicate lang item `sized`
 --> icemaker_87671.rs:4:1
  |
4 | trait Sized { }
  | ^^^^^^^^^^^
  |
  = note: the lang item is first defined in crate `core`.
  = note: first definition in `core` loaded from /home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-05898138a596088a.rlib
  = note: second definition in the local crate (`icemaker_87671`)

error: `#[panic_handler]` function required, but not found

error: language item required, but not found: `eh_personality`
  |
  = note: this can occur when a binary crate with `#![no_std]` is compiled for a target where `eh_personality` is defined in the standard library
  = help: you may be able to compile for a target that doesn't need `eh_personality`, specify a target with `--target` or in `.cargo/config`
Backtrace


thread 'rustc' panicked at 'index out of bounds: the len is 1 but the index is 1', /rustc/db0597f5619d5ed93feca28e61226d3581cc7867/compiler/rustc_middle/src/ty/subst.rs:371:43
stack backtrace:
   0:     0x7f2bca6995b0 - std::backtrace_rs::backtrace::libunwind::trace::h0bf6f02637fe6971
                               at /rustc/db0597f5619d5ed93feca28e61226d3581cc7867/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   1:     0x7f2bca6995b0 - std::backtrace_rs::backtrace::trace_unsynchronized::hca573de4ebdee142
                               at /rustc/db0597f5619d5ed93feca28e61226d3581cc7867/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f2bca6995b0 - std::sys_common::backtrace::_print_fmt::h78a3b0f3fa5431ce
                               at /rustc/db0597f5619d5ed93feca28e61226d3581cc7867/library/std/src/sys_common/backtrace.rs:66:5
   3:     0x7f2bca6995b0 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h388012888db78658
                               at /rustc/db0597f5619d5ed93feca28e61226d3581cc7867/library/std/src/sys_common/backtrace.rs:45:22
   4:     0x7f2bca6f559e - core::fmt::write::h8541eee12bfb22e1
                               at /rustc/db0597f5619d5ed93feca28e61226d3581cc7867/library/core/src/fmt/mod.rs:1209:17
   5:     0x7f2bca689835 - std::io::Write::write_fmt::haf5892ef07750179
                               at /rustc/db0597f5619d5ed93feca28e61226d3581cc7867/library/std/src/io/mod.rs:1680:15
   6:     0x7f2bca69c353 - std::sys_common::backtrace::_print::hd2a58ab324867b58
                               at /rustc/db0597f5619d5ed93feca28e61226d3581cc7867/library/std/src/sys_common/backtrace.rs:48:5
   7:     0x7f2bca69c353 - std::sys_common::backtrace::print::h62650e0a0854a421
                               at /rustc/db0597f5619d5ed93feca28e61226d3581cc7867/library/std/src/sys_common/backtrace.rs:35:9
   8:     0x7f2bca69c353 - std::panicking::default_hook::{{closure}}::h0c0249b3670af819
                               at /rustc/db0597f5619d5ed93feca28e61226d3581cc7867/library/std/src/panicking.rs:267:22
   9:     0x7f2bca69c02a - std::panicking::default_hook::hdd3bdd204a1e5f34
                               at /rustc/db0597f5619d5ed93feca28e61226d3581cc7867/library/std/src/panicking.rs:286:9
  10:     0x7f2bccfd8641 - rustc_driver[1f63e0707e3aafaf]::DEFAULT_HOOK::{closure#0}::{closure#0}
  11:     0x7f2bca69cb8b - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h6f493fd9c4eb244a
                               at /rustc/db0597f5619d5ed93feca28e61226d3581cc7867/library/alloc/src/boxed.rs:1952:9
  12:     0x7f2bca69cb8b - std::panicking::rust_panic_with_hook::hcdeb5a66936a633b
                               at /rustc/db0597f5619d5ed93feca28e61226d3581cc7867/library/std/src/panicking.rs:673:13
  13:     0x7f2bca69c9e7 - std::panicking::begin_panic_handler::{{closure}}::h76d64f438650eafd
                               at /rustc/db0597f5619d5ed93feca28e61226d3581cc7867/library/std/src/panicking.rs:560:13
  14:     0x7f2bca699a5c - std::sys_common::backtrace::__rust_end_short_backtrace::h6159ba2d4e07f4de
                               at /rustc/db0597f5619d5ed93feca28e61226d3581cc7867/library/std/src/sys_common/backtrace.rs:138:18
  15:     0x7f2bca69c702 - rust_begin_unwind
                               at /rustc/db0597f5619d5ed93feca28e61226d3581cc7867/library/std/src/panicking.rs:556:5
  16:     0x7f2bca6f2173 - core::panicking::panic_fmt::h811742b56cf0125a
                               at /rustc/db0597f5619d5ed93feca28e61226d3581cc7867/library/core/src/panicking.rs:142:14
  17:     0x7f2bca6f20b2 - core::panicking::panic_bounds_check::hfee18f8513cbc676
                               at /rustc/db0597f5619d5ed93feca28e61226d3581cc7867/library/core/src/panicking.rs:84:5
  18:     0x7f2bcde70c44 - <rustc_infer[47b922782ea47410]::infer::error_reporting::TypeErrCtxt as rustc_trait_selection[a031dbb00953ed73]::traits::error_reporting::suggestions::TypeErrCtxtExt>::suggest_floating_point_literal
  19:     0x7f2bcde75abd - <rustc_infer[47b922782ea47410]::infer::error_reporting::TypeErrCtxt as rustc_trait_selection[a031dbb00953ed73]::traits::error_reporting::TypeErrCtxtExt>::report_selection_error
  20:     0x7f2bcde7dc4a - <rustc_infer[47b922782ea47410]::infer::error_reporting::TypeErrCtxt as rustc_trait_selection[a031dbb00953ed73]::traits::error_reporting::InferCtxtPrivExt>::report_fulfillment_error
  21:     0x7f2bcde71cf2 - <rustc_infer[47b922782ea47410]::infer::error_reporting::TypeErrCtxt as rustc_trait_selection[a031dbb00953ed73]::traits::error_reporting::TypeErrCtxtExt>::report_fulfillment_errors
  22:     0x7f2bcbc50540 - <rustc_hir_analysis[a6a5d63f9823a7da]::check::fn_ctxt::FnCtxt>::check_overloaded_binop
  23:     0x7f2bcbbc36be - <rustc_hir_analysis[a6a5d63f9823a7da]::check::fn_ctxt::FnCtxt>::check_binop
  24:     0x7f2bcbbb6213 - <rustc_hir_analysis[a6a5d63f9823a7da]::check::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  25:     0x7f2bcbbdf451 - <rustc_hir_analysis[a6a5d63f9823a7da]::check::fn_ctxt::FnCtxt>::check_decl
  26:     0x7f2bcbbdbaeb - <rustc_hir_analysis[a6a5d63f9823a7da]::check::fn_ctxt::FnCtxt>::check_block_with_expected
  27:     0x7f2bcbbb4bfe - <rustc_hir_analysis[a6a5d63f9823a7da]::check::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  28:     0x7f2bcc50fba6 - <rustc_hir_analysis[a6a5d63f9823a7da]::check::fn_ctxt::FnCtxt>::check_return_expr
  29:     0x7f2bcc506850 - rustc_hir_analysis[a6a5d63f9823a7da]::check::check::check_fn
  30:     0x7f2bcc4f813c - <rustc_hir_analysis[a6a5d63f9823a7da]::check::inherited::InheritedBuilder>::enter::<rustc_hir_analysis[a6a5d63f9823a7da]::check::typeck_with_fallback<rustc_hir_analysis[a6a5d63f9823a7da]::check::typeck::{closure#0}>::{closure#1}, &rustc_middle[a8ed4a0dc47aac3]::ty::context::TypeckResults>
  31:     0x7f2bcc4f700c - rustc_hir_analysis[a6a5d63f9823a7da]::check::typeck
  32:     0x7f2bcc617595 - rustc_query_system[a76597d842537d9]::query::plumbing::try_execute_query::<rustc_query_impl[1e7ed5a7eb258aab]::plumbing::QueryCtxt, rustc_query_system[a76597d842537d9]::query::caches::DefaultCache<rustc_span[ddec628aeed15f05]::def_id::LocalDefId, &rustc_middle[a8ed4a0dc47aac3]::ty::context::TypeckResults>>
  33:     0x7f2bcced91ee - <rustc_query_impl[1e7ed5a7eb258aab]::Queries as rustc_middle[a8ed4a0dc47aac3]::ty::query::QueryEngine>::typeck
  34:     0x7f2bccd09df7 - rustc_data_structures[fec937313883fa6d]::sync::par_for_each_in::<&[rustc_span[ddec628aeed15f05]::def_id::LocalDefId], <rustc_middle[a8ed4a0dc47aac3]::hir::map::Map>::par_body_owners<rustc_hir_analysis[a6a5d63f9823a7da]::check::typeck_item_bodies::{closure#0}>::{closure#0}>
  35:     0x7f2bccd09bb3 - rustc_hir_analysis[a6a5d63f9823a7da]::check::typeck_item_bodies
  36:     0x7f2bccc2b66a - rustc_query_system[a76597d842537d9]::query::plumbing::try_execute_query::<rustc_query_impl[1e7ed5a7eb258aab]::plumbing::QueryCtxt, rustc_query_system[a76597d842537d9]::query::caches::DefaultCache<(), ()>>
  37:     0x7f2bccc2b397 - rustc_query_system[a76597d842537d9]::query::plumbing::get_query::<rustc_query_impl[1e7ed5a7eb258aab]::queries::typeck_item_bodies, rustc_query_impl[1e7ed5a7eb258aab]::plumbing::QueryCtxt>
  38:     0x7f2bcc9d07cf - <rustc_session[8b98ba4aacc9d309]::session::Session>::time::<(), rustc_hir_analysis[a6a5d63f9823a7da]::check_crate::{closure#7}>
  39:     0x7f2bcc9d039f - rustc_hir_analysis[a6a5d63f9823a7da]::check_crate
  40:     0x7f2bcc9cfea7 - rustc_interface[cf2fa28a67e8bef]::passes::analysis
  41:     0x7f2bccd629e4 - rustc_query_system[a76597d842537d9]::query::plumbing::try_execute_query::<rustc_query_impl[1e7ed5a7eb258aab]::plumbing::QueryCtxt, rustc_query_system[a76597d842537d9]::query::caches::DefaultCache<(), core[fae631be8e3c81b5]::result::Result<(), rustc_errors[d5334a4a25fbb394]::ErrorGuaranteed>>>
  42:     0x7f2bccd62717 - rustc_query_system[a76597d842537d9]::query::plumbing::get_query::<rustc_query_impl[1e7ed5a7eb258aab]::queries::analysis, rustc_query_impl[1e7ed5a7eb258aab]::plumbing::QueryCtxt>
  43:     0x7f2bcbc91044 - <rustc_interface[cf2fa28a67e8bef]::passes::QueryContext>::enter::<rustc_driver[1f63e0707e3aafaf]::run_compiler::{closure#1}::{closure#2}::{closure#3}, core[fae631be8e3c81b5]::result::Result<(), rustc_errors[d5334a4a25fbb394]::ErrorGuaranteed>>
  44:     0x7f2bcbc8d496 - <rustc_interface[cf2fa28a67e8bef]::interface::Compiler>::enter::<rustc_driver[1f63e0707e3aafaf]::run_compiler::{closure#1}::{closure#2}, core[fae631be8e3c81b5]::result::Result<core[fae631be8e3c81b5]::option::Option<rustc_interface[cf2fa28a67e8bef]::queries::Linker>, rustc_errors[d5334a4a25fbb394]::ErrorGuaranteed>>
  45:     0x7f2bcbc8843c - rustc_span[ddec628aeed15f05]::with_source_map::<core[fae631be8e3c81b5]::result::Result<(), rustc_errors[d5334a4a25fbb394]::ErrorGuaranteed>, rustc_interface[cf2fa28a67e8bef]::interface::create_compiler_and_run<core[fae631be8e3c81b5]::result::Result<(), rustc_errors[d5334a4a25fbb394]::ErrorGuaranteed>, rustc_driver[1f63e0707e3aafaf]::run_compiler::{closure#1}>::{closure#1}>
  46:     0x7f2bcbc87e3f - rustc_interface[cf2fa28a67e8bef]::interface::create_compiler_and_run::<core[fae631be8e3c81b5]::result::Result<(), rustc_errors[d5334a4a25fbb394]::ErrorGuaranteed>, rustc_driver[1f63e0707e3aafaf]::run_compiler::{closure#1}>
  47:     0x7f2bcbc87032 - <scoped_tls[4da31d6f3f5146b7]::ScopedKey<rustc_span[ddec628aeed15f05]::SessionGlobals>>::set::<rustc_interface[cf2fa28a67e8bef]::interface::run_compiler<core[fae631be8e3c81b5]::result::Result<(), rustc_errors[d5334a4a25fbb394]::ErrorGuaranteed>, rustc_driver[1f63e0707e3aafaf]::run_compiler::{closure#1}>::{closure#0}, core[fae631be8e3c81b5]::result::Result<(), rustc_errors[d5334a4a25fbb394]::ErrorGuaranteed>>
  48:     0x7f2bcbc8650f - std[7bd0f41fe60b70b6]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[cf2fa28a67e8bef]::util::run_in_thread_pool_with_globals<rustc_interface[cf2fa28a67e8bef]::interface::run_compiler<core[fae631be8e3c81b5]::result::Result<(), rustc_errors[d5334a4a25fbb394]::ErrorGuaranteed>, rustc_driver[1f63e0707e3aafaf]::run_compiler::{closure#1}>::{closure#0}, core[fae631be8e3c81b5]::result::Result<(), rustc_errors[d5334a4a25fbb394]::ErrorGuaranteed>>::{closure#0}, core[fae631be8e3c81b5]::result::Result<(), rustc_errors[d5334a4a25fbb394]::ErrorGuaranteed>>
  49:     0x7f2bcbc8637f - <<std[7bd0f41fe60b70b6]::thread::Builder>::spawn_unchecked_<rustc_interface[cf2fa28a67e8bef]::util::run_in_thread_pool_with_globals<rustc_interface[cf2fa28a67e8bef]::interface::run_compiler<core[fae631be8e3c81b5]::result::Result<(), rustc_errors[d5334a4a25fbb394]::ErrorGuaranteed>, rustc_driver[1f63e0707e3aafaf]::run_compiler::{closure#1}>::{closure#0}, core[fae631be8e3c81b5]::result::Result<(), rustc_errors[d5334a4a25fbb394]::ErrorGuaranteed>>::{closure#0}, core[fae631be8e3c81b5]::result::Result<(), rustc_errors[d5334a4a25fbb394]::ErrorGuaranteed>>::{closure#1} as core[fae631be8e3c81b5]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  50:     0x7f2bca6a6793 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hc67cb2c032770d7f
                               at /rustc/db0597f5619d5ed93feca28e61226d3581cc7867/library/alloc/src/boxed.rs:1938:9
  51:     0x7f2bca6a6793 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::he79e59a805a8533c
                               at /rustc/db0597f5619d5ed93feca28e61226d3581cc7867/library/alloc/src/boxed.rs:1938:9
  52:     0x7f2bca6a6793 - std::sys::unix::thread::Thread::new::thread_start::hae509166483801f9
                               at /rustc/db0597f5619d5ed93feca28e61226d3581cc7867/library/std/src/sys/unix/thread.rs:108:17
  53:     0x7f2bca3fc8fd - <unknown>
  54:     0x7f2bca47ea60 - <unknown>
  55:                0x0 - <unknown>

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%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.66.0-nightly (db0597f56 2022-10-11) running on x86_64-unknown-linux-gnu

note: compiler flags: -C instrument-coverage

query stack during panic:
#0 [typeck] type-checking `ref_Struct`
#1 [typeck_item_bodies] type-checking all item bodies
#2 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 8 previous errors

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

@matthiaskrgr matthiaskrgr added 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. C-bug Category: This is a bug. requires-nightly This issue requires a nightly compiler in some way. A-code-coverage Area: Source-based code coverage (-Cinstrument-coverage) labels Oct 12, 2022
@TaKO8Ki TaKO8Ki self-assigned this Oct 13, 2022
@compiler-errors compiler-errors added the F-no_core `#![feature(no_core)]` label Oct 13, 2022
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Oct 13, 2022
albertlarsan68 added a commit to albertlarsan68/rust that referenced this issue Oct 14, 2022
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Oct 14, 2022
@TaKO8Ki
Copy link
Member

TaKO8Ki commented Oct 14, 2022

It seems that the ICE does not need -Cinstrument-coverage and no_core feature.

A little bit smaller example is:

#![feature(lang_items)]

#[lang="sized"]
trait Sized {}

fn ref_Struct(self: &Struct, f: &u32) -> &u32 {
    let x = x << 1;
}

fn main() {}

https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=23db069024dd9ca7fdc24383fffd2836

Dylan-DPC added a commit to Dylan-DPC/rust that referenced this issue Oct 15, 2022
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this issue Oct 15, 2022
@bors bors closed this as completed in 65dca11 Oct 15, 2022
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-code-coverage Area: Source-based code coverage (-Cinstrument-coverage) C-bug Category: This is a bug. F-no_core `#![feature(no_core)]` 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.

3 participants