Skip to content

ICE: itertools: .zip_eq() reached end of one iterator before the other #130372

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 Sep 14, 2024 · 7 comments · Fixed by #130437
Closed

ICE: itertools: .zip_eq() reached end of one iterator before the other #130372

matthiaskrgr opened this issue Sep 14, 2024 · 7 comments · Fixed by #130437
Assignees
Labels
C-bug Category: This is a bug. F-c_variadic `#![feature(c_variadic)]` F-fn_delegation `#![feature(fn_delegation)]` I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@matthiaskrgr
Copy link
Member

matthiaskrgr commented Sep 14, 2024

auto-reduced (treereduce-rust):

mod to_reuse {

    pub fn variadic_fn(n: usize, mut args: ...) {}
}

reuse to_reuse::variadic_fn;

reuse fn_header_aux::unsafe_fn_extern;
reuse fn_header_aux::extern_fn_extern;
reuse fn_header_aux::variadic_fn_extern;
reuse fn_header_aux::const_fn_extern;
reuse fn_header_aux::async_fn_extern;

fn main() {
    unsafe {
        variadic_fn();
    }
}
original code

original:

//@ check-pass
//@ edition:2018
//@ aux-crate:fn_header_aux=fn-header-aux.rs

#![feature(c_variadic)]
#![feature(fn_delegation)]
#![allow(incomplete_features)]
#![deny(unused_unsafe)]

mod to_reuse {
    pub unsafe fn unsafe_fn() {}
    pub extern "C" fn extern_fn() {}
    pub unsafe extern "C" fn variadic_fn(n: usize, mut args: ...) {}
    pub const fn const_fn() {}
    pub unsafe fn unsafe_fn() {}
}

reuse to_reuse::unsafe_fn;
reuse to_reuse::extern_fn;
reuse to_reuse::variadic_fn;
reuse to_reuse::const_fn;
reuse to_reuse::unsafe_fn;

reuse fn_header_aux::unsafe_fn_extern;
reuse fn_header_aux::extern_fn_extern;
reuse fn_header_aux::variadic_fn_extern;
reuse fn_header_aux::const_fn_extern;
reuse fn_header_aux::async_fn_extern;

const fn const_check() {
    const_fn();
    const_fn_extern();
}

async fn async_check() {
    async_fn().await;
    fn_header_aux::async_fn_extern;
}

fn main() {
    unsafe {
        unsafe_fn();
        unsafe_fn_extern();
    }
    extern_fn();
    extern_fn_extern();
    let _: extern "C" fn() = extern_fn;
    let _: extern "C" fn() = extern_fn_extern;
    unsafe {
        variadic_fn(0);
        variadic_fn();
        variadic_fn_extern(0);
        variadic_fn_extern(0, 1);
    }
    let _: unsafe extern "C" fn(usize, ...) = variadic_fn;
    let _: unsafe extern "C" fn(usize, ...) = variadic_fn_extern;
}

Version information

rustc 1.83.0-nightly (5e3ede22e 2024-09-14)
binary: rustc
commit-hash: 5e3ede22ef6fd23197629c22b9f466b3734e19f1
commit-date: 2024-09-14
host: x86_64-unknown-linux-gnu
release: 1.83.0-nightly
LLVM version: 19.1.0

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc

Program output

error: only foreign, `unsafe extern "C"`, or `unsafe extern "C-unwind"` functions may have a C-variadic arg
 --> /tmp/icemaker_global_tempdir.m40eJ3wCJOgX/rustc_testrunner_tmpdir_reporting.Esu9dG5LhXST/mvce.rs:3:34
  |
3 |     pub fn variadic_fn(n: usize, mut args: ...) {}
  |                                  ^^^^^^^^^^^^^

error[E0658]: functions delegation is not yet fully implemented
 --> /tmp/icemaker_global_tempdir.m40eJ3wCJOgX/rustc_testrunner_tmpdir_reporting.Esu9dG5LhXST/mvce.rs:6:1
  |
6 | reuse to_reuse::variadic_fn;
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: see issue #118212 <https://github.com/rust-lang/rust/issues/118212> for more information
  = help: add `#![feature(fn_delegation)]` to the crate attributes to enable
  = note: this compiler was built on 2024-09-14; consider upgrading it if it is out of date

