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: panicked at 'index out of bounds: the len is 0 but the index is 0', could not prove Binder(TraitPredicate(<bool as Copy>), []) #87573

Closed
chengniansun opened this issue Jul 28, 2021 · 3 comments · Fixed by #90956
Labels
C-bug Category: This is a bug. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. 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

Might be a duplicate of #86535

Code

#![feature(no_core, lang_items)]
#![no_core]
static STATIC_BOOL: bool = true;
#[lang = "sized"]
trait Sized {}
#[lang = "copy"]
trait Copy {}
#[lang = "sync"]
trait Sync {}
impl Sync for bool {}
#[lang = "drop_in_place"]
fn main() {
    while false {}
}

Meta

rustc --version --verbose:

rustc 1.56.0-nightly (2faabf579 2021-07-27)
binary: rustc
commit-hash: 2faabf579323f5252329264cc53ba9ff803429a3
commit-date: 2021-07-27
host: x86_64-unknown-linux-gnu
release: 1.56.0-nightly
LLVM version: 12.0.1

Error output

warning: static is never used: `STATIC_BOOL`
 --> mutant.rs:3:1
  |
3 | static STATIC_BOOL: bool = true;
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: `#[warn(dead_code)]` on by default

thread 'rustc' panicked at 'index out of bounds: the len is 0 but the index is 0', /rustc/2faabf579323f5252329264cc53ba9ff803429a3/compiler/rustc_middle/src/ty/subst.rs:303:43
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%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.56.0-nightly (2faabf579 2021-07-27) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type staticlib

query stack during panic:
#0 [resolve_instance] resolving instance `main`
#1 [collect_and_partition_mono_items] collect_and_partition_mono_items
end of query stack
warning: 1 warning emitted

error: internal compiler error: broken MIR in DefId(0:6 ~ mutant[d0c6]::main) (NoSolution): could not prove Binder(TraitPredicate(<bool as Copy>), [])
  |
  = note: delayed at compiler/rustc_mir/src/borrow_check/type_check/mod.rs:299:27

