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 "Not enough bound vars" #104916

Closed
jruderman opened this issue Nov 25, 2022 · 3 comments · Fixed by #110147
Closed

ICE "Not enough bound vars" #104916

jruderman opened this issue Nov 25, 2022 · 3 comments · Fixed by #110147
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. F-associated_type_bounds `#![feature(associated_type_bounds)]` I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ requires-debug-assertions This issue requires a build of rustc or tooling with debug-assertions in some way T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@jruderman
Copy link
Contributor

Found with a modified fuzz-rustc

Code

#![feature(associated_type_bounds)]

trait B {
    type AssocType;
}

fn f()
where
    dyn for<'j> B<AssocType: 'j>:,
{
}

fn main() {}

ICE (with debug assertions enabled)

error: internal compiler error: compiler/rustc_middle/src/ty/visit.rs:415: Not enough bound vars: BoundRegion { var: 0, kind: BrNamed(DefId(0:6 ~ hy[af0c]::f::'j), 'j) } not found in []

Backtrace

error: internal compiler error: compiler/rustc_middle/src/ty/visit.rs:415:21: Not enough bound vars: BoundRegion { var: 0, kind: BrNamed(DefId(0:6 ~ hy[af0c]::f::'j), 'j) } not found in []

thread 'rustc' panicked at 'Box<dyn Any>', /Users/jruderman/code/rust/compiler/rustc_errors/src/lib.rs:1575:9
stack backtrace:
   0:        0x106455f21 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hcf5aac4d53eab431
   1:        0x106513818 - core::fmt::write::hed31846cddb4e13c
   2:        0x1064b8ec8 - std::io::Write::write_fmt::h01887004f97cedc7
   3:        0x106455d12 - std::sys_common::backtrace::print::h2141c6543b5865e5
   4:        0x1064b9e45 - std::panicking::default_hook::{{closure}}::hfe93a58a10a72158
   5:        0x1064b9c2e - std::panicking::default_hook::hafca10424d622dfb
   6:        0x115a11398 - rustc_driver[b73731b7ed8e79fd]::DEFAULT_HOOK::{closure#0}::{closure#0}
   7:        0x1064ba636 - std::panicking::rust_panic_with_hook::hafe3bb82e805c420
   8:        0x11a9a8337 - std[e4564114326e8c6]::panicking::begin_panic::<rustc_errors[9121627fb7cf2262]::ExplicitBug>::{closure#0}
   9:        0x11a9a82a9 - std[e4564114326e8c6]::sys_common::backtrace::__rust_end_short_backtrace::<std[e4564114326e8c6]::panicking::begin_panic<rustc_errors[9121627fb7cf2262]::ExplicitBug>::{closure#0}, !>
  10:        0x11b0a9b89 - std[e4564114326e8c6]::panicking::begin_panic::<rustc_errors[9121627fb7cf2262]::ExplicitBug>
  11:        0x11a8c9f69 - std[e4564114326e8c6]::panic::panic_any::<rustc_errors[9121627fb7cf2262]::ExplicitBug>
  12:        0x11a8c9e9d - <rustc_errors[9121627fb7cf2262]::HandlerInner>::bug::<&alloc[fd2a8df82bfdc6c8]::string::String>
  13:        0x11a8c99d1 - <rustc_errors[9121627fb7cf2262]::Handler>::bug::<&alloc[fd2a8df82bfdc6c8]::string::String>
  14:        0x11aa1e0c2 - rustc_middle[db449b3460385d6f]::ty::context::tls::with_opt::<rustc_middle[db449b3460385d6f]::util::bug::opt_span_bug_fmt<rustc_span[3733f809f3ebe388]::span_encoding::Span>::{closure#0}, ()>
  15:        0x11aa1e141 - rustc_middle[db449b3460385d6f]::util::bug::opt_span_bug_fmt::<rustc_span[3733f809f3ebe388]::span_encoding::Span>
  16:        0x11b097f61 - rustc_middle[db449b3460385d6f]::util::bug::bug_fmt
  17:        0x11a941b49 - <rustc_middle[db449b3460385d6f]::ty::visit::ValidateBoundVars as rustc_middle[db449b3460385d6f]::ty::visit::TypeVisitor>::visit_region
  18:        0x118668e00 - <rustc_middle[db449b3460385d6f]::ty::sty::Binder<rustc_middle[db449b3460385d6f]::ty::sty::Region>>::bind_with_vars
  19:        0x1185e33bf - <dyn rustc_hir_analysis[50d2e10c526ac435]::astconv::AstConv>::add_bounds::<core[95bb6d661b676f4d]::slice::iter::Iter<rustc_hir[2c9fd968c67d70e3]::hir::GenericBound>>
  20:        0x1186cda4e - <dyn rustc_hir_analysis[50d2e10c526ac435]::astconv::AstConv>::compute_bounds_inner
  21:        0x1184efd1d - rustc_hir_analysis[50d2e10c526ac435]::collect::item_bounds::explicit_item_bounds
  22:        0x1196a6306 - rustc_query_system[e535d6d94a1ab2a4]::query::plumbing::try_execute_query::<rustc_query_impl[c1f689d635a76408]::plumbing::QueryCtxt, rustc_query_system[e535d6d94a1ab2a4]::query::caches::DefaultCache<rustc_span[3733f809f3ebe388]::def_id::DefId, &[(rustc_middle[db449b3460385d6f]::ty::Predicate, rustc_span[3733f809f3ebe388]::span_encoding::Span)]>>
  23:        0x1197952e9 - rustc_query_system[e535d6d94a1ab2a4]::query::plumbing::get_query::<rustc_query_impl[c1f689d635a76408]::queries::explicit_item_bounds, rustc_query_impl[c1f689d635a76408]::plumbing::QueryCtxt>
  24:        0x1199245d7 - <rustc_query_impl[c1f689d635a76408]::Queries as rustc_middle[db449b3460385d6f]::ty::query::QueryEngine>::explicit_item_bounds
  25:        0x11869b285 - rustc_hir_analysis[50d2e10c526ac435]::collect::convert_item
  26:        0x11869790c - <rustc_hir_analysis[50d2e10c526ac435]::collect::CollectItemTypesVisitor as rustc_hir[2c9fd968c67d70e3]::intravisit::Visitor>::visit_item
  27:        0x11857e855 - <rustc_middle[db449b3460385d6f]::hir::map::Map>::visit_item_likes_in_module::<rustc_hir_analysis[50d2e10c526ac435]::collect::CollectItemTypesVisitor>
  28:        0x118696c15 - rustc_hir_analysis[50d2e10c526ac435]::collect::collect_mod_item_types
  29:        0x1196e107b - rustc_query_system[e535d6d94a1ab2a4]::query::plumbing::try_execute_query::<rustc_query_impl[c1f689d635a76408]::plumbing::QueryCtxt, rustc_query_system[e535d6d94a1ab2a4]::query::caches::VecCache<rustc_span[3733f809f3ebe388]::def_id::LocalDefId, ()>>
  30:        0x11979cc03 - rustc_query_system[e535d6d94a1ab2a4]::query::plumbing::get_query::<rustc_query_impl[c1f689d635a76408]::queries::collect_mod_item_types, rustc_query_impl[c1f689d635a76408]::plumbing::QueryCtxt>
  31:        0x119945ebf - <rustc_query_impl[c1f689d635a76408]::Queries as rustc_middle[db449b3460385d6f]::ty::query::QueryEngine>::collect_mod_item_types
  32:        0x11857e153 - <rustc_middle[db449b3460385d6f]::hir::map::Map>::for_each_module::<rustc_hir_analysis[50d2e10c526ac435]::check_crate::{closure#0}::{closure#0}::{closure#0}>
  33:        0x11867a71b - <rustc_session[eed39e6e03b50785]::session::Session>::track_errors::<rustc_hir_analysis[50d2e10c526ac435]::check_crate::{closure#0}, ()>
  34:        0x1185b4a8c - rustc_hir_analysis[50d2e10c526ac435]::check_crate
  35:        0x115b70faa - rustc_interface[9ed52e10726157d]::passes::analysis
  36:        0x1196acd8f - rustc_query_system[e535d6d94a1ab2a4]::query::plumbing::try_execute_query::<rustc_query_impl[c1f689d635a76408]::plumbing::QueryCtxt, rustc_query_system[e535d6d94a1ab2a4]::query::caches::DefaultCache<(), core[95bb6d661b676f4d]::result::Result<(), rustc_errors[9121627fb7cf2262]::ErrorGuaranteed>>>
  37:        0x1197cf0f9 - rustc_query_system[e535d6d94a1ab2a4]::query::plumbing::get_query::<rustc_query_impl[c1f689d635a76408]::queries::analysis, rustc_query_impl[c1f689d635a76408]::plumbing::QueryCtxt>
  38:        0x119922ba7 - <rustc_query_impl[c1f689d635a76408]::Queries as rustc_middle[db449b3460385d6f]::ty::query::QueryEngine>::analysis
  39:        0x115a25aab - <rustc_interface[9ed52e10726157d]::passes::QueryContext>::enter::<rustc_driver[b73731b7ed8e79fd]::run_compiler::{closure#1}::{closure#2}::{closure#2}, core[95bb6d661b676f4d]::result::Result<(), rustc_errors[9121627fb7cf2262]::ErrorGuaranteed>>
  40:        0x11598cba5 - <rustc_interface[9ed52e10726157d]::interface::Compiler>::enter::<rustc_driver[b73731b7ed8e79fd]::run_compiler::{closure#1}::{closure#2}, core[95bb6d661b676f4d]::result::Result<core[95bb6d661b676f4d]::option::Option<rustc_interface[9ed52e10726157d]::queries::Linker>, rustc_errors[9121627fb7cf2262]::ErrorGuaranteed>>
  41:        0x115a200cb - rustc_span[3733f809f3ebe388]::with_source_map::<core[95bb6d661b676f4d]::result::Result<(), rustc_errors[9121627fb7cf2262]::ErrorGuaranteed>, rustc_interface[9ed52e10726157d]::interface::run_compiler<core[95bb6d661b676f4d]::result::Result<(), rustc_errors[9121627fb7cf2262]::ErrorGuaranteed>, rustc_driver[b73731b7ed8e79fd]::run_compiler::{closure#1}>::{closure#0}::{closure#0}>
  42:        0x11598849a - <scoped_tls[c451c38e2ed76225]::ScopedKey<rustc_span[3733f809f3ebe388]::SessionGlobals>>::set::<rustc_interface[9ed52e10726157d]::interface::run_compiler<core[95bb6d661b676f4d]::result::Result<(), rustc_errors[9121627fb7cf2262]::ErrorGuaranteed>, rustc_driver[b73731b7ed8e79fd]::run_compiler::{closure#1}>::{closure#0}, core[95bb6d661b676f4d]::result::Result<(), rustc_errors[9121627fb7cf2262]::ErrorGuaranteed>>
  43:        0x1159ee870 - std[e4564114326e8c6]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[9ed52e10726157d]::util::run_in_thread_pool_with_globals<rustc_interface[9ed52e10726157d]::interface::run_compiler<core[95bb6d661b676f4d]::result::Result<(), rustc_errors[9121627fb7cf2262]::ErrorGuaranteed>, rustc_driver[b73731b7ed8e79fd]::run_compiler::{closure#1}>::{closure#0}, core[95bb6d661b676f4d]::result::Result<(), rustc_errors[9121627fb7cf2262]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[95bb6d661b676f4d]::result::Result<(), rustc_errors[9121627fb7cf2262]::ErrorGuaranteed>>
  44:        0x115a30900 - std[e4564114326e8c6]::panicking::try::<core[95bb6d661b676f4d]::result::Result<(), rustc_errors[9121627fb7cf2262]::ErrorGuaranteed>, core[95bb6d661b676f4d]::panic::unwind_safe::AssertUnwindSafe<<std[e4564114326e8c6]::thread::Builder>::spawn_unchecked_<rustc_interface[9ed52e10726157d]::util::run_in_thread_pool_with_globals<rustc_interface[9ed52e10726157d]::interface::run_compiler<core[95bb6d661b676f4d]::result::Result<(), rustc_errors[9121627fb7cf2262]::ErrorGuaranteed>, rustc_driver[b73731b7ed8e79fd]::run_compiler::{closure#1}>::{closure#0}, core[95bb6d661b676f4d]::result::Result<(), rustc_errors[9121627fb7cf2262]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[95bb6d661b676f4d]::result::Result<(), rustc_errors[9121627fb7cf2262]::ErrorGuaranteed>>::{closure#1}::{closure#0}>>
  45:        0x1159901e1 - <<std[e4564114326e8c6]::thread::Builder>::spawn_unchecked_<rustc_interface[9ed52e10726157d]::util::run_in_thread_pool_with_globals<rustc_interface[9ed52e10726157d]::interface::run_compiler<core[95bb6d661b676f4d]::result::Result<(), rustc_errors[9121627fb7cf2262]::ErrorGuaranteed>, rustc_driver[b73731b7ed8e79fd]::run_compiler::{closure#1}>::{closure#0}, core[95bb6d661b676f4d]::result::Result<(), rustc_errors[9121627fb7cf2262]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[95bb6d661b676f4d]::result::Result<(), rustc_errors[9121627fb7cf2262]::ErrorGuaranteed>>::{closure#1} as core[95bb6d661b676f4d]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  46:        0x10646fb5b - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hd10a5c38d6c64916
  47:        0x10645a19f - std::sys::unix::thread::Thread::new::thread_start::he793914283faf21a
  48:     0x7ff807a764e1 - __pthread_start

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.67.0-dev running on x86_64-apple-darwin

query stack during panic:
#0 [explicit_item_bounds] finding item bounds for `f::{opaque#0}`
#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 previous error

Version

stage1 built from 8681d4c with debug assertions

config.toml
# Includes one of the default files in src/bootstrap/defaults
profile = "compiler"
changelog-seen = 2

[llvm]
download-ci-llvm = true     # Download a pre-built LLVM?
assertions = true           # LLVM assertions on?

[rust]
incremental = true          # Build rustc with incremental compilation?
debug-assertions = true
overflow-checks = true

@rustbot label +F-associated_type_bounds +requires-debug-assertions

@jruderman jruderman 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 Nov 25, 2022
@rustbot
Copy link
Collaborator

rustbot commented Nov 25, 2022

Error: Label requires-debug-assertions can only be set by Rust team members

Please file an issue on GitHub at triagebot if there's a problem with this bot, or reach out on #t-infra on Zulip.

@compiler-errors compiler-errors added the requires-debug-assertions This issue requires a build of rustc or tooling with debug-assertions in some way label Nov 26, 2022
compiler-errors added a commit to compiler-errors/rust that referenced this issue Nov 26, 2022
jruderman tried to add this in rust-lang#104916, for example. I think I've seen this happen before as well.
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Nov 27, 2022
…ertions, r=Mark-Simulacrum

Allow non-org members to label `requires-debug-assertions`

`jruderman` tried to add this in rust-lang#104916, for example. I think I've seen this happen before as well.
@jruderman
Copy link
Contributor Author

@rustbot label +F-associated_type_bounds

@rustbot rustbot added the F-associated_type_bounds `#![feature(associated_type_bounds)]` label Nov 29, 2022
@matthiaskrgr
Copy link
Member

It seems this no longer crashes when checking with debug assertions :)

@matthiaskrgr matthiaskrgr added the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label Mar 16, 2023
JohnTitor added a commit to JohnTitor/rust that referenced this issue Apr 10, 2023
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this issue Apr 10, 2023
…-errors

Add regression test for rust-lang#104916

Closes rust-lang#104916
I haven't tested if it still passes with debug assertions enabled so it'd be better to wait for CI to be green.
r? compiler-errors
JohnTitor added a commit to JohnTitor/rust that referenced this issue Apr 11, 2023
…-errors

Add regression test for rust-lang#104916

Closes rust-lang#104916
I haven't tested if it still passes with debug assertions enabled so it'd be better to wait for CI to be green.
r? compiler-errors
bors added a commit to rust-lang-ci/rust that referenced this issue Apr 11, 2023
Rollup of 8 pull requests

Successful merges:

 - rust-lang#109527 (Set up standard library path substitution in rust-gdb and gdbgui)
 - rust-lang#109752 (Stall auto trait assembly in new solver for int/float vars)
 - rust-lang#109860 (Add support for RISC-V relax target feature)
 - rust-lang#109923 (Update `error [E0449]: unnecessary visibility qualifier` to be more clear)
 - rust-lang#110070 (The `wrapping_neg` example for unsigned types shouldn't use `i8`)
 - rust-lang#110146 (fix(doc): do not parse inline when output is json for external crate)
 - rust-lang#110147 (Add regression test for rust-lang#104916)
 - rust-lang#110149 (Update books)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors closed this as completed in 016ebf8 Apr 11, 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. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. F-associated_type_bounds `#![feature(associated_type_bounds)]` I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ requires-debug-assertions This issue requires a build of rustc or tooling with debug-assertions 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.

4 participants