Skip to content

ICE: index out of bounds: the len is 0 but the index is 0 snapshot_vec #10374

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

Closed
matthiaskrgr opened this issue Feb 19, 2023 · 3 comments
Closed
Labels
C-bug Category: Clippy is not doing the correct thing I-ICE Issue: Clippy panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@matthiaskrgr
Copy link
Member

Summary

This will probably need a rustc->clippy sync in order to be reproducible in the clippy repo.
File was added in rust-lang/rust#107772

./tests/ui/dyn-star/llvm-old-style-ptrs.rs

// run-pass
// compile-flags: -Copt-level=0 -Cllvm-args=-opaque-pointers=0

// (opaque-pointers flag is called force-opaque-pointers in LLVM 13...)
// min-llvm-version: 14.0

// This test can be removed once non-opaque pointers are gone from LLVM, maybe.

#![feature(dyn_star, pointer_like_trait)]
#![allow(incomplete_features)]

use std::fmt::Debug;
use std::marker::PointerLike;

fn make_dyn_star<'a>(t: impl PointerLike + Debug + 'a) -> dyn* Debug + 'a {
    t as _
}

fn main() {
    println!("{:?}", make_dyn_star(Box::new(1i32)));
    println!("{:?}", make_dyn_star(2usize));
    println!("{:?}", make_dyn_star((3usize,)));
}

Version

rustc 1.69.0-nightly (4507fdaaa 2023-02-18)
binary: rustc
commit-hash: 4507fdaaa27ea2fb59a41df2ce7d1f290da53dae
commit-date: 2023-02-18
host: x86_64-unknown-linux-gnu
release: 1.69.0-nightly
LLVM version: 15.0.7

Error output

Backtrace

thread 'rustc' panicked at 'index out of bounds: the len is 0 but the index is 0', /cargo/registry/src/index.crates.io-6f17d22bba15001f/ena-0.14.0/src/snapshot_vec.rs:199:10
stack backtrace:
 0:     0x7f111176aa7a - std::backtrace_rs::backtrace::libunwind::trace::h9ab7cd28287cf18f
                             at /rustc/4507fdaaa27ea2fb59a41df2ce7d1f290da53dae/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
 1:     0x7f111176aa7a - std::backtrace_rs::backtrace::trace_unsynchronized::h3e7e6ca06d1d63cf
                             at /rustc/4507fdaaa27ea2fb59a41df2ce7d1f290da53dae/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
 2:     0x7f111176aa7a - std::sys_common::backtrace::_print_fmt::h5b6184fd459f0c71
                             at /rustc/4507fdaaa27ea2fb59a41df2ce7d1f290da53dae/library/std/src/sys_common/backtrace.rs:65:5
 3:     0x7f111176aa7a - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h8ed5468732b78071
                             at /rustc/4507fdaaa27ea2fb59a41df2ce7d1f290da53dae/library/std/src/sys_common/backtrace.rs:44:22
 4:     0x7f11117ca9fe - core::fmt::write::h89c1e855e81d7a96
                             at /rustc/4507fdaaa27ea2fb59a41df2ce7d1f290da53dae/library/core/src/fmt/mod.rs:1232:17
 5:     0x7f111175af25 - std::io::Write::write_fmt::ha23ba71db044374b
                             at /rustc/4507fdaaa27ea2fb59a41df2ce7d1f290da53dae/library/std/src/io/mod.rs:1684:15
 6:     0x7f111176a845 - std::sys_common::backtrace::_print::h194cdf55c322d5fe
                             at /rustc/4507fdaaa27ea2fb59a41df2ce7d1f290da53dae/library/std/src/sys_common/backtrace.rs:47:5
 7:     0x7f111176a845 - std::sys_common::backtrace::print::h4549e75783bab124
                             at /rustc/4507fdaaa27ea2fb59a41df2ce7d1f290da53dae/library/std/src/sys_common/backtrace.rs:34:9
 8:     0x7f111176d5bf - std::panicking::default_hook::{{closure}}::h04a46ea9ff60bf2c
                             at /rustc/4507fdaaa27ea2fb59a41df2ce7d1f290da53dae/library/std/src/panicking.rs:267:22
 9:     0x7f111176d2fb - std::panicking::default_hook::h6f3c116d48f73fba
                             at /rustc/4507fdaaa27ea2fb59a41df2ce7d1f290da53dae/library/std/src/panicking.rs:286:9
