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 out of bounds #[rustc_host] #115265

Closed
matthiaskrgr opened this issue Aug 27, 2023 · 9 comments
Closed

ICE: index out of bounds #[rustc_host] #115265

matthiaskrgr opened this issue Aug 27, 2023 · 9 comments
Labels
C-bug Category: This is a bug. F-effects `#![feature(effects)]` F-rustc_attrs Internal rustc attributes gated on the `#[rustc_attrs]` feature gate. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-low Low priority regression-from-stable-to-beta Performance or correctness regression from stable to beta. requires-internal-features This issue requires the use of internal features. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@matthiaskrgr
Copy link
Member

Code

trait Fake {}
impl<T, #[rustc_host] const host: bool = true> Fake for T {}

Meta

rustc --version --verbose:

rustc 1.74.0-nightly (69e97df5c 2023-08-26)
binary: rustc
commit-hash: 69e97df5ce571a777acd654ec3697ae8d25962ea
commit-date: 2023-08-26
host: x86_64-unknown-linux-gnu
release: 1.74.0-nightly
LLVM version: 17.0.0

Error output

error[E0658]: #[rustc_host] annotates const generic parameters as the `host` effect param, and it is only intended for internal use and as a desugaring.
 --> icemaker_reduced/F468B92A11E7FFBD4CF8B971AE2AA2D6EC86BEE083B0F18C53B36FFBC97CD71B.rs:2:9
  |
2 | impl<T, #[rustc_host] const host: bool = true> Fake for T {}
  |         ^^^^^^^^^^^^^
  |
  = help: add `#![feature(rustc_attrs)]` to the crate attributes to enable

error[E0601]: `main` function not found in crate `F468B92A11E7FFBD4CF8B971AE2AA2D6EC86BEE083B0F18C53B36FFBC97CD71B`
 --> icemaker_reduced/F468B92A11E7FFBD4CF8B971AE2AA2D6EC86BEE083B0F18C53B36FFBC97CD71B.rs:2:61
  |
2 | impl<T, #[rustc_host] const host: bool = true> Fake for T {}
  |                                                             ^ consider adding a `main` function to `icemaker_reduced/F468B92A11E7FFBD4CF8B971AE2AA2D6EC86BEE083B0F18C53B36FFBC97CD71B.rs`

error: const `impl` for trait `Fake` which is not marked with `#[const_trait]`
 --> icemaker_reduced/F468B92A11E7FFBD4CF8B971AE2AA2D6EC86BEE083B0F18C53B36FFBC97CD71B.rs:2:48
  |
2 | impl<T, #[rustc_host] const host: bool = true> Fake for T {}
  |                                                ^^^^ help: mark `Fake` as const: `#[const_trait]`
  |
  = note: marking a trait with `#[const_trait]` ensures all default method bodies are `const`
  = note: adding a non-const method body in the future would be a breaking change
Backtrace