thread 'rustc' panicked at 'no errors encountered even though `delay_span_bug` issued', compiler/rustc_errors/src/lib.rs:1050:13
stack backtrace:
   0:     0x7fc5bb8e4f50 - std::backtrace_rs::backtrace::libunwind::trace::h99dbb39dca18857d
                               at /rustc/2faabf579323f5252329264cc53ba9ff803429a3/library/std/src/../../backtrace/src/backtrace/libunwind.rs:90:5
   1:     0x7fc5bb8e4f50 - std::backtrace_rs::backtrace::trace_unsynchronized::h832861927e9cfedf
                               at /rustc/2faabf579323f5252329264cc53ba9ff803429a3/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7fc5bb8e4f50 - std::sys_common::backtrace::_print_fmt::h3d18154c77dcf310
                               at /rustc/2faabf579323f5252329264cc53ba9ff803429a3/library/std/src/sys_common/backtrace.rs:67:5
   3:     0x7fc5bb8e4f50 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::he312f4ad5b9bb346
                               at /rustc/2faabf579323f5252329264cc53ba9ff803429a3/library/std/src/sys_common/backtrace.rs:46:22
   4:     0x7fc5bb952bbc - core::fmt::write::h9a6d9c74526a6c1b
                               at /rustc/2faabf579323f5252329264cc53ba9ff803429a3/library/core/src/fmt/mod.rs:1115:17
   5:     0x7fc5bb8d6835 - std::io::Write::write_fmt::h6aced00850e8186f
                               at /rustc/2faabf579323f5252329264cc53ba9ff803429a3/library/std/src/io/mod.rs:1665:15
   6:     0x7fc5bb8e8c6b - std::sys_common::backtrace::_print::h65d996766de40da4
                               at /rustc/2faabf579323f5252329264cc53ba9ff803429a3/library/std/src/sys_common/backtrace.rs:49:5
   7:     0x7fc5bb8e8c6b - std::sys_common::backtrace::print::h40df9727e635f303
                               at /rustc/2faabf579323f5252329264cc53ba9ff803429a3/library/std/src/sys_common/backtrace.rs:36:9
   8:     0x7fc5bb8e8c6b - std::panicking::default_hook::{{closure}}::hd2da4327dea91a51
                               at /rustc/2faabf579323f5252329264cc53ba9ff803429a3/library/std/src/panicking.rs:208:50
   9:     0x7fc5bb8e8741 - std::panicking::default_hook::h3d55120ad6ada158
                               at /rustc/2faabf579323f5252329264cc53ba9ff803429a3/library/std/src/panicking.rs:225:9
  10:     0x7fc5bc0c5611 - rustc_driver::DEFAULT_HOOK::{{closure}}::{{closure}}::h6c854bb74ca75dad
  11:     0x7fc5bb8e9499 - std::panicking::rust_panic_with_hook::hf85dd0bb545e3b55
                               at /rustc/2faabf579323f5252329264cc53ba9ff803429a3/library/std/src/panicking.rs:626:17
  12:     0x7fc5bb8e8f57 - std::panicking::begin_panic_handler::{{closure}}::h736ae969434da9fa
                               at /rustc/2faabf579323f5252329264cc53ba9ff803429a3/library/std/src/panicking.rs:519:13
  13:     0x7fc5bb8e542c - std::sys_common::backtrace::__rust_end_short_backtrace::h6133bb80b1d6c3e0
                               at /rustc/2faabf579323f5252329264cc53ba9ff803429a3/library/std/src/sys_common/backtrace.rs:141:18
  14:     0x7fc5bb8e8eb9 - rust_begin_unwind
                               at /rustc/2faabf579323f5252329264cc53ba9ff803429a3/library/std/src/panicking.rs:515:5
  15:     0x7fc5bb8b1eab - std::panicking::begin_panic_fmt::hf70e90a601287d8b
                               at /rustc/2faabf579323f5252329264cc53ba9ff803429a3/library/std/src/panicking.rs:457:5
  16:     0x7fc5be50b3d9 - rustc_errors::HandlerInner::flush_delayed::h400415fe09e32e42
  17:     0x7fc5be509e3d - <rustc_errors::HandlerInner as core::ops::drop::Drop>::drop::h99b093f7064b7696
  18:     0x7fc5bdbc68e6 - core::ptr::drop_in_place<rustc_session::parse::ParseSess>::hd2c66b9140bd0417
  19:     0x7fc5bdbc8bfe - <alloc::rc::Rc<T> as core::ops::drop::Drop>::drop::hd322edc4934bdbe3
  20:     0x7fc5bdb9c57d - core::ptr::drop_in_place<rustc_interface::interface::Compiler>::hba47a069d6e06a26
  21:     0x7fc5bdb9be3c - rustc_span::with_source_map::hdc8c4c7d7611fe77
  22:     0x7fc5bdbae0ba - rustc_interface::interface::create_compiler_and_run::hbe7a78745769ff96
  23:     0x7fc5bdba0e19 - scoped_tls::ScopedKey<T>::set::ha164143a03306a1b
  24:     0x7fc5bdb9ceba - std::sys_common::backtrace::__rust_begin_short_backtrace::h4dd3c27220dda569
  25:     0x7fc5bdb9c335 - core::ops::function::FnOnce::call_once{{vtable.shim}}::h546778848e9193e6
  26:     0x7fc5bb8f5a27 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h09f167e08fc945ff
                               at /rustc/2faabf579323f5252329264cc53ba9ff803429a3/library/alloc/src/boxed.rs:1572:9
  27:     0x7fc5bb8f5a27 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hf814fe85eeb118e0
                               at /rustc/2faabf579323f5252329264cc53ba9ff803429a3/library/alloc/src/boxed.rs:1572:9
  28:     0x7fc5bb8f5a27 - std::sys::unix::thread::Thread::new::thread_start::hb71b17934c5f5e68
                               at /rustc/2faabf579323f5252329264cc53ba9ff803429a3/library/std/src/sys/unix/thread.rs:91:17
  29:     0x7fc5bb822609 - start_thread
  30:     0x7fc5bb736293 - clone
  31:                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.56.0-nightly (2faabf579 2021-07-27) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type staticlib

