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 "Overflow should be caught earlier in standard query mode" building specialization graph with infinite-size structs #105231

Closed
jruderman opened this issue Dec 3, 2022 · 0 comments · Fixed by #112163
Labels
C-bug Category: This is a bug. 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

@jruderman
Copy link
Contributor

Found with a modified fuzz-rustc

Code

struct A<T>(B<T>);
struct B<T>(A<A<T>>);
trait Foo {}
impl<T> Foo for T where T: Send {}
impl Foo for B<u8> {}
fn main() {}

Error output

error[E0072]: recursive types A and B have infinite size

thread 'rustc' panicked at 'Overflow should be caught earlier in standard query mode: Error(ErrorGuaranteed(()))', compiler/rustc_trait_selection/src/traits/select/mod.rs:531

Full output including backtrace
error[E0072]: recursive types `A` and `B` have infinite size
 --> ../auu.rs:1:1
  |
1 | pub struct A<T>(B<T>);
  | ^^^^^^^^^^^^^^^ ---- recursive without indirection
2 | pub struct B<T>(A<A<T>>);
  | ^^^^^^^^^^^^^^^ ------- recursive without indirection
  |
help: insert some indirection (e.g., a `Box`, `Rc`, or `&`) to break the cycle
  |
1 ~ pub struct A<T>(Box<B<T>>);
2 ~ pub struct B<T>(Box<A<A<T>>>);
  |

