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

Debug assertion failure with generator that yields mismatched tuples #105728

Closed
jruderman opened this issue Dec 15, 2022 · 0 comments · Fixed by #105837
Closed

Debug assertion failure with generator that yields mismatched tuples #105728

jruderman opened this issue Dec 15, 2022 · 0 comments · Fixed by #105837
Assignees
Labels
C-bug Category: This is a bug. F-coroutines `#![feature(coroutines)]` I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ requires-debug-assertions This issue requires 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 by modifying src/test/ui/typeck/issue-91334.rs with my fork of fuzz-rustc

Code

#![feature(generators)]

fn main() {
    let _generator = || {
        yield ((), ((), ()));
        yield ((), ());
    };
}

Debug assertion failure

thread 'rustc' panicked at 'assertion failed: (left == right)
left: 0,
right: 2', compiler/rustc_hir_typeck/src/generator_interior/mod.rs:611

Where line 611 in rustc_hir_typeck::generator_interior::check_must_not_suspend_ty is:

debug_assert_eq!(comps.len(), fields.len());
Full output with backtrace
error[E0308]: mismatched types
 --> ajj.rs:6:20
  |
6 |         yield ((), ());
  |                    ^^ expected tuple, found `()`
  |
  = note:  expected tuple `((), ())`
          found unit type `()`

thread 'rustc' panicked at 'assertion failed: `(left == right)`
  left: `0`,
 right: `2`', compiler/rustc_hir_typeck/src/generator_interior/mod.rs:611:21