query stack during panic:
end of query stack
thread panicked while panicking. aborting.
Backtrace

warning: static is never used: `STATIC_BOOL`
 --> mutant.rs:3:1
  |
3 | static STATIC_BOOL: bool = true;
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: `#[warn(dead_code)]` on by default

thread 'rustc' panicked at 'index out of bounds: the len is 0 but the index is 0', /rustc/2faabf579323f5252329264cc53ba9ff803429a3/compiler/rustc_middle/src/ty/subst.rs:303:43
stack backtrace:
   0: rust_begin_unwind
             at /rustc/2faabf579323f5252329264cc53ba9ff803429a3/library/std/src/panicking.rs:515:5
   1: core::panicking::panic_fmt
             at /rustc/2faabf579323f5252329264cc53ba9ff803429a3/library/core/src/panicking.rs:92:14
   2: core::panicking::panic_bounds_check
             at /rustc/2faabf579323f5252329264cc53ba9ff803429a3/library/core/src/panicking.rs:69:5
   3: rustc_ty_utils::instance::inner_resolve_instance
   4: rustc_ty_utils::instance::resolve_instance
   5: rustc_query_system::query::plumbing::get_query_impl
   6: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::resolve_instance
   7: rustc_middle::ty::instance::Instance::resolve_opt_const_arg
   8: rustc_middle::ty::instance::Instance::resolve_drop_in_place
   9: rustc_mir::monomorphize::collector::collect_items_rec
  10: rustc_mir::monomorphize::collector::collect_crate_mono_items
  11: rustc_mir::monomorphize::partitioning::collect_and_partition_mono_items
  12: rustc_query_system::query::plumbing::get_query_impl
  13: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::collect_and_partition_mono_items
  14: <rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_ssa::traits::backend::CodegenBackend>::codegen_crate
  15: rustc_interface::passes::QueryContext::enter
  16: rustc_interface::queries::Queries::ongoing_codegen
  17: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
  18: rustc_span::with_source_map
  19: rustc_interface::interface::create_compiler_and_run
  20: 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%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.56.0-nightly (2faabf579 2021-07-27) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type staticlib

query stack during panic:
#0 [resolve_instance] resolving instance `main`
#1 [collect_and_partition_mono_items] collect_and_partition_mono_items
end of query stack
warning: 1 warning emitted

error: internal compiler error: broken MIR in DefId(0:6 ~ mutant[d0c6]::main) (NoSolution): could not prove Binder(TraitPredicate(<bool as Copy>), [])
  |
  = note: delayed at compiler/rustc_mir/src/borrow_check/type_check/mod.rs:299:27