error[E0658]: functions delegation is not yet fully implemented
 --> /tmp/icemaker_global_tempdir.m40eJ3wCJOgX/rustc_testrunner_tmpdir_reporting.Esu9dG5LhXST/mvce.rs:8:1
  |
8 | reuse fn_header_aux::unsafe_fn_extern;
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: see issue #118212 <https://github.com/rust-lang/rust/issues/118212> for more information
  = help: add `#![feature(fn_delegation)]` to the crate attributes to enable
  = note: this compiler was built on 2024-09-14; consider upgrading it if it is out of date

error[E0658]: functions delegation is not yet fully implemented
 --> /tmp/icemaker_global_tempdir.m40eJ3wCJOgX/rustc_testrunner_tmpdir_reporting.Esu9dG5LhXST/mvce.rs:9:1
  |
9 | reuse fn_header_aux::extern_fn_extern;
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: see issue #118212 <https://github.com/rust-lang/rust/issues/118212> for more information
  = help: add `#![feature(fn_delegation)]` to the crate attributes to enable
  = note: this compiler was built on 2024-09-14; consider upgrading it if it is out of date

error[E0658]: functions delegation is not yet fully implemented
  --> /tmp/icemaker_global_tempdir.m40eJ3wCJOgX/rustc_testrunner_tmpdir_reporting.Esu9dG5LhXST/mvce.rs:10:1
   |
10 | reuse fn_header_aux::variadic_fn_extern;
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: see issue #118212 <https://github.com/rust-lang/rust/issues/118212> for more information
   = help: add `#![feature(fn_delegation)]` to the crate attributes to enable
   = note: this compiler was built on 2024-09-14; consider upgrading it if it is out of date

error[E0658]: functions delegation is not yet fully implemented
  --> /tmp/icemaker_global_tempdir.m40eJ3wCJOgX/rustc_testrunner_tmpdir_reporting.Esu9dG5LhXST/mvce.rs:11:1
   |
11 | reuse fn_header_aux::const_fn_extern;
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: see issue #118212 <https://github.com/rust-lang/rust/issues/118212> for more information
   = help: add `#![feature(fn_delegation)]` to the crate attributes to enable
   = note: this compiler was built on 2024-09-14; consider upgrading it if it is out of date

error[E0658]: functions delegation is not yet fully implemented
  --> /tmp/icemaker_global_tempdir.m40eJ3wCJOgX/rustc_testrunner_tmpdir_reporting.Esu9dG5LhXST/mvce.rs:12:1
   |
12 | reuse fn_header_aux::async_fn_extern;
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: see issue #118212 <https://github.com/rust-lang/rust/issues/118212> for more information
   = help: add `#![feature(fn_delegation)]` to the crate attributes to enable
   = note: this compiler was built on 2024-09-14; consider upgrading it if it is out of date

error[E0658]: C-variadic functions are unstable
 --> /tmp/icemaker_global_tempdir.m40eJ3wCJOgX/rustc_testrunner_tmpdir_reporting.Esu9dG5LhXST/mvce.rs:3:5
  |
3 |     pub fn variadic_fn(n: usize, mut args: ...) {}
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: see issue #44930 <https://github.com/rust-lang/rust/issues/44930> for more information
  = help: add `#![feature(c_variadic)]` to the crate attributes to enable
  = note: this compiler was built on 2024-09-14; consider upgrading it if it is out of date

