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

Index out of bounds while checking function arguments #97197

Closed
GabrielDertoni opened this issue May 20, 2022 · 4 comments · Fixed by #97303
Closed

Index out of bounds while checking function arguments #97197

GabrielDertoni opened this issue May 20, 2022 · 4 comments · Fixed by #97303
Assignees
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) ❄️ P-medium Medium priority regression-from-stable-to-beta Performance or correctness regression from stable to beta. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@GabrielDertoni
Copy link

GabrielDertoni commented May 20, 2022

Code

fn f() {
    g((), ());
}

pub fn g(a1: (), a2: bool, a3: bool, a4: bool, a5: bool, a6: ()) {}

Playground

Meta

rustc --version --verbose:

rustc 1.63.0-nightly (cd282d7f7 2022-05-18)
binary: rustc
commit-hash: cd282d7f75da9080fda0f1740a729516e7fbec68
commit-date: 2022-05-18
host: x86_64-unknown-linux-gnu
release: 1.63.0-nightly
LLVM version: 14.0.4

Error output

thread 'rustc' panicked at 'index out of bounds: the len is 2 but the index is 4', compiler/rustc_typeck/src/check/fn_ctxt/checks.rs:818:59

error: internal compiler error: unexpected panic

note: the compiler unexpectedly panicked. this is a bug.

note: rustc 1.63.0-nightly (cd282d7f7 2022-05-18) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type lib -C embed-bitcode=no -C debuginfo=2 -C incremental

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
#0 [typeck] type-checking `f`
#1 [typeck_item_bodies] type-checking all item bodies
#2 [analysis] running analysis passes on this crate
end of query stack
error: could not compile `rustc_bug`
Backtrace