thread 'rustc' panicked at 'no errors encountered even though `delay_span_bug` issued', compiler/rustc_errors/src/lib.rs:1050:13
stack backtrace:
   0:     0x7fa952871f50 - std::backtrace_rs::backtrace::libunwind::trace::h99dbb39dca18857d
                               at /rustc/2faabf579323f5252329264cc53ba9ff803429a3/library/std/src/../../backtrace/src/backtrace/libunwind.rs:90:5
   1:     0x7fa952871f50 - std::backtrace_rs::backtrace::trace_unsynchronized::h832861927e9cfedf
                               at /rustc/2faabf579323f5252329264cc53ba9ff803429a3/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7fa952871f50 - std::sys_common::backtrace::_print_fmt::h3d18154c77dcf310
                               at /rustc/2faabf579323f5252329264cc53ba9ff803429a3/library/std/src/sys_common/backtrace.rs:67:5
   3:     0x7fa952871f50 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::he312f4ad5b9bb346
                               at /rustc/2faabf579323f5252329264cc53ba9ff803429a3/library/std/src/sys_common/backtrace.rs:46:22
   4:     0x7fa9528dfbbc - core::fmt::write::h9a6d9c74526a6c1b
                               at /rustc/2faabf579323f5252329264cc53ba9ff803429a3/library/core/src/fmt/mod.rs:1115:17
   5:     0x7fa952863835 - std::io::Write::write_fmt::h6aced00850e8186f
                               at /rustc/2faabf579323f5252329264cc53ba9ff803429a3/library/std/src/io/mod.rs:1665:15
   6:     0x7fa952875c6b - std::sys_common::backtrace::_print::h65d996766de40da4
                               at /rustc/2faabf579323f5252329264cc53ba9ff803429a3/library/std/src/sys_common/backtrace.rs:49:5
   7:     0x7fa952875c6b - std::sys_common::backtrace::print::h40df9727e635f303
                               at /rustc/2faabf579323f5252329264cc53ba9ff803429a3/library/std/src/sys_common/backtrace.rs:36:9
   8:     0x7fa952875c6b - std::panicking::default_hook::{{closure}}::hd2da4327dea91a51
                               at /rustc/2faabf579323f5252329264cc53ba9ff803429a3/library/std/src/panicking.rs:208:50
   9:     0x7fa952875741 - std::panicking::default_hook::h3d55120ad6ada158
                               at /rustc/2faabf579323f5252329264cc53ba9ff803429a3/library/std/src/panicking.rs:225:9
  10:     0x7fa953052611 - rustc_driver::DEFAULT_HOOK::{{closure}}::{{closure}}::h6c854bb74ca75dad
  11:     0x7fa952876499 - std::panicking::rust_panic_with_hook::hf85dd0bb545e3b55
                               at /rustc/2faabf579323f5252329264cc53ba9ff803429a3/library/std/src/panicking.rs:626:17
  12:     0x7fa952875f57 - std::panicking::begin_panic_handler::{{closure}}::h736ae969434da9fa
                               at /rustc/2faabf579323f5252329264cc53ba9ff803429a3/library/std/src/panicking.rs:519:13
  13:     0x7fa95287242c - std::sys_common::backtrace::__rust_end_short_backtrace::h6133bb80b1d6c3e0
                               at /rustc/2faabf579323f5252329264cc53ba9ff803429a3/library/std/src/sys_common/backtrace.rs:141:18
  14:     0x7fa952875eb9 - rust_begin_unwind
                               at /rustc/2faabf579323f5252329264cc53ba9ff803429a3/library/std/src/panicking.rs:515:5
  15:     0x7fa95283eeab - std::panicking::begin_panic_fmt::hf70e90a601287d8b
                               at /rustc/2faabf579323f5252329264cc53ba9ff803429a3/library/std/src/panicking.rs:457:5
  16:     0x7fa9554983d9 - rustc_errors::HandlerInner::flush_delayed::h400415fe09e32e42
  17:     0x7fa955496e3d - <rustc_errors::HandlerInner as core::ops::drop::Drop>::drop::h99b093f7064b7696
  18:     0x7fa954b538e6 - core::ptr::drop_in_place<rustc_session::parse::ParseSess>::hd2c66b9140bd0417
  19:     0x7fa954b55bfe - <alloc::rc::Rc<T> as core::ops::drop::Drop>::drop::hd322edc4934bdbe3
  20:     0x7fa954b2957d - core::ptr::drop_in_place<rustc_interface::interface::Compiler>::hba47a069d6e06a26
  21:     0x7fa954b28e3c - rustc_span::with_source_map::hdc8c4c7d7611fe77
  22:     0x7fa954b3b0ba - rustc_interface::interface::create_compiler_and_run::hbe7a78745769ff96
  23:     0x7fa954b2de19 - scoped_tls::ScopedKey<T>::set::ha164143a03306a1b
  24:     0x7fa954b29eba - std::sys_common::backtrace::__rust_begin_short_backtrace::h4dd3c27220dda569
  25:     0x7fa954b29335 - core::ops::function::FnOnce::call_once{{vtable.shim}}::h546778848e9193e6
  26:     0x7fa952882a27 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h09f167e08fc945ff
                               at /rustc/2faabf579323f5252329264cc53ba9ff803429a3/library/alloc/src/boxed.rs:1572:9
  27:     0x7fa952882a27 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hf814fe85eeb118e0
                               at /rustc/2faabf579323f5252329264cc53ba9ff803429a3/library/alloc/src/boxed.rs:1572:9
  28:     0x7fa952882a27 - std::sys::unix::thread::Thread::new::thread_start::hb71b17934c5f5e68
                               at /rustc/2faabf579323f5252329264cc53ba9ff803429a3/library/std/src/sys/unix/thread.rs:91:17
  29:     0x7fa9527af609 - start_thread
  30:     0x7fa9526c3293 - clone
  31:                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.56.0-nightly (2faabf579 2021-07-27) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type staticlib

