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: underef: index out of bounds #121472

Closed
matthiaskrgr opened this issue Feb 22, 2024 · 1 comment · Fixed by #122863
Closed

ICE: underef: index out of bounds #121472

matthiaskrgr opened this issue Feb 22, 2024 · 1 comment · Fixed by #122863
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. 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

@matthiaskrgr
Copy link
Member

auto-reduced (treereduce-rust):

trait T {}

type Alias<'a> = impl T;

struct S;
impl<'a> T for &'a S {}

fn with_positive(fun: impl Fn(Alias<'_>)) {}

fn main() {
    with_positive(|&n| ());
}

original:

#![feature(type_alias_impl_trait)]

//@ build-pass

trait T { type Item; }

type Alias<'a> = impl T<Item = &'a ()>;

struct S;
impl<'a> T for &'a S {
    type Item = &'a ();
}

fn filter_positive<'a>() -> Alias<'a> {
    &S
}

fn with_positive(fun: impl Fn(Alias<'_>)) {
    fun(filter_positive());
}

fn main() {
    with_positive(|&n| ());
}

Version information

rustc 1.78.0-nightly (f8131a48a 2024-02-21)
binary: rustc
commit-hash: f8131a48a46ac3bc8a3d0fe0477055b132cffdc3
commit-date: 2024-02-21
host: x86_64-unknown-linux-gnu
release: 1.78.0-nightly
LLVM version: 18.1.0

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

Program output

error[E0658]: `impl Trait` in type aliases is unstable
 --> /tmp/icemaker_global_tempdir.F5838RU6DQwp/rustc_testrunner_tmpdir_reporting.lgnzWyLkPTPL/mvce.rs:3:18
  |
3 | type Alias<'a> = impl T;
  |                  ^^^^^^
  |
  = note: see issue #63063 <https://github.com/rust-lang/rust/issues/63063> for more information
  = help: add `#![feature(type_alias_impl_trait)]` to the crate attributes to enable
  = note: this compiler was built on 2024-02-21; consider upgrading it if it is out of date

error: item constrains opaque type that is not in its signature
  --> /tmp/icemaker_global_tempdir.F5838RU6DQwp/rustc_testrunner_tmpdir_reporting.lgnzWyLkPTPL/mvce.rs:11:20
   |
11 |     with_positive(|&n| ());
   |                    ^^
   |
   = note: this item must mention the opaque type in its signature in order to be able to register hidden types
note: this item must mention the opaque type in its signature in order to be able to register hidden types
  --> /tmp/icemaker_global_tempdir.F5838RU6DQwp/rustc_testrunner_tmpdir_reporting.lgnzWyLkPTPL/mvce.rs:10:4
   |
10 | fn main() {
   |    ^^^^

warning: unused variable: `n`
  --> /tmp/icemaker_global_tempdir.F5838RU6DQwp/rustc_testrunner_tmpdir_reporting.lgnzWyLkPTPL/mvce.rs:11:21
   |
11 |     with_positive(|&n| ());
   |                     ^ help: if this is intentional, prefix it with an underscore: `_n`
   |
   = note: `#[warn(unused_variables)]` on by default

error[E0507]: cannot move out of a shared reference
  --> /tmp/icemaker_global_tempdir.F5838RU6DQwp/rustc_testrunner_tmpdir_reporting.lgnzWyLkPTPL/mvce.rs:11:20
   |
11 |     with_positive(|&n| ());
   |                    ^-
   |                     |
   |                     data moved here
   |                     move occurs because `n` has type `S`, which does not implement the `Copy` trait
   |
help: consider removing the borrow
   |
11 -     with_positive(|&n| ());
11 +     with_positive(|n| ());
   |

error: item constrains opaque type that is not in its signature
  --> /tmp/icemaker_global_tempdir.F5838RU6DQwp/rustc_testrunner_tmpdir_reporting.lgnzWyLkPTPL/mvce.rs:11:20
   |
11 |     with_positive(|&n| ());
   |                    ^^
   |
   = note: this item must mention the opaque type in its signature in order to be able to register hidden types
note: this item must mention the opaque type in its signature in order to be able to register hidden types
  --> /tmp/icemaker_global_tempdir.F5838RU6DQwp/rustc_testrunner_tmpdir_reporting.lgnzWyLkPTPL/mvce.rs:11:19
   |
11 |     with_positive(|&n| ());
   |                   ^^^^

warning: unused variable: `fun`
 --> /tmp/icemaker_global_tempdir.F5838RU6DQwp/rustc_testrunner_tmpdir_reporting.lgnzWyLkPTPL/mvce.rs:8:18
  |
8 | fn with_positive(fun: impl Fn(Alias<'_>)) {}
  |                  ^^^ help: if this is intentional, prefix it with an underscore: `_fun`

thread 'rustc' panicked at /rustc/f8131a48a46ac3bc8a3d0fe0477055b132cffdc3/compiler/rustc_mir_dataflow/src/un_derefer.rs:67:20:
index out of bounds: the len is 0 but the index is 0
stack backtrace:
   0:     0x7f603d823af6 - std::backtrace_rs::backtrace::libunwind::trace::hbec2edc838b433e2
                               at /rustc/f8131a48a46ac3bc8a3d0fe0477055b132cffdc3/library/std/src/../../backtrace/src/backtrace/libunwind.rs:104:5
   1:     0x7f603d823af6 - std::backtrace_rs::backtrace::trace_unsynchronized::h88c30257ee0dd166
                               at /rustc/f8131a48a46ac3bc8a3d0fe0477055b132cffdc3/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f603d823af6 - std::sys_common::backtrace::_print_fmt::h9176654d509e3088
                               at /rustc/f8131a48a46ac3bc8a3d0fe0477055b132cffdc3/library/std/src/sys_common/backtrace.rs:68:5
   3:     0x7f603d823af6 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h671feaee1776bf19
                               at /rustc/f8131a48a46ac3bc8a3d0fe0477055b132cffdc3/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7f603d874a7c - core::fmt::rt::Argument::fmt::h59605c83ae32d935
                               at /rustc/f8131a48a46ac3bc8a3d0fe0477055b132cffdc3/library/core/src/fmt/rt.rs:142:9
   5:     0x7f603d874a7c - core::fmt::write::hf7af8dfcfd20db5b
                               at /rustc/f8131a48a46ac3bc8a3d0fe0477055b132cffdc3/library/core/src/fmt/mod.rs:1120:17
   6:     0x7f603d8184bf - std::io::Write::write_fmt::h92a5dbf489025e71
                               at /rustc/f8131a48a46ac3bc8a3d0fe0477055b132cffdc3/library/std/src/io/mod.rs:1846:15
   7:     0x7f603d8238a4 - std::sys_common::backtrace::_print::h00080302d23998ae
                               at /rustc/f8131a48a46ac3bc8a3d0fe0477055b132cffdc3/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x7f603d8238a4 - std::sys_common::backtrace::print::h6b23124445400245
                               at /rustc/f8131a48a46ac3bc8a3d0fe0477055b132cffdc3/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7f603d8265eb - std::panicking::default_hook::{{closure}}::hd67b2f9d36675a28
  10:     0x7f603d826339 - std::panicking::default_hook::h10a39ef11c714e42
                               at /rustc/f8131a48a46ac3bc8a3d0fe0477055b132cffdc3/library/std/src/panicking.rs:292:9
  11:     0x7f603a47a94c - std[5a8e7f94216a9138]::panicking::update_hook::<alloc[e14ab1f516d287ab]::boxed::Box<rustc_driver_impl[e279e4f1fedd9109]::install_ice_hook::{closure#0}>>::{closure#0}
  12:     0x7f603d826d50 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h37ba37dc48823c1d
                               at /rustc/f8131a48a46ac3bc8a3d0fe0477055b132cffdc3/library/alloc/src/boxed.rs:2030:9
  13:     0x7f603d826d50 - std::panicking::rust_panic_with_hook::he3e3bc7c345bf54b
                               at /rustc/f8131a48a46ac3bc8a3d0fe0477055b132cffdc3/library/std/src/panicking.rs:786:13
  14:     0x7f603d826a92 - std::panicking::begin_panic_handler::{{closure}}::h4bfbc62f377d59e6
                               at /rustc/f8131a48a46ac3bc8a3d0fe0477055b132cffdc3/library/std/src/panicking.rs:660:13
  15:     0x7f603d823fd6 - std::sys_common::backtrace::__rust_end_short_backtrace::hc8487cf1bc04a693
                               at /rustc/f8131a48a46ac3bc8a3d0fe0477055b132cffdc3/library/std/src/sys_common/backtrace.rs:171:18
  16:     0x7f603d8267c4 - rust_begin_unwind
                               at /rustc/f8131a48a46ac3bc8a3d0fe0477055b132cffdc3/library/std/src/panicking.rs:648:5
  17:     0x7f603d870f95 - core::panicking::panic_fmt::h88277cce839da186
                               at /rustc/f8131a48a46ac3bc8a3d0fe0477055b132cffdc3/library/core/src/panicking.rs:72:14
  18:     0x7f603d8711e2 - core::panicking::panic_bounds_check::h7889403d641fd53a
                               at /rustc/f8131a48a46ac3bc8a3d0fe0477055b132cffdc3/library/core/src/panicking.rs:208:5
  19:     0x7f603898e24a - <rustc_mir_dataflow[9dbea5a14cdf9346]::move_paths::builder::Gatherer<<rustc_mir_transform[2f80b166b66099ac]::elaborate_drops::ElaborateDrops as rustc_middle[446dd094ad85939e]::mir::MirPass>::run_pass::{closure#0}>>::gather_move
  20:     0x7f6038973697 - <rustc_mir_transform[2f80b166b66099ac]::elaborate_drops::ElaborateDrops as rustc_middle[446dd094ad85939e]::mir::MirPass>::run_pass
  21:     0x7f603b812689 - rustc_mir_transform[2f80b166b66099ac]::pass_manager::run_passes_inner
  22:     0x7f603ba42806 - rustc_mir_transform[2f80b166b66099ac]::mir_drops_elaborated_and_const_checked
  23:     0x7f603ba4213d - rustc_query_impl[9d4c51777e2bb749]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[9d4c51777e2bb749]::query_impl::mir_drops_elaborated_and_const_checked::dynamic_query::{closure#2}::{closure#0}, rustc_middle[446dd094ad85939e]::query::erase::Erased<[u8; 8usize]>>
  24:     0x7f603b9098b0 - rustc_query_system[9b2ccfe41ae3bb1b]::query::plumbing::try_execute_query::<rustc_query_impl[9d4c51777e2bb749]::DynamicConfig<rustc_query_system[9b2ccfe41ae3bb1b]::query::caches::VecCache<rustc_span[adb133ac03280fc1]::def_id::LocalDefId, rustc_middle[446dd094ad85939e]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[9d4c51777e2bb749]::plumbing::QueryCtxt, false>
  25:     0x7f603b90919e - rustc_query_impl[9d4c51777e2bb749]::query_impl::mir_drops_elaborated_and_const_checked::get_query_non_incr::__rust_end_short_backtrace
  26:     0x7f603c2a333f - rustc_interface[7ca501d7f8f3a34f]::passes::analysis
  27:     0x7f603c2a2a29 - rustc_query_impl[9d4c51777e2bb749]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[9d4c51777e2bb749]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[446dd094ad85939e]::query::erase::Erased<[u8; 1usize]>>
  28:     0x7f603c53d4a5 - rustc_query_system[9b2ccfe41ae3bb1b]::query::plumbing::try_execute_query::<rustc_query_impl[9d4c51777e2bb749]::DynamicConfig<rustc_query_system[9b2ccfe41ae3bb1b]::query::caches::SingleCache<rustc_middle[446dd094ad85939e]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[9d4c51777e2bb749]::plumbing::QueryCtxt, false>
  29:     0x7f603c53d209 - rustc_query_impl[9d4c51777e2bb749]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  30:     0x7f603c54c719 - rustc_interface[7ca501d7f8f3a34f]::interface::run_compiler::<core[85b4fd477ce5bb21]::result::Result<(), rustc_span[adb133ac03280fc1]::ErrorGuaranteed>, rustc_driver_impl[e279e4f1fedd9109]::run_compiler::{closure#0}>::{closure#0}
  31:     0x7f603c7be705 - std[5a8e7f94216a9138]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[7ca501d7f8f3a34f]::util::run_in_thread_with_globals<rustc_interface[7ca501d7f8f3a34f]::util::run_in_thread_pool_with_globals<rustc_interface[7ca501d7f8f3a34f]::interface::run_compiler<core[85b4fd477ce5bb21]::result::Result<(), rustc_span[adb133ac03280fc1]::ErrorGuaranteed>, rustc_driver_impl[e279e4f1fedd9109]::run_compiler::{closure#0}>::{closure#0}, core[85b4fd477ce5bb21]::result::Result<(), rustc_span[adb133ac03280fc1]::ErrorGuaranteed>>::{closure#0}, core[85b4fd477ce5bb21]::result::Result<(), rustc_span[adb133ac03280fc1]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[85b4fd477ce5bb21]::result::Result<(), rustc_span[adb133ac03280fc1]::ErrorGuaranteed>>
  32:     0x7f603c7be532 - <<std[5a8e7f94216a9138]::thread::Builder>::spawn_unchecked_<rustc_interface[7ca501d7f8f3a34f]::util::run_in_thread_with_globals<rustc_interface[7ca501d7f8f3a34f]::util::run_in_thread_pool_with_globals<rustc_interface[7ca501d7f8f3a34f]::interface::run_compiler<core[85b4fd477ce5bb21]::result::Result<(), rustc_span[adb133ac03280fc1]::ErrorGuaranteed>, rustc_driver_impl[e279e4f1fedd9109]::run_compiler::{closure#0}>::{closure#0}, core[85b4fd477ce5bb21]::result::Result<(), rustc_span[adb133ac03280fc1]::ErrorGuaranteed>>::{closure#0}, core[85b4fd477ce5bb21]::result::Result<(), rustc_span[adb133ac03280fc1]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[85b4fd477ce5bb21]::result::Result<(), rustc_span[adb133ac03280fc1]::ErrorGuaranteed>>::{closure#1} as core[85b4fd477ce5bb21]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  33:     0x7f603d830725 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h1bff3efb61c3fa6b
                               at /rustc/f8131a48a46ac3bc8a3d0fe0477055b132cffdc3/library/alloc/src/boxed.rs:2016:9
  34:     0x7f603d830725 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h83141cf549dced8a
                               at /rustc/f8131a48a46ac3bc8a3d0fe0477055b132cffdc3/library/alloc/src/boxed.rs:2016:9
  35:     0x7f603d830725 - std::sys::pal::unix::thread::Thread::new::thread_start::hbe9287fdd7c325bc
                               at /rustc/f8131a48a46ac3bc8a3d0fe0477055b132cffdc3/library/std/src/sys/pal/unix/thread.rs:108:17
  36:     0x7f60374aa9eb - <unknown>
  37:     0x7f603752e7cc - <unknown>
  38:                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: rustc 1.78.0-nightly (f8131a48a 2024-02-21) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [mir_drops_elaborated_and_const_checked] elaborating drops for `main::{closure#0}`
#1 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 4 previous errors; 2 warnings emitted

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

@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 Feb 22, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Feb 22, 2024
@matthiaskrgr
Copy link
Member Author

#120550 cc @oli-obk

@fmease fmease removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Mar 1, 2024
@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 12, 2024
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Mar 22, 2024
@bors bors closed this as completed in 4d9ce7a Mar 22, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Mar 22, 2024
Rollup merge of rust-lang#122863 - matthiaskrgr:teest, r=lcnr

add more ice tests

fixes rust-lang#119275
fixes rust-lang#113017
fixes rust-lang#112824
fixes rust-lang#112823
fixes rust-lang#121472
fixes rust-lang#110696
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. 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
Development

Successfully merging a pull request may close this issue.

3 participants