stack backtrace:
   0:     0x7fc08d000fcd - std::backtrace_rs::backtrace::libunwind::trace::h792c30771d1dce4e
                               at /rustc/cd282d7f75da9080fda0f1740a729516e7fbec68/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7fc08d000fcd - std::backtrace_rs::backtrace::trace_unsynchronized::h20bd96032223b984
                               at /rustc/cd282d7f75da9080fda0f1740a729516e7fbec68/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7fc08d000fcd - std::sys_common::backtrace::_print_fmt::h55ce8a26aee332a3
                               at /rustc/cd282d7f75da9080fda0f1740a729516e7fbec68/library/std/src/sys_common/backtrace.rs:66:5
   3:     0x7fc08d000fcd - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h1e608165fd05792c
                               at /rustc/cd282d7f75da9080fda0f1740a729516e7fbec68/library/std/src/sys_common/backtrace.rs:45:22
   4:     0x7fc08d05cc5c - core::fmt::write::hdc9f366f1ec7f5cc
                               at /rustc/cd282d7f75da9080fda0f1740a729516e7fbec68/library/core/src/fmt/mod.rs:1196:17
   5:     0x7fc08cff2741 - std::io::Write::write_fmt::hae36452b87a7144a
                               at /rustc/cd282d7f75da9080fda0f1740a729516e7fbec68/library/std/src/io/mod.rs:1654:15
   6:     0x7fc08d003ce5 - std::sys_common::backtrace::_print::hbfb86fe090e52690
                               at /rustc/cd282d7f75da9080fda0f1740a729516e7fbec68/library/std/src/sys_common/backtrace.rs:48:5
   7:     0x7fc08d003ce5 - std::sys_common::backtrace::print::h4abb1fed1562e0f8
                               at /rustc/cd282d7f75da9080fda0f1740a729516e7fbec68/library/std/src/sys_common/backtrace.rs:35:9
   8:     0x7fc08d003ce5 - std::panicking::default_hook::{{closure}}::hed4b61614b3d60d1
                               at /rustc/cd282d7f75da9080fda0f1740a729516e7fbec68/library/std/src/panicking.rs:295:22
   9:     0x7fc08d003959 - std::panicking::default_hook::h787a125a3d53fabc
                               at /rustc/cd282d7f75da9080fda0f1740a729516e7fbec68/library/std/src/panicking.rs:314:9
  10:     0x7fc08d7c9b41 - rustc_driver[af3c34e99bc7132d]::DEFAULT_HOOK::{closure#0}::{closure#0}
  11:     0x7fc08d0044b6 - std::panicking::rust_panic_with_hook::he936e1666803a13d
                               at /rustc/cd282d7f75da9080fda0f1740a729516e7fbec68/library/std/src/panicking.rs:702:17
  12:     0x7fc08d0042b7 - std::panicking::begin_panic_handler::{{closure}}::h5330690fb8e8d9da
                               at /rustc/cd282d7f75da9080fda0f1740a729516e7fbec68/library/std/src/panicking.rs:588:13
  13:     0x7fc08d001484 - std::sys_common::backtrace::__rust_end_short_backtrace::he03416277ca16606
                               at /rustc/cd282d7f75da9080fda0f1740a729516e7fbec68/library/std/src/sys_common/backtrace.rs:138:18
  14:     0x7fc08d003fe9 - rust_begin_unwind
                               at /rustc/cd282d7f75da9080fda0f1740a729516e7fbec68/library/std/src/panicking.rs:584:5
  15:     0x7fc08cfc9263 - core::panicking::panic_fmt::hcb1f1aab333b06ef
                               at /rustc/cd282d7f75da9080fda0f1740a729516e7fbec68/library/core/src/panicking.rs:142:14
  16:     0x7fc08cfc91a2 - core::panicking::panic_bounds_check::h2a4a0e6246b57d65
                               at /rustc/cd282d7f75da9080fda0f1740a729516e7fbec68/library/core/src/panicking.rs:84:5
  17:     0x7fc08ecafdc6 - <rustc_typeck[a51bc4bda11be944]::check::fn_ctxt::FnCtxt>::check_argument_types
  18:     0x7fc08ec7833c - <rustc_typeck[a51bc4bda11be944]::check::fn_ctxt::FnCtxt>::check_call
  19:     0x7fc08ecc6399 - <rustc_typeck[a51bc4bda11be944]::check::fn_ctxt::FnCtxt>::check_expr_kind
  20:     0x7fc08ecc5210 - <rustc_typeck[a51bc4bda11be944]::check::fn_ctxt::FnCtxt>::check_expr_with_expectation
  21:     0x7fc08ecb4099 - <rustc_typeck[a51bc4bda11be944]::check::fn_ctxt::FnCtxt>::check_stmt
  22:     0x7fc08ecb571d - <rustc_typeck[a51bc4bda11be944]::check::fn_ctxt::FnCtxt>::check_block_with_expected
  23:     0x7fc08ecc64aa - <rustc_typeck[a51bc4bda11be944]::check::fn_ctxt::FnCtxt>::check_expr_kind
  24:     0x7fc08ecc5210 - <rustc_typeck[a51bc4bda11be944]::check::fn_ctxt::FnCtxt>::check_expr_with_expectation
  25:     0x7fc08ede1640 - rustc_typeck[a51bc4bda11be944]::check::check::check_fn
  26:     0x7fc08ed46bbc - <rustc_infer[73d5c1fd1d2bb465]::infer::InferCtxtBuilder>::enter::<&rustc_middle[29414c9708d2f2c6]::ty::context::TypeckResults, <rustc_typeck[a51bc4bda11be944]::check::inherited::InheritedBuilder>::enter<rustc_typeck[a51bc4bda11be944]::check::typeck_with_fallback<rustc_typeck[a51bc4bda11be944]::check::typeck::{closure#0}>::{closure#1}, &rustc_middle[29414c9708d2f2c6]::ty::context::TypeckResults>::{closure#0}>
  27:     0x7fc08ed03c90 - rustc_typeck[a51bc4bda11be944]::check::typeck
  28:     0x7fc08fd28a70 - <rustc_query_system[c5b167391a1fc8c0]::dep_graph::graph::DepGraph<rustc_middle[29414c9708d2f2c6]::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle[29414c9708d2f2c6]::ty::context::TyCtxt, rustc_span[59d1c307ce41abbc]::def_id::LocalDefId, &rustc_middle[29414c9708d2f2c6]::ty::context::TypeckResults>
  29:     0x7fc08f2baee1 - rustc_query_system[c5b167391a1fc8c0]::query::plumbing::try_execute_query::<rustc_query_impl[d1fe922fcf7cfd91]::plumbing::QueryCtxt, rustc_query_system[c5b167391a1fc8c0]::query::caches::DefaultCache<rustc_span[59d1c307ce41abbc]::def_id::LocalDefId, &rustc_middle[29414c9708d2f2c6]::ty::context::TypeckResults>>
  30:     0x7fc08f28b188 - <rustc_query_impl[d1fe922fcf7cfd91]::Queries as rustc_middle[29414c9708d2f2c6]::ty::query::QueryEngine>::typeck
  31:     0x7fc08eda37d8 - <rustc_middle[29414c9708d2f2c6]::hir::map::Map>::par_body_owners::<rustc_typeck[a51bc4bda11be944]::check::typeck_item_bodies::{closure#0}>
  32:     0x7fc08fad650c - rustc_typeck[a51bc4bda11be944]::check::typeck_item_bodies
  33:     0x7fc08fd45ee9 - <rustc_query_system[c5b167391a1fc8c0]::dep_graph::graph::DepGraph<rustc_middle[29414c9708d2f2c6]::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle[29414c9708d2f2c6]::ty::context::TyCtxt, (), ()>
  34:     0x7fc08fdec61a - rustc_query_system[c5b167391a1fc8c0]::query::plumbing::try_execute_query::<rustc_query_impl[d1fe922fcf7cfd91]::plumbing::QueryCtxt, rustc_query_system[c5b167391a1fc8c0]::query::caches::DefaultCache<(), ()>>
  35:     0x7fc08fe15441 - rustc_query_system[c5b167391a1fc8c0]::query::plumbing::get_query::<rustc_query_impl[d1fe922fcf7cfd91]::queries::typeck_item_bodies, rustc_query_impl[d1fe922fcf7cfd91]::plumbing::QueryCtxt>
  36:     0x7fc08fb0b0b3 - <rustc_session[8640123feec5f500]::session::Session>::time::<(), rustc_typeck[a51bc4bda11be944]::check_crate::{closure#7}>
  37:     0x7fc08faf5ddb - rustc_typeck[a51bc4bda11be944]::check_crate
  38:     0x7fc08f88fee7 - rustc_interface[3e05e90922109e97]::passes::analysis
  39:     0x7fc08fd420b5 - <rustc_query_system[c5b167391a1fc8c0]::dep_graph::graph::DepGraph<rustc_middle[29414c9708d2f2c6]::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle[29414c9708d2f2c6]::ty::context::TyCtxt, (), core[d4fcbe885e6a87a3]::result::Result<(), rustc_errors[8ec3179ad5714546]::ErrorGuaranteed>>
  40:     0x7fc08fde25b1 - rustc_query_system[c5b167391a1fc8c0]::query::plumbing::try_execute_query::<rustc_query_impl[d1fe922fcf7cfd91]::plumbing::QueryCtxt, rustc_query_system[c5b167391a1fc8c0]::query::caches::DefaultCache<(), core[d4fcbe885e6a87a3]::result::Result<(), rustc_errors[8ec3179ad5714546]::ErrorGuaranteed>>>
  41:     0x7fc08fe2791e - rustc_query_system[c5b167391a1fc8c0]::query::plumbing::get_query::<rustc_query_impl[d1fe922fcf7cfd91]::queries::analysis, rustc_query_impl[d1fe922fcf7cfd91]::plumbing::QueryCtxt>
  42:     0x7fc08f870bf7 - <rustc_interface[3e05e90922109e97]::passes::QueryContext>::enter::<rustc_driver[af3c34e99bc7132d]::run_compiler::{closure#1}::{closure#2}::{closure#3}, core[d4fcbe885e6a87a3]::result::Result<(), rustc_errors[8ec3179ad5714546]::ErrorGuaranteed>>
  43:     0x7fc08f85b9c8 - <rustc_interface[3e05e90922109e97]::interface::Compiler>::enter::<rustc_driver[af3c34e99bc7132d]::run_compiler::{closure#1}::{closure#2}, core[d4fcbe885e6a87a3]::result::Result<core[d4fcbe885e6a87a3]::option::Option<rustc_interface[3e05e90922109e97]::queries::Linker>, rustc_errors[8ec3179ad5714546]::ErrorGuaranteed>>
  44:     0x7fc08f88433f - rustc_span[59d1c307ce41abbc]::with_source_map::<core[d4fcbe885e6a87a3]::result::Result<(), rustc_errors[8ec3179ad5714546]::ErrorGuaranteed>, rustc_interface[3e05e90922109e97]::interface::create_compiler_and_run<core[d4fcbe885e6a87a3]::result::Result<(), rustc_errors[8ec3179ad5714546]::ErrorGuaranteed>, rustc_driver[af3c34e99bc7132d]::run_compiler::{closure#1}>::{closure#1}>
  45:     0x7fc08f85c734 - rustc_interface[3e05e90922109e97]::interface::create_compiler_and_run::<core[d4fcbe885e6a87a3]::result::Result<(), rustc_errors[8ec3179ad5714546]::ErrorGuaranteed>, rustc_driver[af3c34e99bc7132d]::run_compiler::{closure#1}>
  46:     0x7fc08f859ec2 - <scoped_tls[cbc0d094596bada1]::ScopedKey<rustc_span[59d1c307ce41abbc]::SessionGlobals>>::set::<rustc_interface[3e05e90922109e97]::interface::run_compiler<core[d4fcbe885e6a87a3]::result::Result<(), rustc_errors[8ec3179ad5714546]::ErrorGuaranteed>, rustc_driver[af3c34e99bc7132d]::run_compiler::{closure#1}>::{closure#0}, core[d4fcbe885e6a87a3]::result::Result<(), rustc_errors[8ec3179ad5714546]::ErrorGuaranteed>>
  47:     0x7fc08f87127f - std[5ea0d33796e47bea]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[3e05e90922109e97]::util::run_in_thread_pool_with_globals<rustc_interface[3e05e90922109e97]::interface::run_compiler<core[d4fcbe885e6a87a3]::result::Result<(), rustc_errors[8ec3179ad5714546]::ErrorGuaranteed>, rustc_driver[af3c34e99bc7132d]::run_compiler::{closure#1}>::{closure#0}, core[d4fcbe885e6a87a3]::result::Result<(), rustc_errors[8ec3179ad5714546]::ErrorGuaranteed>>::{closure#0}, core[d4fcbe885e6a87a3]::result::Result<(), rustc_errors[8ec3179ad5714546]::ErrorGuaranteed>>
  48:     0x7fc08f8713b9 - <<std[5ea0d33796e47bea]::thread::Builder>::spawn_unchecked_<rustc_interface[3e05e90922109e97]::util::run_in_thread_pool_with_globals<rustc_interface[3e05e90922109e97]::interface::run_compiler<core[d4fcbe885e6a87a3]::result::Result<(), rustc_errors[8ec3179ad5714546]::ErrorGuaranteed>, rustc_driver[af3c34e99bc7132d]::run_compiler::{closure#1}>::{closure#0}, core[d4fcbe885e6a87a3]::result::Result<(), rustc_errors[8ec3179ad5714546]::ErrorGuaranteed>>::{closure#0}, core[d4fcbe885e6a87a3]::result::Result<(), rustc_errors[8ec3179ad5714546]::ErrorGuaranteed>>::{closure#1} as core[d4fcbe885e6a87a3]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  49:     0x7fc08d00e3d3 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h80876dac74f8f7f5
                               at /rustc/cd282d7f75da9080fda0f1740a729516e7fbec68/library/alloc/src/boxed.rs:1872:9
  50:     0x7fc08d00e3d3 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h9cd29f95cc73ffbe
                               at /rustc/cd282d7f75da9080fda0f1740a729516e7fbec68/library/alloc/src/boxed.rs:1872:9
  51:     0x7fc08d00e3d3 - std::sys::unix::thread::Thread::new::thread_start::hc9488b0bdef72094
                               at /rustc/cd282d7f75da9080fda0f1740a729516e7fbec68/library/std/src/sys/unix/thread.rs:108:17
  52:     0x7fc08cf23609 - start_thread
                               at /build/glibc-eX1tMB/glibc-2.31/nptl/pthread_create.c:477:8
  53:     0x7fc08ce3d293 - clone
  54:                0x0 - <unknown>

@GabrielDertoni GabrielDertoni 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 May 20, 2022
@rust-lang-glacier-bot rust-lang-glacier-bot added the glacier ICE tracked in rust-lang/glacier. label May 21, 2022
@SNCPlay42
Copy link
Contributor

Also ICEs on beta. Output on stable:

error[E0061]: this function takes 6 arguments but 2 arguments were supplied
  --> src/main.rs:2:5
   |
2  |     g((), ());
   |     ^ --  -- supplied 2 arguments
   |     |
   |     expected 6 arguments
   |
note: function defined here
  --> src/main.rs:5:8
   |
5  |   pub fn g(
   |          ^
6  |       a1: (),
   |       ------
7  |       a2: bool,
   |       --------
8  |       a3: bool,
   |       --------
9  |       a4: bool,
   |       --------
10 |       a5: bool,
   |       --------
11 | /     a6: ()
12 | | ) -> () {
   | |_

@rustbot label regression-from-stable-to-beta

@rustbot rustbot added regression-from-stable-to-beta Performance or correctness regression from stable to beta. I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels May 21, 2022
@LingMan
Copy link
Contributor

LingMan commented May 23, 2022

searched nightlies: from nightly-2022-04-16 to nightly-2022-04-17
regressed nightly: nightly-2022-04-17
searched commit range: 3f391b8...878c783
regressed commit: 07bb916

bisected with cargo-bisect-rustc v0.6.3

Host triple: x86_64-unknown-linux-gnu
Reproduce with:

cargo bisect-rustc --regress=ice --start=2022-04-16 --end=2022-04-17 

cc @jackh726

@compiler-errors
Copy link
Member

@rustbot claim

@apiraino
Copy link
Contributor

Assigning priority as discussed in the Zulip thread of the Prioritization Working Group.

@rustbot label -I-prioritize +P-medium

@rustbot rustbot added P-medium Medium priority and removed I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels May 23, 2022
@bors bors closed this as completed in b5ff4ad May 23, 2022
ehuss pushed a commit to ehuss/rust that referenced this issue Jun 1, 2022
Fix some typos in arg checking algorithm

Fixes rust-lang#97197

Also fixes a typo where if we're missing args A, B, C, we actually say A, B, B
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) ❄️ P-medium Medium priority regression-from-stable-to-beta Performance or correctness regression from stable to beta. 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.

7 participants