thread 'rustc' panicked at /rust/deps/itertools-0.12.1/src/zip_eq_impl.rs:50:17:
itertools: .zip_eq() reached end of one iterator before the other
stack backtrace:
   0:     0x7924c407927a - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h6120b7c64733b388
   1:     0x7924c4803257 - core::fmt::write::h04ec5344cbf9caeb
   2:     0x7924c5796233 - std::io::Write::write_fmt::h3c09d500ee92d83a
   3:     0x7924c40790d2 - std::sys::backtrace::BacktraceLock::print::h2fad0fa7205efa50
   4:     0x7924c407b851 - std::panicking::default_hook::{{closure}}::h4b479f759ddef1a6
   5:     0x7924c407b684 - std::panicking::default_hook::hdce79c09ea25303c
   6:     0x7924c317a70f - std[19c17663dd54327b]::panicking::update_hook::<alloc[5ed900dfc17f3cdd]::boxed::Box<rustc_driver_impl[1984b1857baa03d4]::install_ice_hook::{closure#0}>>::{closure#0}
   7:     0x7924c407bf78 - std::panicking::rust_panic_with_hook::ha97d2f186b78408e
   8:     0x7924c33ef36b - std[19c17663dd54327b]::panicking::begin_panic::<&str>::{closure#0}
   9:     0x7924c33a38a6 - std[19c17663dd54327b]::sys::backtrace::__rust_end_short_backtrace::<std[19c17663dd54327b]::panicking::begin_panic<&str>::{closure#0}, !>
  10:     0x7924c339a00f - std[19c17663dd54327b]::panicking::begin_panic::<&str>
  11:     0x7924c3418b39 - <itertools[ccdf881defd5b68f]::zip_eq_impl::ZipEq<alloc[5ed900dfc17f3cdd]::vec::into_iter::IntoIter<core[7a7dfcda68e5ea50]::option::Option<&rustc_hir[cd53a4d46407d6c]::hir::GenericParam>>, alloc[5ed900dfc17f3cdd]::vec::into_iter::IntoIter<&rustc_hir[cd53a4d46407d6c]::hir::Param>> as core[7a7dfcda68e5ea50]::iter::traits::iterator::Iterator>::next
  12:     0x7924c348e6ea - <rustc_hir_typeck[64ea15fc6d555141]::fn_ctxt::FnCtxt>::get_hir_params_with_generics
  13:     0x7924c348dc35 - <rustc_hir_typeck[64ea15fc6d555141]::fn_ctxt::FnCtxt>::label_generic_mismatches
  14:     0x7924c348531c - <rustc_hir_typeck[64ea15fc6d555141]::fn_ctxt::FnCtxt>::report_arg_errors
  15:     0x7924c0fe464b - <rustc_hir_typeck[64ea15fc6d555141]::fn_ctxt::FnCtxt>::confirm_builtin_call
  16:     0x7924c53f8054 - <rustc_hir_typeck[64ea15fc6d555141]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  17:     0x7924c53f167d - <rustc_hir_typeck[64ea15fc6d555141]::fn_ctxt::FnCtxt>::check_block_with_expected
  18:     0x7924c53f88c6 - <rustc_hir_typeck[64ea15fc6d555141]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  19:     0x7924c53f1750 - <rustc_hir_typeck[64ea15fc6d555141]::fn_ctxt::FnCtxt>::check_block_with_expected
  20:     0x7924c53f88c6 - <rustc_hir_typeck[64ea15fc6d555141]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  21:     0x7924c48e34cd - rustc_hir_typeck[64ea15fc6d555141]::check::check_fn
  22:     0x7924c4acf8b2 - rustc_hir_typeck[64ea15fc6d555141]::typeck
  23:     0x7924c4acf2fb - rustc_query_impl[10f4610d82d1755]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[10f4610d82d1755]::query_impl::typeck::dynamic_query::{closure#2}::{closure#0}, rustc_middle[b34bf39858087346]::query::erase::Erased<[u8; 8usize]>>
  24:     0x7924c4a8c37a - rustc_query_system[9b131319f03a3a86]::query::plumbing::try_execute_query::<rustc_query_impl[10f4610d82d1755]::DynamicConfig<rustc_query_system[9b131319f03a3a86]::query::caches::VecCache<rustc_span[47520046110495da]::def_id::LocalDefId, rustc_middle[b34bf39858087346]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[10f4610d82d1755]::plumbing::QueryCtxt, false>
  25:     0x7924c4a8af4d - rustc_query_impl[10f4610d82d1755]::query_impl::typeck::get_query_non_incr::__rust_end_short_backtrace
  26:     0x7924c4a8abc7 - <rustc_middle[b34bf39858087346]::hir::map::Map>::par_body_owners::<rustc_hir_analysis[da01e707c7998300]::check_crate::{closure#4}>::{closure#0}
  27:     0x7924c4a88a6e - rustc_hir_analysis[da01e707c7998300]::check_crate
  28:     0x7924c4a853c5 - rustc_interface[1be50e3bad7a611]::passes::run_required_analyses
  29:     0x7924c55b5f5e - rustc_interface[1be50e3bad7a611]::passes::analysis
  30:     0x7924c55b5f31 - rustc_query_impl[10f4610d82d1755]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[10f4610d82d1755]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[b34bf39858087346]::query::erase::Erased<[u8; 1usize]>>
  31:     0x7924c573b26e - rustc_query_system[9b131319f03a3a86]::query::plumbing::try_execute_query::<rustc_query_impl[10f4610d82d1755]::DynamicConfig<rustc_query_system[9b131319f03a3a86]::query::caches::SingleCache<rustc_middle[b34bf39858087346]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[10f4610d82d1755]::plumbing::QueryCtxt, false>
  32:     0x7924c573afcf - rustc_query_impl[10f4610d82d1755]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  33:     0x7924c55ae47c - rustc_interface[1be50e3bad7a611]::interface::run_compiler::<core[7a7dfcda68e5ea50]::result::Result<(), rustc_span[47520046110495da]::ErrorGuaranteed>, rustc_driver_impl[1984b1857baa03d4]::run_compiler::{closure#0}>::{closure#1}
  34:     0x7924c5675c50 - std[19c17663dd54327b]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[1be50e3bad7a611]::util::run_in_thread_with_globals<rustc_interface[1be50e3bad7a611]::util::run_in_thread_pool_with_globals<rustc_interface[1be50e3bad7a611]::interface::run_compiler<core[7a7dfcda68e5ea50]::result::Result<(), rustc_span[47520046110495da]::ErrorGuaranteed>, rustc_driver_impl[1984b1857baa03d4]::run_compiler::{closure#0}>::{closure#1}, core[7a7dfcda68e5ea50]::result::Result<(), rustc_span[47520046110495da]::ErrorGuaranteed>>::{closure#0}, core[7a7dfcda68e5ea50]::result::Result<(), rustc_span[47520046110495da]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[7a7dfcda68e5ea50]::result::Result<(), rustc_span[47520046110495da]::ErrorGuaranteed>>
  35:     0x7924c56762ba - <<std[19c17663dd54327b]::thread::Builder>::spawn_unchecked_<rustc_interface[1be50e3bad7a611]::util::run_in_thread_with_globals<rustc_interface[1be50e3bad7a611]::util::run_in_thread_pool_with_globals<rustc_interface[1be50e3bad7a611]::interface::run_compiler<core[7a7dfcda68e5ea50]::result::Result<(), rustc_span[47520046110495da]::ErrorGuaranteed>, rustc_driver_impl[1984b1857baa03d4]::run_compiler::{closure#0}>::{closure#1}, core[7a7dfcda68e5ea50]::result::Result<(), rustc_span[47520046110495da]::ErrorGuaranteed>>::{closure#0}, core[7a7dfcda68e5ea50]::result::Result<(), rustc_span[47520046110495da]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[7a7dfcda68e5ea50]::result::Result<(), rustc_span[47520046110495da]::ErrorGuaranteed>>::{closure#1} as core[7a7dfcda68e5ea50]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  36:     0x7924c56766ab - std::sys::pal::unix::thread::Thread::new::thread_start::h01e5f19adf5c8c06
  37:     0x7924c6d4c39d - <unknown>
  38:     0x7924c6dd149c - <unknown>
  39:                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 make sure that you have updated to the latest nightly

note: rustc 1.83.0-nightly (5e3ede22e 2024-09-14) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [typeck] type-checking `main`
#1 [analysis] running analysis passes on this crate
end of query stack
error[E0433]: failed to resolve: use of undeclared crate or module `fn_header_aux`
 --> /tmp/icemaker_global_tempdir.m40eJ3wCJOgX/rustc_testrunner_tmpdir_reporting.Esu9dG5LhXST/mvce.rs:8:7
  |
8 | reuse fn_header_aux::unsafe_fn_extern;
  |       ^^^^^^^^^^^^^ use of undeclared crate or module `fn_header_aux`

error[E0433]: failed to resolve: use of undeclared crate or module `fn_header_aux`
 --> /tmp/icemaker_global_tempdir.m40eJ3wCJOgX/rustc_testrunner_tmpdir_reporting.Esu9dG5LhXST/mvce.rs:9:7
  |
9 | reuse fn_header_aux::extern_fn_extern;
  |       ^^^^^^^^^^^^^ use of undeclared crate or module `fn_header_aux`

error[E0433]: failed to resolve: use of undeclared crate or module `fn_header_aux`
  --> /tmp/icemaker_global_tempdir.m40eJ3wCJOgX/rustc_testrunner_tmpdir_reporting.Esu9dG5LhXST/mvce.rs:10:7
   |
10 | reuse fn_header_aux::variadic_fn_extern;
   |       ^^^^^^^^^^^^^ use of undeclared crate or module `fn_header_aux`

error[E0433]: failed to resolve: use of undeclared crate or module `fn_header_aux`
  --> /tmp/icemaker_global_tempdir.m40eJ3wCJOgX/rustc_testrunner_tmpdir_reporting.Esu9dG5LhXST/mvce.rs:11:7
   |
11 | reuse fn_header_aux::const_fn_extern;
   |       ^^^^^^^^^^^^^ use of undeclared crate or module `fn_header_aux`

error[E0433]: failed to resolve: use of undeclared crate or module `fn_header_aux`
  --> /tmp/icemaker_global_tempdir.m40eJ3wCJOgX/rustc_testrunner_tmpdir_reporting.Esu9dG5LhXST/mvce.rs:12:7
   |
12 | reuse fn_header_aux::async_fn_extern;
   |       ^^^^^^^^^^^^^ use of undeclared crate or module `fn_header_aux`

error: aborting due to 13 previous errors

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

@rustbot label +F-c_variadic +F-fn_delegation

@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. C-bug Category: This is a bug. labels Sep 14, 2024
@rustbot rustbot added needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. F-c_variadic `#![feature(c_variadic)]` F-fn_delegation `#![feature(fn_delegation)]` labels Sep 14, 2024
@matthiaskrgr
Copy link
Member Author

pub fn variadic_fn(n: usize, mut args: ...) {}

reuse variadic_fn;

fn main() {
        variadic_fn();
}

@matthiaskrgr
Copy link
Member Author

#129320 cc @jder

@compiler-errors
Copy link
Member

lol

@jder
Copy link
Contributor

jder commented Sep 15, 2024

Thanks! I will take a look. (I'm glad we added the check!)

@matthiaskrgr
Copy link
Member Author

another one that does not need delegation I think

pub fn test_va_copy(_: u64, mut ap: ...) {}

pub fn main() {
    unsafe {
        test_va_copy();

        call(x);
    }
}

@matthiaskrgr
Copy link
Member Author

fn bar() -> impl Fn() {
    wrap()
}

fn wrap(...: impl ...) -> impl Fn() {}

@jder
Copy link
Contributor

jder commented Sep 15, 2024

@rustbot claim

@matthiaskrgr matthiaskrgr added the S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. label Sep 16, 2024
@bors bors closed this as completed in 14ee69c Sep 16, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Sep 16, 2024
Rollup merge of rust-lang#130437 - jder:issue-130372, r=compiler-errors

Avoid crashing on variadic functions when producing arg-mismatch errors

Fixes rust-lang#130372 by accommodating how variadic functions change the argument list length between HIR body and FnDecls.

Also degrades the zip_eq to a debug_assert! to match other asserts in the area to avoid being disruptive to users. There is at least one other crash in this area I am working on in rust-lang#130400 and also considering how we might refactor some of this code to hoist some of this logic up higher.

r? `@compiler-errors`
@jieyouxu jieyouxu removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Sep 17, 2024
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-c_variadic `#![feature(c_variadic)]` F-fn_delegation `#![feature(fn_delegation)]` I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. 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.

5 participants