stack backtrace:
   0:        0x1071f9731 - ___fixunssfsi
   1:        0x107284b08 - core::fmt::write::hed31846cddb4e13c
   2:        0x1071d0b28 - std::io::Write::write_fmt::hf6e0f2914bebea98
   3:        0x1071f9522 - std::sys_common::backtrace::print::h905a3d11750ea1e9
   4:        0x107209d35 - std::panicking::default_hook::{{closure}}::he83c590da184b003
   5:        0x107209b1e - std::panicking::default_hook::hd8c8acc029e0c8cd
   6:        0x116dd5ae8 - rustc_driver[75b940a0d44b1efd]::DEFAULT_HOOK::{closure#0}::{closure#0}
   7:        0x10720a526 - std::panicking::rust_panic_with_hook::h0cf82b3605a8081f
   8:        0x1071f8a93 - std::panicking::begin_panic_handler::{{closure}}::h7d24d0bcbcd0c8c3
   9:        0x1071f89c8 - std::sys_common::backtrace::__rust_end_short_backtrace::h584365ffa1be1317
  10:        0x107209e08 - _rust_begin_unwind
  11:        0x1072a9483 - core::panicking::panic_fmt::h7ec57a9a63e6db71
  12:        0x1072a96ba - core::panicking::assert_failed_inner::hb961e0acdeb20af8
  13:        0x11c3641ce - core[95bb6d661b676f4d]::panicking::assert_failed::<usize, usize>
  14:        0x1198af2ab - rustc_hir_typeck[b7aa618f0b708977]::generator_interior::check_must_not_suspend_ty
  15:        0x1198aea22 - rustc_hir_typeck[b7aa618f0b708977]::generator_interior::check_must_not_suspend_ty
  16:        0x1198aaffa - <rustc_hir_typeck[b7aa618f0b708977]::generator_interior::InteriorVisitor>::record
  17:        0x1198ad4b5 - <rustc_hir_typeck[b7aa618f0b708977]::generator_interior::InteriorVisitor as rustc_hir[996085a55c0aa981]::intravisit::Visitor>::visit_expr
  18:        0x1198ad0b9 - <rustc_hir_typeck[b7aa618f0b708977]::generator_interior::InteriorVisitor as rustc_hir[996085a55c0aa981]::intravisit::Visitor>::visit_expr
  19:        0x119731e82 - rustc_hir[996085a55c0aa981]::intravisit::walk_block::<rustc_hir_typeck[b7aa618f0b708977]::generator_interior::InteriorVisitor>
  20:        0x11973be59 - rustc_hir[996085a55c0aa981]::intravisit::walk_expr::<rustc_hir_typeck[b7aa618f0b708977]::generator_interior::InteriorVisitor>
  21:        0x1198ad0b9 - <rustc_hir_typeck[b7aa618f0b708977]::generator_interior::InteriorVisitor as rustc_hir[996085a55c0aa981]::intravisit::Visitor>::visit_expr
  22:        0x1198ab9e5 - rustc_hir_typeck[b7aa618f0b708977]::generator_interior::resolve_interior
  23:        0x1197a6284 - <rustc_hir_typeck[b7aa618f0b708977]::fn_ctxt::FnCtxt>::resolve_generator_interiors
  24:        0x1196996d0 - <rustc_hir_typeck[b7aa618f0b708977]::inherited::InheritedBuilder>::enter::<rustc_hir_typeck[b7aa618f0b708977]::typeck_with_fallback<rustc_hir_typeck[b7aa618f0b708977]::typeck::{closure#0}>::{closure#0}::{closure#1}, &rustc_middle[2716ddfd79b0a8a6]::ty::context::TypeckResults>
  25:        0x11974cef5 - rustc_hir_typeck[b7aa618f0b708977]::typeck_with_fallback::<rustc_hir_typeck[b7aa618f0b708977]::typeck::{closure#0}>
  26:        0x11977e46f - rustc_hir_typeck[b7aa618f0b708977]::typeck
  27:        0x11ae8bd6b - rustc_query_system[47b5c57ee62d79cf]::query::plumbing::try_execute_query::<rustc_query_impl[6353a2785d754f42]::plumbing::QueryCtxt, rustc_query_system[47b5c57ee62d79cf]::query::caches::VecCache<rustc_span[c887fc7c2a0a81b]::def_id::LocalDefId, &rustc_middle[2716ddfd79b0a8a6]::ty::context::TypeckResults>>
  28:        0x11af8a62e - rustc_query_system[47b5c57ee62d79cf]::query::plumbing::get_query::<rustc_query_impl[6353a2785d754f42]::queries::typeck, rustc_query_impl[6353a2785d754f42]::plumbing::QueryCtxt>
  29:        0x11ac1003f - <rustc_query_impl[6353a2785d754f42]::Queries as rustc_middle[2716ddfd79b0a8a6]::ty::query::QueryEngine>::typeck
  30:        0x119758b13 - <core[95bb6d661b676f4d]::panic::unwind_safe::AssertUnwindSafe<rustc_data_structures[49afb3d772895c69]::sync::par_for_each_in<&[rustc_span[c887fc7c2a0a81b]::def_id::LocalDefId], <rustc_middle[2716ddfd79b0a8a6]::hir::map::Map>::par_body_owners<rustc_hir_typeck[b7aa618f0b708977]::typeck_item_bodies::{closure#0}>::{closure#0}>::{closure#0}::{closure#0}> as core[95bb6d661b676f4d]::ops::function::FnOnce<()>>::call_once
  31:        0x11977cad0 - std[150eb488e385df0f]::panicking::try::<(), core[95bb6d661b676f4d]::panic::unwind_safe::AssertUnwindSafe<rustc_data_structures[49afb3d772895c69]::sync::par_for_each_in<&[rustc_span[c887fc7c2a0a81b]::def_id::LocalDefId], <rustc_middle[2716ddfd79b0a8a6]::hir::map::Map>::par_body_owners<rustc_hir_typeck[b7aa618f0b708977]::typeck_item_bodies::{closure#0}>::{closure#0}>::{closure#0}::{closure#0}>>
  32:        0x119854153 - rustc_data_structures[49afb3d772895c69]::sync::par_for_each_in::<&[rustc_span[c887fc7c2a0a81b]::def_id::LocalDefId], <rustc_middle[2716ddfd79b0a8a6]::hir::map::Map>::par_body_owners<rustc_hir_typeck[b7aa618f0b708977]::typeck_item_bodies::{closure#0}>::{closure#0}>
  33:        0x11977e22a - rustc_hir_typeck[b7aa618f0b708977]::typeck_item_bodies
  34:        0x11ae6a427 - rustc_query_system[47b5c57ee62d79cf]::query::plumbing::try_execute_query::<rustc_query_impl[6353a2785d754f42]::plumbing::QueryCtxt, rustc_query_system[47b5c57ee62d79cf]::query::caches::DefaultCache<(), ()>>
  35:        0x11af4345d - rustc_query_system[47b5c57ee62d79cf]::query::plumbing::get_query::<rustc_query_impl[6353a2785d754f42]::queries::typeck_item_bodies, rustc_query_impl[6353a2785d754f42]::plumbing::QueryCtxt>
  36:        0x11ac0f9d7 - <rustc_query_impl[6353a2785d754f42]::Queries as rustc_middle[2716ddfd79b0a8a6]::ty::query::QueryEngine>::typeck_item_bodies
  37:        0x1199fb245 - <rustc_session[9e89c47467305ea5]::session::Session>::time::<(), rustc_hir_analysis[39115411e53478da]::check_crate::{closure#7}>
  38:        0x1199db7ee - rustc_hir_analysis[39115411e53478da]::check_crate
  39:        0x116f743ea - rustc_interface[3c94b850180ed4ea]::passes::analysis
  40:        0x11ae5a658 - rustc_query_system[47b5c57ee62d79cf]::query::plumbing::try_execute_query::<rustc_query_impl[6353a2785d754f42]::plumbing::QueryCtxt, rustc_query_system[47b5c57ee62d79cf]::query::caches::DefaultCache<(), core[95bb6d661b676f4d]::result::Result<(), rustc_errors[dcd2348bee1b0385]::ErrorGuaranteed>>>
  41:        0x11af8a9dd - rustc_query_system[47b5c57ee62d79cf]::query::plumbing::get_query::<rustc_query_impl[6353a2785d754f42]::queries::analysis, rustc_query_impl[6353a2785d754f42]::plumbing::QueryCtxt>
  42:        0x11abec127 - <rustc_query_impl[6353a2785d754f42]::Queries as rustc_middle[2716ddfd79b0a8a6]::ty::query::QueryEngine>::analysis
  43:        0x116de4ff4 - <rustc_interface[3c94b850180ed4ea]::passes::QueryContext>::enter::<rustc_driver[75b940a0d44b1efd]::run_compiler::{closure#1}::{closure#2}::{closure#2}, core[95bb6d661b676f4d]::result::Result<(), rustc_errors[dcd2348bee1b0385]::ErrorGuaranteed>>
  44:        0x116dc5b3d - <rustc_interface[3c94b850180ed4ea]::interface::Compiler>::enter::<rustc_driver[75b940a0d44b1efd]::run_compiler::{closure#1}::{closure#2}, core[95bb6d661b676f4d]::result::Result<core[95bb6d661b676f4d]::option::Option<rustc_interface[3c94b850180ed4ea]::queries::Linker>, rustc_errors[dcd2348bee1b0385]::ErrorGuaranteed>>
  45:        0x116dc3241 - rustc_span[c887fc7c2a0a81b]::with_source_map::<core[95bb6d661b676f4d]::result::Result<(), rustc_errors[dcd2348bee1b0385]::ErrorGuaranteed>, rustc_interface[3c94b850180ed4ea]::interface::run_compiler<core[95bb6d661b676f4d]::result::Result<(), rustc_errors[dcd2348bee1b0385]::ErrorGuaranteed>, rustc_driver[75b940a0d44b1efd]::run_compiler::{closure#1}>::{closure#0}::{closure#0}>
  46:        0x116e10f0a - <scoped_tls[c451c38e2ed76225]::ScopedKey<rustc_span[c887fc7c2a0a81b]::SessionGlobals>>::set::<rustc_interface[3c94b850180ed4ea]::interface::run_compiler<core[95bb6d661b676f4d]::result::Result<(), rustc_errors[dcd2348bee1b0385]::ErrorGuaranteed>, rustc_driver[75b940a0d44b1efd]::run_compiler::{closure#1}>::{closure#0}, core[95bb6d661b676f4d]::result::Result<(), rustc_errors[dcd2348bee1b0385]::ErrorGuaranteed>>
  47:        0x116de00a0 - std[150eb488e385df0f]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[3c94b850180ed4ea]::util::run_in_thread_pool_with_globals<rustc_interface[3c94b850180ed4ea]::interface::run_compiler<core[95bb6d661b676f4d]::result::Result<(), rustc_errors[dcd2348bee1b0385]::ErrorGuaranteed>, rustc_driver[75b940a0d44b1efd]::run_compiler::{closure#1}>::{closure#0}, core[95bb6d661b676f4d]::result::Result<(), rustc_errors[dcd2348bee1b0385]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[95bb6d661b676f4d]::result::Result<(), rustc_errors[dcd2348bee1b0385]::ErrorGuaranteed>>
  48:        0x116e03810 - std[150eb488e385df0f]::panicking::try::<core[95bb6d661b676f4d]::result::Result<(), rustc_errors[dcd2348bee1b0385]::ErrorGuaranteed>, core[95bb6d661b676f4d]::panic::unwind_safe::AssertUnwindSafe<<std[150eb488e385df0f]::thread::Builder>::spawn_unchecked_<rustc_interface[3c94b850180ed4ea]::util::run_in_thread_pool_with_globals<rustc_interface[3c94b850180ed4ea]::interface::run_compiler<core[95bb6d661b676f4d]::result::Result<(), rustc_errors[dcd2348bee1b0385]::ErrorGuaranteed>, rustc_driver[75b940a0d44b1efd]::run_compiler::{closure#1}>::{closure#0}, core[95bb6d661b676f4d]::result::Result<(), rustc_errors[dcd2348bee1b0385]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[95bb6d661b676f4d]::result::Result<(), rustc_errors[dcd2348bee1b0385]::ErrorGuaranteed>>::{closure#1}::{closure#0}>>
  49:        0x116e00071 - <<std[150eb488e385df0f]::thread::Builder>::spawn_unchecked_<rustc_interface[3c94b850180ed4ea]::util::run_in_thread_pool_with_globals<rustc_interface[3c94b850180ed4ea]::interface::run_compiler<core[95bb6d661b676f4d]::result::Result<(), rustc_errors[dcd2348bee1b0385]::ErrorGuaranteed>, rustc_driver[75b940a0d44b1efd]::run_compiler::{closure#1}>::{closure#0}, core[95bb6d661b676f4d]::result::Result<(), rustc_errors[dcd2348bee1b0385]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[95bb6d661b676f4d]::result::Result<(), rustc_errors[dcd2348bee1b0385]::ErrorGuaranteed>>::{closure#1} as core[95bb6d661b676f4d]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  50:        0x1071cd07b - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h363a7f79aa0064c8
  51:        0x10720489f - std::sys::unix::thread::Thread::new::thread_start::hee5a1e4745806fcc
  52:     0x7ff80c3874e1 - __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.68.0-dev running on x86_64-apple-darwin

query stack during panic:
#0 [typeck] type-checking `main`
#1 [typeck_item_bodies] type-checking all item bodies
#2 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to previous error

For more information about this error, try `rustc --explain E0308`.

Version

Built stage1 from fbf8b93 with debug assertions enabled

CC @FabianWolff, who fixed similar issue #91334

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

@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 15, 2022
@rustbot rustbot added F-coroutines `#![feature(coroutines)]` requires-debug-assertions This issue requires debug-assertions in some way labels Dec 15, 2022
@bors bors closed this as completed in 3eccc29 Dec 22, 2022
Aaron1011 pushed a commit to Aaron1011/rust that referenced this issue Jan 6, 2023
…tebank

Don't ICE in `check_must_not_suspend_ty` for mismatched tuple arity

These expressions are just used for their spans, so make it best-effort here.

Fixes rust-lang#105728
@compiler-errors compiler-errors self-assigned this Mar 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. F-coroutines `#![feature(coroutines)]` I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ requires-debug-assertions This issue requires 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.

3 participants