10:     0x55cee00184c0 - clippy_driver[f0dcf01ecd52ed00]::ICE_HOOK::{closure#0}::{closure#0}
11:     0x7f111176ddfd - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h779d28c2deb011a8
                             at /rustc/4507fdaaa27ea2fb59a41df2ce7d1f290da53dae/library/alloc/src/boxed.rs:2002:9
12:     0x7f111176ddfd - std::panicking::rust_panic_with_hook::h5a936503487f19f5
                             at /rustc/4507fdaaa27ea2fb59a41df2ce7d1f290da53dae/library/std/src/panicking.rs:692:13
13:     0x7f111176db79 - std::panicking::begin_panic_handler::{{closure}}::hf8db4efce7a7f23f
                             at /rustc/4507fdaaa27ea2fb59a41df2ce7d1f290da53dae/library/std/src/panicking.rs:579:13
14:     0x7f111176aee6 - std::sys_common::backtrace::__rust_end_short_backtrace::h668cb6dbbf3929c2
                             at /rustc/4507fdaaa27ea2fb59a41df2ce7d1f290da53dae/library/std/src/sys_common/backtrace.rs:137:18
15:     0x7f111176d882 - rust_begin_unwind
                             at /rustc/4507fdaaa27ea2fb59a41df2ce7d1f290da53dae/library/std/src/panicking.rs:575:5
16:     0x7f11117c73a3 - core::panicking::panic_fmt::h6a86232234ce2127
                             at /rustc/4507fdaaa27ea2fb59a41df2ce7d1f290da53dae/library/core/src/panicking.rs:64:14
17:     0x7f11117c7592 - core::panicking::panic_bounds_check::h71a6710f1af624e4
                             at /rustc/4507fdaaa27ea2fb59a41df2ce7d1f290da53dae/library/core/src/panicking.rs:159:5
18:     0x7f1112a23267 - <ena[e9f14e00eff15fcd]::unify::UnificationTable<ena[e9f14e00eff15fcd]::unify::backing_vec::InPlace<rustc_middle[2a277d44e6a99f4f]::infer::unify_key::RegionVidKey, &mut alloc[d821da156a43ed98]::vec::Vec<ena[e9f14e00eff15fcd]::unify::VarValue<rustc_middle[2a277d44e6a99f4f]::infer::unify_key::RegionVidKey>>, &mut rustc_infer[80d058b2c2e7c69]::infer::undo_log::InferCtxtUndoLogs>>>::uninlined_get_root_key
19:     0x7f1112ae4c7d - <rustc_infer[80d058b2c2e7c69]::infer::canonical::canonicalizer::Canonicalizer as rustc_type_ir[8beb17bdab38ad78]::fold::TypeFolder<rustc_middle[2a277d44e6a99f4f]::ty::context::TyCtxt>>::fold_region
20:     0x7f1112d3a8e8 - rustc_middle[2a277d44e6a99f4f]::ty::util::fold_list::<rustc_infer[80d058b2c2e7c69]::infer::canonical::canonicalizer::Canonicalizer, rustc_middle[2a277d44e6a99f4f]::ty::Predicate, <&rustc_middle[2a277d44e6a99f4f]::ty::list::List<rustc_middle[2a277d44e6a99f4f]::ty::Predicate> as rustc_type_ir[8beb17bdab38ad78]::fold::TypeFoldable<rustc_middle[2a277d44e6a99f4f]::ty::context::TyCtxt>>::try_fold_with<rustc_infer[80d058b2c2e7c69]::infer::canonical::canonicalizer::Canonicalizer>::{closure#0}>
21:     0x7f11133b5838 - <rustc_infer[80d058b2c2e7c69]::infer::InferCtxt as rustc_trait_selection[56e02159555b3df4]::traits::query::evaluate_obligation::InferCtxtExt>::predicate_must_hold_modulo_regions
22:     0x7f11133b503b - rustc_trait_selection[56e02159555b3df4]::traits::type_known_to_meet_bound_modulo_regions
23:     0x7f11133b4cdc - rustc_ty_utils[ee275bd23a42692]::common_traits::is_sized_raw
24:     0x7f1113703e0b - <rustc_middle[2a277d44e6a99f4f]::ty::Ty>::is_sized
25:     0x7f111346d39b - rustc_ty_utils[ee275bd23a42692]::layout::layout_of
26:     0x7f111362dac9 - rustc_query_system[46560f6823c6ac3e]::query::plumbing::get_query::<rustc_query_impl[34788ad4354c9a05]::queries::layout_of, rustc_query_impl[34788ad4354c9a05]::plumbing::QueryCtxt, rustc_middle[2a277d44e6a99f4f]::dep_graph::dep_node::DepKind>
27:     0x7f111362d6b3 - <rustc_query_impl[34788ad4354c9a05]::Queries as rustc_middle[2a277d44e6a99f4f]::ty::query::QueryEngine>::layout_of
28:     0x7f11130cd123 - <rustc_trait_selection[56e02159555b3df4]::traits::select::SelectionContext>::assemble_candidate_for_ptr_sized
29:     0x7f11130a9e84 - <rustc_trait_selection[56e02159555b3df4]::traits::select::SelectionContext>::assemble_candidates
30:     0x7f1112bdd1fe - <rustc_trait_selection[56e02159555b3df4]::traits::select::SelectionContext>::candidate_from_obligation_no_cache
31:     0x7f1112bdc5df - <rustc_query_system[46560f6823c6ac3e]::dep_graph::graph::DepGraph<rustc_middle[2a277d44e6a99f4f]::dep_graph::dep_node::DepKind>>::with_anon_task::<rustc_middle[2a277d44e6a99f4f]::ty::context::TyCtxt, <rustc_trait_selection[56e02159555b3df4]::traits::select::SelectionContext>::in_task<<rustc_trait_selection[56e02159555b3df4]::traits::select::SelectionContext>::candidate_from_obligation::{closure#0}::{closure#0}, core[69c2f5c35675f1ee]::result::Result<core[69c2f5c35675f1ee]::option::Option<rustc_middle[2a277d44e6a99f4f]::traits::select::SelectionCandidate>, rustc_middle[2a277d44e6a99f4f]::traits::SelectionError>>::{closure#0}, core[69c2f5c35675f1ee]::result::Result<core[69c2f5c35675f1ee]::option::Option<rustc_middle[2a277d44e6a99f4f]::traits::select::SelectionCandidate>, rustc_middle[2a277d44e6a99f4f]::traits::SelectionError>>
32:     0x7f1112bd5a97 - <rustc_trait_selection[56e02159555b3df4]::traits::select::SelectionContext>::evaluate_stack
33:     0x7f1113626cdf - <rustc_trait_selection[56e02159555b3df4]::traits::select::SelectionContext>::evaluate_predicate_recursively
34:     0x7f1113624883 - <rustc_infer[80d058b2c2e7c69]::infer::InferCtxt>::probe::<core[69c2f5c35675f1ee]::result::Result<rustc_middle[2a277d44e6a99f4f]::traits::select::EvaluationResult, rustc_middle[2a277d44e6a99f4f]::traits::select::OverflowError>, <rustc_trait_selection[56e02159555b3df4]::traits::select::SelectionContext>::evaluation_probe<<rustc_trait_selection[56e02159555b3df4]::traits::select::SelectionContext>::evaluate_root_obligation::{closure#0}>::{closure#0}>
35:     0x7f11132dfe02 - rustc_traits[92224ab987017c6]::evaluate_obligation::evaluate_obligation
36:     0x7f11132dd096 - rustc_query_system[46560f6823c6ac3e]::query::plumbing::get_query::<rustc_query_impl[34788ad4354c9a05]::queries::evaluate_obligation, rustc_query_impl[34788ad4354c9a05]::plumbing::QueryCtxt, rustc_middle[2a277d44e6a99f4f]::dep_graph::dep_node::DepKind>
37:     0x7f111338c815 - <rustc_infer[80d058b2c2e7c69]::infer::InferCtxt as rustc_trait_selection[56e02159555b3df4]::traits::query::evaluate_obligation::InferCtxtExt>::evaluate_obligation
38:     0x55cee0409cba - clippy_utils[a5661489ba05b5cc]::ty::implements_trait
39:     0x55cee033e99f - <clippy_lints[4079790fda0cdfd1]::needless_pass_by_value::NeedlessPassByValue as rustc_lint[d21e6d472070f61c]::passes::LateLintPass>::check_fn
40:     0x7f1114e515ad - <rustc_lint[d21e6d472070f61c]::late::RuntimeCombinedLateLintPass as rustc_lint[d21e6d472070f61c]::passes::LateLintPass>::check_fn
41:     0x7f1114e18569 - <rustc_lint[d21e6d472070f61c]::late::LateContextAndPass<rustc_lint[d21e6d472070f61c]::late::RuntimeCombinedLateLintPass> as rustc_hir[1e8fd85835ba83b0]::intravisit::Visitor>::visit_fn
42:     0x7f1114deda5d - rustc_hir[1e8fd85835ba83b0]::intravisit::walk_item::<rustc_lint[d21e6d472070f61c]::late::LateContextAndPass<rustc_lint[d21e6d472070f61c]::late::RuntimeCombinedLateLintPass>>
43:     0x7f1114e189c0 - <rustc_lint[d21e6d472070f61c]::late::LateContextAndPass<rustc_lint[d21e6d472070f61c]::late::RuntimeCombinedLateLintPass> as rustc_hir[1e8fd85835ba83b0]::intravisit::Visitor>::visit_nested_item
44:     0x7f1114ded2b8 - rustc_hir[1e8fd85835ba83b0]::intravisit::walk_mod::<rustc_lint[d21e6d472070f61c]::late::LateContextAndPass<rustc_lint[d21e6d472070f61c]::late::RuntimeCombinedLateLintPass>>
45:     0x7f11140a3323 - rustc_lint[d21e6d472070f61c]::late::late_lint_crate::<rustc_lint[d21e6d472070f61c]::BuiltinCombinedLateLintPass>
46:     0x7f11140a2672 - <rustc_session[403a5d4fc02438c2]::session::Session>::time::<(), rustc_lint[d21e6d472070f61c]::late::check_crate<rustc_lint[d21e6d472070f61c]::BuiltinCombinedLateLintPass, rustc_interface[3e6023fe39c52850]::passes::analysis::{closure#6}::{closure#1}::{closure#2}::{closure#0}::{closure#0}>::{closure#0}::{closure#0}>
47:     0x7f11140a24d2 - <rustc_session[403a5d4fc02438c2]::session::Session>::time::<(), rustc_interface[3e6023fe39c52850]::passes::analysis::{closure#6}::{closure#1}::{closure#2}::{closure#0}>
48:     0x7f11140a215b - <core[69c2f5c35675f1ee]::panic::unwind_safe::AssertUnwindSafe<rustc_interface[3e6023fe39c52850]::passes::analysis::{closure#6}::{closure#1}> as core[69c2f5c35675f1ee]::ops::function::FnOnce<()>>::call_once
49:     0x7f1112efff4d - <rustc_session[403a5d4fc02438c2]::session::Session>::time::<(), rustc_interface[3e6023fe39c52850]::passes::analysis::{closure#6}>
50:     0x7f1112efec8a - rustc_interface[3e6023fe39c52850]::passes::analysis
51:     0x7f1114258e62 - rustc_query_system[46560f6823c6ac3e]::query::plumbing::try_execute_query::<rustc_query_impl[34788ad4354c9a05]::queries::analysis, rustc_query_impl[34788ad4354c9a05]::plumbing::QueryCtxt>
52:     0x7f111442ed8a - <rustc_query_impl[34788ad4354c9a05]::Queries as rustc_middle[2a277d44e6a99f4f]::ty::query::QueryEngine>::analysis
53:     0x7f1113cc79f6 - <rustc_middle[2a277d44e6a99f4f]::ty::context::GlobalCtxt>::enter::<rustc_driver_impl[48a98004e06292cf]::run_compiler::{closure#1}::{closure#2}::{closure#3}, core[69c2f5c35675f1ee]::result::Result<(), rustc_errors[abf5e0320c3520e7]::ErrorGuaranteed>>
54:     0x7f1113cc68e6 - <rustc_interface[3e6023fe39c52850]::interface::Compiler>::enter::<rustc_driver_impl[48a98004e06292cf]::run_compiler::{closure#1}::{closure#2}, core[69c2f5c35675f1ee]::result::Result<core[69c2f5c35675f1ee]::option::Option<rustc_interface[3e6023fe39c52850]::queries::Linker>, rustc_errors[abf5e0320c3520e7]::ErrorGuaranteed>>
55:     0x7f1113cc49c4 - rustc_span[97beb3ced854c2e2]::with_source_map::<core[69c2f5c35675f1ee]::result::Result<(), rustc_errors[abf5e0320c3520e7]::ErrorGuaranteed>, rustc_interface[3e6023fe39c52850]::interface::run_compiler<core[69c2f5c35675f1ee]::result::Result<(), rustc_errors[abf5e0320c3520e7]::ErrorGuaranteed>, rustc_driver_impl[48a98004e06292cf]::run_compiler::{closure#1}>::{closure#0}::{closure#0}>
56:     0x7f1113cc3f2d - std[d6315e0f51da5517]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[3e6023fe39c52850]::util::run_in_thread_pool_with_globals<rustc_interface[3e6023fe39c52850]::interface::run_compiler<core[69c2f5c35675f1ee]::result::Result<(), rustc_errors[abf5e0320c3520e7]::ErrorGuaranteed>, rustc_driver_impl[48a98004e06292cf]::run_compiler::{closure#1}>::{closure#0}, core[69c2f5c35675f1ee]::result::Result<(), rustc_errors[abf5e0320c3520e7]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[69c2f5c35675f1ee]::result::Result<(), rustc_errors[abf5e0320c3520e7]::ErrorGuaranteed>>
57:     0x7f1113cc397c - <<std[d6315e0f51da5517]::thread::Builder>::spawn_unchecked_<rustc_interface[3e6023fe39c52850]::util::run_in_thread_pool_with_globals<rustc_interface[3e6023fe39c52850]::interface::run_compiler<core[69c2f5c35675f1ee]::result::Result<(), rustc_errors[abf5e0320c3520e7]::ErrorGuaranteed>, rustc_driver_impl[48a98004e06292cf]::run_compiler::{closure#1}>::{closure#0}, core[69c2f5c35675f1ee]::result::Result<(), rustc_errors[abf5e0320c3520e7]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[69c2f5c35675f1ee]::result::Result<(), rustc_errors[abf5e0320c3520e7]::ErrorGuaranteed>>::{closure#1} as core[69c2f5c35675f1ee]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
58:     0x7f1111777c83 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::heeffe32503a99aa5
                             at /rustc/4507fdaaa27ea2fb59a41df2ce7d1f290da53dae/library/alloc/src/boxed.rs:1988:9
59:     0x7f1111777c83 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h5085270dbf970bb4
                             at /rustc/4507fdaaa27ea2fb59a41df2ce7d1f290da53dae/library/alloc/src/boxed.rs:1988:9
60:     0x7f1111777c83 - std::sys::unix::thread::Thread::new::thread_start::h76c3abd575e0d195
                             at /rustc/4507fdaaa27ea2fb59a41df2ce7d1f290da53dae/library/std/src/sys/unix/thread.rs:108:17
61:     0x7f11113e8bb5 - <unknown>
62:     0x7f111146ad90 - <unknown>
63:                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-clippy/issues/new

note: Clippy version: clippy 0.1.69 (4507fda 2023-02-18)

query stack during panic:
#0 [is_sized_raw] computing whether `impl PointerLike + Debug + 'a` is `Sized`
#1 [layout_of] computing layout of `&impl PointerLike + Debug + 'a`
#2 [evaluate_obligation] evaluating trait selection obligation `&impl PointerLike + Debug + 'a: core::marker::PointerLike`
#3 [analysis] running analysis passes on this crate
end of query stack

@matthiaskrgr matthiaskrgr added C-bug Category: Clippy is not doing the correct thing I-ICE Issue: Clippy panicked, giving an Internal Compilation Error (ICE) ❄️ labels Feb 19, 2023
@matthiaskrgr
Copy link
Member Author

Reduced to

#![feature(pointer_like_trait)]
#![allow(incomplete_features)]

fn make_dyn_star<'a>(t: impl std::marker::PointerLike + 'a)  {
    todo!();
}

fn main() {}

@Jarcho
Copy link
Contributor

Jarcho commented Feb 22, 2023

I'm not sure if that's a clippy bug. The obligation it's failing on is valid and shouldn't crash. Unless we set the ParamEnv wrong somehow.

The ParamEnv is set correctly.

Somehow a RegionKind::ReVar(_) is ending up in the query. Only way I can see that happening is through the predicates contained in the ParamEnv. Current code has an obligation of the form &'erased T: std::marker::PointerLike which evaluates a second obligation T: Sized. Not sure where the stray region variable comes from.

@Jarcho
Copy link
Contributor

Jarcho commented Aug 3, 2024

This no longer crashes on 2024-08-02

@Jarcho Jarcho closed this as completed Aug 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: Clippy is not doing the correct thing I-ICE Issue: Clippy panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

No branches or pull requests

2 participants