query stack during panic:
end of query stack
thread panicked while panicking. aborting.

@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 Jul 28, 2021
@asquared31415
Copy link
Contributor

asquared31415 commented Jul 29, 2021

Functional playground example with comments explaining the source of the errors.

I highly doubt that this is a duplicate of that issue you linked.

The first ICE here is an error when trying to figure out generics. The drop_in_place lang item expects its function to have a generic, and the function you've declared doesn't. Adding the generic, even if you don't add the argument for it, avoids this ICE. The second ICE is related to the exact body of that function. Even though the body should be replaced by the compiler because of the lang item, the while loop still tries to make sure that bool is Copy, but there is no impl for that. Adding that impl Copy for bool or changing/removing the body of the drop_in_place fn avoids the second.

Ideally the compiler could emit nicer errors about expecting the generic and the trait bound that it tried to find, and I'm quite surprised that the second ICE wasn't nicer.

@asquared31415
Copy link
Contributor

The first ICE with the generics is probably relevant to #9307

@rust-lang-glacier-bot rust-lang-glacier-bot added the glacier ICE tracked in rust-lang/glacier. label Aug 12, 2021
bors added a commit to rust-lang-ci/rust that referenced this issue Aug 25, 2021
…jgillot

Improve detection of generics on lang items

Adds detection for the required generics for all lang items.  Many lang items require an exact or minimum amount of generic arguments and if they don't exist, the compiler will ICE.  This does not add any additional validation about bounds on generics or any other lang item restrictions.

Fixes one of the ICEs in rust-lang#87573

cc `@FabianWolff`
@Alexendoo
Copy link
Member

No longer ICEs since #87875 and #80357

@Alexendoo Alexendoo added the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label Aug 29, 2021
JohnTitor added a commit to JohnTitor/rust that referenced this issue Nov 16, 2021
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Nov 19, 2021
bors added a commit to rust-lang-ci/rust that referenced this issue Nov 20, 2021
…askrgr

Rollup of 8 pull requests

Successful merges:

 - rust-lang#88361 (Makes docs for references a little less confusing)
 - rust-lang#90089 (Improve display of enum variants)
 - rust-lang#90956 (Add a regression test for rust-lang#87573)
 - rust-lang#90999 (fix CTFE/Miri simd_insert/extract on array-style repr(simd) types)
 - rust-lang#91026 (rustdoc doctest: detect `fn main` after an unexpected semicolon)
 - rust-lang#91035 (Put back removed empty line)
 - rust-lang#91044 (Turn all 0x1b_u8 into '\x1b' or b'\x1b')
 - rust-lang#91054 (rustdoc: Fix some unescaped HTML tags in docs)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors closed this as completed in 5c98cf1 Nov 20, 2021
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. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. 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

Successfully merging a pull request may close this issue.

4 participants