thread 'rustc' panicked at 'Overflow should be caught earlier in standard query mode: Error(ErrorGuaranteed(()))', compiler/rustc_trait_selection/src/traits/select/mod.rs:531:14
stack backtrace:
   0:        0x107f4a406 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h7aeb894505898234
   1:        0x107fa8dca - core::fmt::write::hb0aa72ff55d6ae53
   2:        0x107f3c7ac - std::io::Write::write_fmt::h1945469b78b865f8
   3:        0x107f4a1ea - std::sys_common::backtrace::print::h85c2438dfd145403
   4:        0x107f4d553 - std::panicking::default_hook::{{closure}}::hdd077715d2b82795
   5:        0x107f4d2a8 - std::panicking::default_hook::he8d3e4e56f8c52ec
   6:        0x112a7302d - rustc_driver[2d5e2c84e80eab0e]::DEFAULT_HOOK::{closure#0}::{closure#0}
   7:        0x107f4dd37 - std::panicking::rust_panic_with_hook::h48c87533cff0c7b5
   8:        0x107f4dae4 - std::panicking::begin_panic_handler::{{closure}}::h03e0170622ddc3a5
   9:        0x107f4a8a8 - std::sys_common::backtrace::__rust_end_short_backtrace::h27a5e4055100ab18
  10:        0x107f4d7ad - _rust_begin_unwind
  11:        0x107fd52a3 - core::panicking::panic_fmt::hd88a77e190c81c5c
  12:        0x107fd5725 - core::result::unwrap_failed::h34df02e39265a387
  13:        0x116fe5991 - <&mut core[430c2907dc9a6903]::iter::adapters::map::map_try_fold<rustc_middle[209729e445530cc9]::ty::Predicate, rustc_middle[209729e445530cc9]::ty::Predicate, (), core[430c2907dc9a6903]::ops::control_flow::ControlFlow<rustc_infer[db474c8c0e0cf674]::traits::Obligation<rustc_middle[209729e445530cc9]::ty::Predicate>>, rustc_trait_selection[d46787f576d816bf]::traits::coherence::implicit_negative::{closure#0}, core[430c2907dc9a6903]::iter::adapters::map::map_try_fold<rustc_middle[209729e445530cc9]::ty::Predicate, rustc_infer[db474c8c0e0cf674]::traits::Obligation<rustc_middle[209729e445530cc9]::ty::Predicate>, (), core[430c2907dc9a6903]::ops::control_flow::ControlFlow<rustc_infer[db474c8c0e0cf674]::traits::Obligation<rustc_middle[209729e445530cc9]::ty::Predicate>>, rustc_trait_selection[d46787f576d816bf]::traits::coherence::implicit_negative::{closure#1}, core[430c2907dc9a6903]::iter::traits::iterator::Iterator::find::check<rustc_infer[db474c8c0e0cf674]::traits::Obligation<rustc_middle[209729e445530cc9]::ty::Predicate>, &mut rustc_trait_selection[d46787f576d816bf]::traits::coherence::implicit_negative::{closure#2}>::{closure#0}>::{closure#0}>::{closure#0} as core[430c2907dc9a6903]::ops::function::FnMut<((), rustc_middle[209729e445530cc9]::ty::Predicate)>>::call_mut
  14:        0x116fd6719 - <core[430c2907dc9a6903]::iter::adapters::map::Map<core[430c2907dc9a6903]::iter::adapters::map::Map<core[430c2907dc9a6903]::iter::adapters::chain::Chain<core[430c2907dc9a6903]::iter::adapters::copied::Copied<core[430c2907dc9a6903]::slice::iter::Iter<rustc_middle[209729e445530cc9]::ty::Predicate>>, alloc[567819b9645b4323]::vec::into_iter::IntoIter<rustc_middle[209729e445530cc9]::ty::Predicate>>, rustc_trait_selection[d46787f576d816bf]::traits::coherence::implicit_negative::{closure#0}>, rustc_trait_selection[d46787f576d816bf]::traits::coherence::implicit_negative::{closure#1}> as core[430c2907dc9a6903]::iter::traits::iterator::Iterator>::try_fold::<(), core[430c2907dc9a6903]::iter::traits::iterator::Iterator::find::check<rustc_infer[db474c8c0e0cf674]::traits::Obligation<rustc_middle[209729e445530cc9]::ty::Predicate>, &mut rustc_trait_selection[d46787f576d816bf]::traits::coherence::implicit_negative::{closure#2}>::{closure#0}, core[430c2907dc9a6903]::ops::control_flow::ControlFlow<rustc_infer[db474c8c0e0cf674]::traits::Obligation<rustc_middle[209729e445530cc9]::ty::Predicate>>>
  15:        0x116f9a428 - rustc_trait_selection[d46787f576d816bf]::traits::coherence::overlap_within_probe
  16:        0x116fcd588 - <rustc_infer[db474c8c0e0cf674]::infer::InferCtxt>::probe_maybe_skip_leak_check::<core[430c2907dc9a6903]::option::Option<rustc_trait_selection[d46787f576d816bf]::traits::coherence::OverlapResult>, rustc_trait_selection[d46787f576d816bf]::traits::coherence::overlap::{closure#0}>
  17:        0x116f9d7ec - rustc_trait_selection[d46787f576d816bf]::traits::coherence::overlapping_impls
  18:        0x116fed76a - <rustc_middle[209729e445530cc9]::traits::specialization_graph::Children as rustc_trait_selection[d46787f576d816bf]::traits::specialize::specialization_graph::ChildrenExt>::insert
  19:        0x116fee4c9 - <rustc_middle[209729e445530cc9]::traits::specialization_graph::Graph as rustc_trait_selection[d46787f576d816bf]::traits::specialize::specialization_graph::GraphExt>::insert
  20:        0x117067cae - rustc_trait_selection[d46787f576d816bf]::traits::specialize::specialization_graph_provider
  21:        0x1161ff17e - rustc_query_system[c11f59037b5cfd63]::query::plumbing::try_execute_query::<rustc_query_impl[45e9db0b3ea45acb]::plumbing::QueryCtxt, rustc_query_system[c11f59037b5cfd63]::query::caches::ArenaCache<rustc_span[157adb1f3d5a28e2]::def_id::DefId, rustc_middle[209729e445530cc9]::traits::specialization_graph::Graph>>
  22:        0x11639e7c8 - rustc_query_system[c11f59037b5cfd63]::query::plumbing::get_query::<rustc_query_impl[45e9db0b3ea45acb]::queries::specialization_graph_of, rustc_query_impl[45e9db0b3ea45acb]::plumbing::QueryCtxt>
  23:        0x11551673a - rustc_hir_analysis[eec43b6a4b80b88b]::coherence::coherent_trait
  24:        0x1162a29b5 - rustc_query_system[c11f59037b5cfd63]::query::plumbing::try_execute_query::<rustc_query_impl[45e9db0b3ea45acb]::plumbing::QueryCtxt, rustc_query_system[c11f59037b5cfd63]::query::caches::DefaultCache<rustc_span[157adb1f3d5a28e2]::def_id::DefId, ()>>
  25:        0x11638fd85 - rustc_query_system[c11f59037b5cfd63]::query::plumbing::get_query::<rustc_query_impl[45e9db0b3ea45acb]::queries::coherent_trait, rustc_query_impl[45e9db0b3ea45acb]::plumbing::QueryCtxt>
  26:        0x11548babe - <rustc_session[b3c342af35a3ea6a]::session::Session>::track_errors::<rustc_hir_analysis[eec43b6a4b80b88b]::check_crate::{closure#3}, ()>
  27:        0x115595e63 - rustc_hir_analysis[eec43b6a4b80b88b]::check_crate
  28:        0x112b1c23a - rustc_interface[f59f2966aecfe0a5]::passes::analysis
  29:        0x1162d9544 - rustc_query_system[c11f59037b5cfd63]::query::plumbing::try_execute_query::<rustc_query_impl[45e9db0b3ea45acb]::plumbing::QueryCtxt, rustc_query_system[c11f59037b5cfd63]::query::caches::DefaultCache<(), core[430c2907dc9a6903]::result::Result<(), rustc_errors[17a2ca97c979a6e5]::ErrorGuaranteed>>>
  30:        0x1163a3c41 - rustc_query_system[c11f59037b5cfd63]::query::plumbing::get_query::<rustc_query_impl[45e9db0b3ea45acb]::queries::analysis, rustc_query_impl[45e9db0b3ea45acb]::plumbing::QueryCtxt>
  31:        0x112a04f47 - <rustc_interface[f59f2966aecfe0a5]::passes::QueryContext>::enter::<rustc_driver[2d5e2c84e80eab0e]::run_compiler::{closure#1}::{closure#2}::{closure#2}, core[430c2907dc9a6903]::result::Result<(), rustc_errors[17a2ca97c979a6e5]::ErrorGuaranteed>>
  32:        0x112a4b4e5 - <rustc_interface[f59f2966aecfe0a5]::interface::Compiler>::enter::<rustc_driver[2d5e2c84e80eab0e]::run_compiler::{closure#1}::{closure#2}, core[430c2907dc9a6903]::result::Result<core[430c2907dc9a6903]::option::Option<rustc_interface[f59f2966aecfe0a5]::queries::Linker>, rustc_errors[17a2ca97c979a6e5]::ErrorGuaranteed>>
  33:        0x1129e5a5d - rustc_span[157adb1f3d5a28e2]::with_source_map::<core[430c2907dc9a6903]::result::Result<(), rustc_errors[17a2ca97c979a6e5]::ErrorGuaranteed>, rustc_interface[f59f2966aecfe0a5]::interface::run_compiler<core[430c2907dc9a6903]::result::Result<(), rustc_errors[17a2ca97c979a6e5]::ErrorGuaranteed>, rustc_driver[2d5e2c84e80eab0e]::run_compiler::{closure#1}>::{closure#0}::{closure#0}>
  34:        0x112a3e40d - <scoped_tls[86ec2be37ea12d20]::ScopedKey<rustc_span[157adb1f3d5a28e2]::SessionGlobals>>::set::<rustc_interface[f59f2966aecfe0a5]::interface::run_compiler<core[430c2907dc9a6903]::result::Result<(), rustc_errors[17a2ca97c979a6e5]::ErrorGuaranteed>, rustc_driver[2d5e2c84e80eab0e]::run_compiler::{closure#1}>::{closure#0}, core[430c2907dc9a6903]::result::Result<(), rustc_errors[17a2ca97c979a6e5]::ErrorGuaranteed>>
  35:        0x112a0d86a - std[cffeb5472d7fcddb]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[f59f2966aecfe0a5]::util::run_in_thread_pool_with_globals<rustc_interface[f59f2966aecfe0a5]::interface::run_compiler<core[430c2907dc9a6903]::result::Result<(), rustc_errors[17a2ca97c979a6e5]::ErrorGuaranteed>, rustc_driver[2d5e2c84e80eab0e]::run_compiler::{closure#1}>::{closure#0}, core[430c2907dc9a6903]::result::Result<(), rustc_errors[17a2ca97c979a6e5]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[430c2907dc9a6903]::result::Result<(), rustc_errors[17a2ca97c979a6e5]::ErrorGuaranteed>>
  36:        0x1129ef795 - <<std[cffeb5472d7fcddb]::thread::Builder>::spawn_unchecked_<rustc_interface[f59f2966aecfe0a5]::util::run_in_thread_pool_with_globals<rustc_interface[f59f2966aecfe0a5]::interface::run_compiler<core[430c2907dc9a6903]::result::Result<(), rustc_errors[17a2ca97c979a6e5]::ErrorGuaranteed>, rustc_driver[2d5e2c84e80eab0e]::run_compiler::{closure#1}>::{closure#0}, core[430c2907dc9a6903]::result::Result<(), rustc_errors[17a2ca97c979a6e5]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[430c2907dc9a6903]::result::Result<(), rustc_errors[17a2ca97c979a6e5]::ErrorGuaranteed>>::{closure#1} as core[430c2907dc9a6903]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  37:        0x107f57007 - std::sys::unix::thread::Thread::new::thread_start::hd82b4d9ec5e0369f
  38:     0x7ff8083354e1 - __pthread_start

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.67.0-nightly (32e613bba 2022-12-02) running on x86_64-apple-darwin

query stack during panic:
#0 [specialization_graph_of] building specialization graph of trait `Foo`
#1 [coherent_trait] coherence checking all impls of trait `Foo`
#2 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to previous error

Regression

Regression in nightly-2022-10-13, somewhere in rollup e6ce562, maybe #102890 (@camsteffen)

Version

rustc 1.67.0-nightly (32e613bba 2022-12-02)
binary: rustc
commit-hash: 32e613bbaafee1bcabba48a2257b838f8d1c03d3
commit-date: 2022-12-02
host: x86_64-apple-darwin
release: 1.67.0-nightly
LLVM version: 15.0.4
@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 Dec 3, 2022
@rust-lang-glacier-bot rust-lang-glacier-bot added the glacier ICE tracked in rust-lang/glacier. label Dec 20, 2022
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this issue Jun 16, 2023
…rrors

fix: inline `predicate_may_hold_fatal` and remove expect call in it

- Fixes rust-lang#105231
- Discussion: rust-lang#111985 (comment)

r? `@compiler-errors`
@bors bors closed this as completed in c563296 Jun 16, 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. 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
2 participants