thread 'rustc' panicked at compiler/rustc_hir_analysis/src/collect.rs:1376:34:
index out of bounds: the len is 0 but the index is 18446744073709551615
stack backtrace:
   0:     0x7ff416b62fac - std::backtrace_rs::backtrace::libunwind::trace::h7ead10aab469b9aa
                               at /rustc/69e97df5ce571a777acd654ec3697ae8d25962ea/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7ff416b62fac - std::backtrace_rs::backtrace::trace_unsynchronized::hf548e9e8c1fe3e8d
                               at /rustc/69e97df5ce571a777acd654ec3697ae8d25962ea/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7ff416b62fac - std::sys_common::backtrace::_print_fmt::h4f790d56eeca616b
                               at /rustc/69e97df5ce571a777acd654ec3697ae8d25962ea/library/std/src/sys_common/backtrace.rs:67:5
   3:     0x7ff416b62fac - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h30e5bb3d4404f378
                               at /rustc/69e97df5ce571a777acd654ec3697ae8d25962ea/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7ff416bc91dc - core::fmt::rt::Argument::fmt::h35f06f2256f98b43
                               at /rustc/69e97df5ce571a777acd654ec3697ae8d25962ea/library/core/src/fmt/rt.rs:138:9
   5:     0x7ff416bc91dc - core::fmt::write::h5005ce68dd6774c4
                               at /rustc/69e97df5ce571a777acd654ec3697ae8d25962ea/library/core/src/fmt/mod.rs:1094:21
   6:     0x7ff416b55cae - std::io::Write::write_fmt::h8a7c95ddeefaf4be
                               at /rustc/69e97df5ce571a777acd654ec3697ae8d25962ea/library/std/src/io/mod.rs:1714:15
   7:     0x7ff416b62d94 - std::sys_common::backtrace::_print::hedccafa15bd98864
                               at /rustc/69e97df5ce571a777acd654ec3697ae8d25962ea/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x7ff416b62d94 - std::sys_common::backtrace::print::h911d101d11c4e8b0
                               at /rustc/69e97df5ce571a777acd654ec3697ae8d25962ea/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7ff416b65e8a - std::panicking::panic_hook_with_disk_dump::{{closure}}::he8cf7cbd1dd11756
                               at /rustc/69e97df5ce571a777acd654ec3697ae8d25962ea/library/std/src/panicking.rs:278:22
  10:     0x7ff416b65b78 - std::panicking::panic_hook_with_disk_dump::h3baf172fecd393f6
                               at /rustc/69e97df5ce571a777acd654ec3697ae8d25962ea/library/std/src/panicking.rs:312:9
  11:     0x7ff419d4a279 - <rustc_driver_impl[98acc53e2d2f6ece]::install_ice_hook::{closure#0} as core[cb689c380e703cde]::ops::function::FnOnce<(&core[cb689c380e703cde]::panic::panic_info::PanicInfo,)>>::call_once::{shim:vtable#0}
  12:     0x7ff416b66731 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h8e3b5b4f77120996
                               at /rustc/69e97df5ce571a777acd654ec3697ae8d25962ea/library/alloc/src/boxed.rs:2021:9
  13:     0x7ff416b66731 - std::panicking::rust_panic_with_hook::hcec56ff9d71a6f8a
                               at /rustc/69e97df5ce571a777acd654ec3697ae8d25962ea/library/std/src/panicking.rs:733:13
  14:     0x7ff416b664b7 - std::panicking::begin_panic_handler::{{closure}}::h080d65de76ce8958
                               at /rustc/69e97df5ce571a777acd654ec3697ae8d25962ea/library/std/src/panicking.rs:621:13
  15:     0x7ff416b634d6 - std::sys_common::backtrace::__rust_end_short_backtrace::had2be8eed332cfa1
                               at /rustc/69e97df5ce571a777acd654ec3697ae8d25962ea/library/std/src/sys_common/backtrace.rs:170:18
  16:     0x7ff416b66202 - rust_begin_unwind
                               at /rustc/69e97df5ce571a777acd654ec3697ae8d25962ea/library/std/src/panicking.rs:617:5
  17:     0x7ff416bc55c3 - core::panicking::panic_fmt::he0f6263a3bff06fd
                               at /rustc/69e97df5ce571a777acd654ec3697ae8d25962ea/library/core/src/panicking.rs:67:14
  18:     0x7ff416bc5719 - core::panicking::panic_bounds_check::h0b0bc4c77a041494
                               at /rustc/69e97df5ce571a777acd654ec3697ae8d25962ea/library/core/src/panicking.rs:162:5
  19:     0x7ff418fd5777 - rustc_hir_analysis[667fece327758e4f]::collect::impl_trait_ref
  20:     0x7ff417e72408 - rustc_query_impl[58a3c40f53c1e9dd]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[58a3c40f53c1e9dd]::query_impl::impl_trait_ref::dynamic_query::{closure#2}::{closure#0}, rustc_middle[464349d56e47250b]::query::erase::Erased<[u8; 16usize]>>
  21:     0x7ff417ebe8cb - rustc_query_system[771da89a8e6a97f0]::query::plumbing::try_execute_query::<rustc_query_impl[58a3c40f53c1e9dd]::DynamicConfig<rustc_query_system[771da89a8e6a97f0]::query::caches::DefaultCache<rustc_span[c92a35b362599b57]::def_id::DefId, rustc_middle[464349d56e47250b]::query::erase::Erased<[u8; 16usize]>>, false, false, false>, rustc_query_impl[58a3c40f53c1e9dd]::plumbing::QueryCtxt, false>
  22:     0x7ff417ebe564 - rustc_query_impl[58a3c40f53c1e9dd]::query_impl::impl_trait_ref::get_query_non_incr::__rust_end_short_backtrace
  23:     0x7ff4184080b9 - <rustc_hir_analysis[667fece327758e4f]::collect::CollectItemTypesVisitor as rustc_hir[3a72116ea74f2480]::intravisit::Visitor>::visit_item
  24:     0x7ff4184063f7 - <rustc_middle[464349d56e47250b]::hir::map::Map>::visit_item_likes_in_module::<rustc_hir_analysis[667fece327758e4f]::collect::CollectItemTypesVisitor>
  25:     0x7ff4184062ac - rustc_hir_analysis[667fece327758e4f]::collect::collect_mod_item_types
  26:     0x7ff418a746fc - rustc_query_impl[58a3c40f53c1e9dd]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[58a3c40f53c1e9dd]::query_impl::collect_mod_item_types::dynamic_query::{closure#2}::{closure#0}, rustc_middle[464349d56e47250b]::query::erase::Erased<[u8; 0usize]>>
  27:     0x7ff418a746de - <rustc_query_impl[58a3c40f53c1e9dd]::query_impl::collect_mod_item_types::dynamic_query::{closure#2} as core[cb689c380e703cde]::ops::function::FnOnce<(rustc_middle[464349d56e47250b]::ty::context::TyCtxt, rustc_span[c92a35b362599b57]::def_id::LocalModDefId)>>::call_once
  28:     0x7ff418d74923 - rustc_query_system[771da89a8e6a97f0]::query::plumbing::try_execute_query::<rustc_query_impl[58a3c40f53c1e9dd]::DynamicConfig<rustc_query_system[771da89a8e6a97f0]::query::caches::DefaultCache<rustc_span[c92a35b362599b57]::def_id::LocalModDefId, rustc_middle[464349d56e47250b]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[58a3c40f53c1e9dd]::plumbing::QueryCtxt, false>
  29:     0x7ff4196cd374 - rustc_query_impl[58a3c40f53c1e9dd]::query_impl::collect_mod_item_types::get_query_non_incr::__rust_end_short_backtrace
  30:     0x7ff418c715d7 - <rustc_middle[464349d56e47250b]::hir::map::Map>::for_each_module::<rustc_hir_analysis[667fece327758e4f]::check_crate::{closure#0}::{closure#0}::{closure#0}>
  31:     0x7ff418c7018f - rustc_hir_analysis[667fece327758e4f]::check_crate
  32:     0x7ff418c69c4a - rustc_interface[b81038288d48d278]::passes::analysis
  33:     0x7ff41925ca4a - rustc_query_impl[58a3c40f53c1e9dd]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[58a3c40f53c1e9dd]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[464349d56e47250b]::query::erase::Erased<[u8; 1usize]>>
  34:     0x7ff41925ca39 - <rustc_query_impl[58a3c40f53c1e9dd]::query_impl::analysis::dynamic_query::{closure#2} as core[cb689c380e703cde]::ops::function::FnOnce<(rustc_middle[464349d56e47250b]::ty::context::TyCtxt, ())>>::call_once
  35:     0x7ff4193ecc18 - rustc_query_system[771da89a8e6a97f0]::query::plumbing::try_execute_query::<rustc_query_impl[58a3c40f53c1e9dd]::DynamicConfig<rustc_query_system[771da89a8e6a97f0]::query::caches::SingleCache<rustc_middle[464349d56e47250b]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[58a3c40f53c1e9dd]::plumbing::QueryCtxt, false>
  36:     0x7ff4193ec999 - rustc_query_impl[58a3c40f53c1e9dd]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  37:     0x7ff419028da6 - <rustc_middle[464349d56e47250b]::ty::context::GlobalCtxt>::enter::<rustc_driver_impl[98acc53e2d2f6ece]::run_compiler::{closure#1}::{closure#2}::{closure#6}, core[cb689c380e703cde]::result::Result<(), rustc_span[c92a35b362599b57]::ErrorGuaranteed>>
  38:     0x7ff41902822c - <rustc_interface[b81038288d48d278]::interface::Compiler>::enter::<rustc_driver_impl[98acc53e2d2f6ece]::run_compiler::{closure#1}::{closure#2}, core[cb689c380e703cde]::result::Result<core[cb689c380e703cde]::option::Option<rustc_interface[b81038288d48d278]::queries::Linker>, rustc_span[c92a35b362599b57]::ErrorGuaranteed>>
  39:     0x7ff419025548 - std[ebccec195fc5e844]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[b81038288d48d278]::util::run_in_thread_pool_with_globals<rustc_interface[b81038288d48d278]::interface::run_compiler<core[cb689c380e703cde]::result::Result<(), rustc_span[c92a35b362599b57]::ErrorGuaranteed>, rustc_driver_impl[98acc53e2d2f6ece]::run_compiler::{closure#1}>::{closure#0}, core[cb689c380e703cde]::result::Result<(), rustc_span[c92a35b362599b57]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[cb689c380e703cde]::result::Result<(), rustc_span[c92a35b362599b57]::ErrorGuaranteed>>
  40:     0x7ff4195c60f5 - <<std[ebccec195fc5e844]::thread::Builder>::spawn_unchecked_<rustc_interface[b81038288d48d278]::util::run_in_thread_pool_with_globals<rustc_interface[b81038288d48d278]::interface::run_compiler<core[cb689c380e703cde]::result::Result<(), rustc_span[c92a35b362599b57]::ErrorGuaranteed>, rustc_driver_impl[98acc53e2d2f6ece]::run_compiler::{closure#1}>::{closure#0}, core[cb689c380e703cde]::result::Result<(), rustc_span[c92a35b362599b57]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[cb689c380e703cde]::result::Result<(), rustc_span[c92a35b362599b57]::ErrorGuaranteed>>::{closure#1} as core[cb689c380e703cde]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  41:     0x7ff416b71195 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hf6677bb1228f81ea
                               at /rustc/69e97df5ce571a777acd654ec3697ae8d25962ea/library/alloc/src/boxed.rs:2007:9
  42:     0x7ff416b71195 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h4f3130db7e13aaba
                               at /rustc/69e97df5ce571a777acd654ec3697ae8d25962ea/library/alloc/src/boxed.rs:2007:9
  43:     0x7ff416b71195 - std::sys::unix::thread::Thread::new::thread_start::h17fc5e491c7b31dd
                               at /rustc/69e97df5ce571a777acd654ec3697ae8d25962ea/library/std/src/sys/unix/thread.rs:108:17
  44:     0x7ff41688c9eb - <unknown>
  45:     0x7ff416910ebc - <unknown>
  46:                0x0 - <unknown>

error: 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: please attach the file at `/tmp/host/rustc-ice-2023-08-27T08:39:34.669355941Z-794436.txt` to your bug report

query stack during panic:
#0 [impl_trait_ref] computing trait implemented by `<impl at icemaker_reduced/F468B92A11E7FFBD4CF8B971AE2AA2D6EC86BEE083B0F18C53B36FFBC97CD71B.rs:2:1: 2:58>`
#1 [collect_mod_item_types] collecting item types in top-level module
#2 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 3 previous errors

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

@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. regression-from-stable-to-beta Performance or correctness regression from stable to beta. C-bug Category: This is a bug. labels Aug 27, 2023
@rustbot rustbot added needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels Aug 27, 2023
@matthiaskrgr
Copy link
Member Author

This crashes beta but not stable (yet) but will become a stable regression on the next bump.
It would be nice to prevent in-progress features leaking their crashes into the stable toolchain.

@matthiaskrgr
Copy link
Member Author

Regression in nightly-2023-08-09
Regression in f88a8b7

#114545

@fmease
Copy link
Member

fmease commented Aug 27, 2023

It would be nice to prevent in-progress features leaking their crashes into the stable toolchain.

That would be very nice indeed1 but in this specific case the probability of a real user being affected is 0% since there's no way anyone would actually use #[rustc_host], an internal feature.

@rustbot label -needs-triage F-effects F-rustc_attrs requires-internal-features

Footnotes

  1. By having better quality control if we were to have more resources. Different branches (nightly vs. nightly-experiments) wouldn't make sense if that's what you are alluding to.

@rustbot rustbot added F-effects `#![feature(effects)]` F-rustc_attrs Internal rustc attributes gated on the `#[rustc_attrs]` feature gate. requires-internal-features This issue requires the use of internal features. and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Aug 27, 2023
@matthiaskrgr
Copy link
Member Author

Shouldn't it trigger the internal_features lint then? 🤔

@fmease
Copy link
Member

fmease commented Aug 27, 2023

The lints incomplete_features and internal_features are only triggered if you explicitly use #![feature]. As you probably know, even if the user doesn't enable a specific feature with #![feature], in most cases the compiler resumes after emitting a feature gate error and still interprets said feature according to its semantics whose implementation might contain bugs that you discover.

Even without an explicit #![feature] to all intents and purposes such a bug was caused using the respective feature and therefore it warrants F-* and requires-*-features labels.

Edit: Here, #[rustc_host] requires F-rustc_attrs Internal rustc attributes gated on the `#[rustc_attrs]` feature gate. which is an internal feature, hence the requires-internal-features This issue requires the use of internal features. . Internal features come with next to no stability guarantees.

The error #[rustc_host] annotates const generic parameters as the host effect param, and it is only intended for internal use and as a desugaring. emitted before the ICE is the feature gate error that informs the user that they are attempting to use an internal feature and which implicitly signals that resulting ICEs are not necessarily bugs.

@fmease
Copy link
Member

fmease commented Aug 27, 2023

Let's leave this open for @fee1-dead to judge if this ICE is an indication for a more serious bug in the implementation or if it's a WONTFIX

@Noratrieb
Copy link
Member

error[E0658]: #[rustc_host] annotates const generic parameters as the host effect param, and it is only intended for internal use and as a desugaring.

a feature error was emitted, and doing the recovery and applying it anyways despite the feature error is generally a useful thing to do for example for some of the rustc debugging attrs

@apiraino
Copy link
Contributor

WG-prioritization assigning priority (Zulip discussion). Tentatively assigning P-high to monitor the conversation and eventually decide what to do.

If this issue (or the more general topic) would benefit from a T-compiler time slot to be discussed, please don't hesitate to apply the I-compiler-nominated label.

@rustbot label -I-prioritize +P-high

@rustbot rustbot added P-high High priority and removed I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels Aug 29, 2023
@apiraino apiraino added P-low Low priority and removed P-high High priority labels Aug 29, 2023
@fmease
Copy link
Member

fmease commented Dec 4, 2023

Triage: This requires internal features as explained here: #115265 (comment). Therefore closing as not planned.

#118605 will fix this issue but that's not relevant.

@fmease fmease closed this as not planned Won't fix, can't repro, duplicate, stale Dec 4, 2023
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. F-effects `#![feature(effects)]` F-rustc_attrs Internal rustc attributes gated on the `#[rustc_attrs]` feature gate. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-low Low priority regression-from-stable-to-beta Performance or correctness regression from stable to beta. requires-internal-features This issue requires the use of internal features. 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

5 participants