Skip to content

ICE: delegation: liveness: index out of bounds #139512

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 Apr 8, 2025 · 2 comments
Closed

ICE: delegation: liveness: index out of bounds #139512

matthiaskrgr opened this issue Apr 8, 2025 · 2 comments
Assignees
Labels
C-bug Category: This is a bug. F-fn_delegation `#![feature(fn_delegation)]` 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):

mod to_reuse {
    pub fn foo<T, U>(_: T, y: U) -> U { y }
}

trait Trait<T> {
    fn foo(&self, x: T) -> T { x }
}
struct F;


struct S<T>(F, T);

impl<T, U> Trait<T> for S<U> {
    reuse to_reuse::foo { &.0 }
}



original:

//@ run-pass
#![feature(fn_delegation)]
#![allow(incomplete_features)]

mod to_reuse {
    pub fn foo<T, U>(_: T, y: U) -> U { y }
}

trait Trait<T> {
    fn foo(&self, x: T) -> T { x }
}
struct F;
impl<T> Trait<T> for F {}

struct S<T>(F, T);

impl<T, U> Trait<T> for S<U> {
    reuse to_reuse::foo { &.0 }
}

impl<T> S<T> {
    reuse to_reuse::foo;
}

fn main() {
    let s = S(F, 42);
    assert_eq!(s.by_ref(), 3);
    assert_eq!(<S<_> as Trait<_>>::foo(&s, 1), 1);
}

Version information

rustc 1.88.0-nightly (e643f59f6 2025-04-07)
binary: rustc
commit-hash: e643f59f6da3a84f43e75dea99afaa5b041ea6bf
commit-date: 2025-04-07
host: x86_64-unknown-linux-gnu
release: 1.88.0-nightly
LLVM version: 20.1.2

Possibly related line of code:

}
}
fn should_warn(&self, var: Variable) -> Option<String> {
let name = self.ir.variable_name(var);
let name = name.as_str();
if name.as_bytes()[0] == b'_' {
return None;
}
Some(name.to_owned())
}
fn warn_about_unused_upvars(&self, entry_ln: LiveNode) {

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

Program output

error: float literals must have an integer part
  --> /tmp/icemaker_global_tempdir.FLH6GcVf8ZFZ/rustc_testrunner_tmpdir_reporting.xWsyd1fPpEDo/mvce.rs:18:28
   |
18 |     reuse to_reuse::foo { &.0 }
   |                            ^^
   |
help: must have an integer part
   |
18 |     reuse to_reuse::foo { &0.0 }
   |                            +

error[E0658]: functions delegation is not yet fully implemented
  --> /tmp/icemaker_global_tempdir.FLH6GcVf8ZFZ/rustc_testrunner_tmpdir_reporting.xWsyd1fPpEDo/mvce.rs:18:5
   |
18 |     reuse to_reuse::foo { &.0 }
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = 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 2025-04-07; consider upgrading it if it is out of date

error[E0601]: `main` function not found in crate `mvce`
  --> /tmp/icemaker_global_tempdir.FLH6GcVf8ZFZ/rustc_testrunner_tmpdir_reporting.xWsyd1fPpEDo/mvce.rs:19:2
   |
19 | }
   |  ^ consider adding a `main` function to `/tmp/icemaker_global_tempdir.FLH6GcVf8ZFZ/rustc_testrunner_tmpdir_reporting.xWsyd1fPpEDo/mvce.rs`


thread 'rustc' panicked at compiler/rustc_passes/src/liveness.rs:1485:12:
index out of bounds: the len is 0 but the index is 0
stack backtrace:
   0:     0x741a1ac9bb23 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::hf5dc873791abf135
   1:     0x741a1b406111 - core::fmt::write::ha776e938852cf3cc
   2:     0x741a1c5760d1 - std::io::Write::write_fmt::h20ffaced5034a7d9
   3:     0x741a1ac9b982 - std::sys::backtrace::BacktraceLock::print::hb886f83202af1df7
   4:     0x741a1ac9f46a - std::panicking::default_hook::{{closure}}::h6c1c8b305374519f
   5:     0x741a1ac9efef - std::panicking::default_hook::h20bf230235c76f2b
   6:     0x741a19cf7d13 - std[9466cf876ee11eca]::panicking::update_hook::<alloc[d3b838bf054e3104]::boxed::Box<rustc_driver_impl[4339cf40f8e3ed89]::install_ice_hook::{closure#1}>>::{closure#0}
   7:     0x741a1ac9fce3 - std::panicking::rust_panic_with_hook::h636edd46b6e2975a
   8:     0x741a1ac9f9da - std::panicking::begin_panic_handler::{{closure}}::h188310d1379a79a3
   9:     0x741a1ac9bfe9 - std::sys::backtrace::__rust_end_short_backtrace::h66ee93ae65c27ed6
  10:     0x741a1ac9f69d - __rustc[f84ae5861e8c8fa0]::rust_begin_unwind
  11:     0x741a176989c0 - core::panicking::panic_fmt::h3d5144c0032eb82c
  12:     0x741a1896dd10 - core::panicking::panic_bounds_check::h230ef3172cc957ba
  13:     0x741a1cedcb9e - <rustc_passes[b12d5492c61825e7]::liveness::Liveness>::should_warn.cold
  14:     0x741a1be31d05 - <rustc_passes[b12d5492c61825e7]::liveness::Liveness>::report_unused
  15:     0x741a1be3a435 - rustc_passes[b12d5492c61825e7]::liveness::check_liveness
  16:     0x741a1be392b1 - rustc_query_impl[75a3021f06b975a9]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[75a3021f06b975a9]::query_impl::check_liveness::dynamic_query::{closure#2}::{closure#0}, rustc_middle[3618dc43a4e0fd99]::query::erase::Erased<[u8; 0usize]>>
  17:     0x741a1b6c6d11 - rustc_query_system[4850d857ad6bbb48]::query::plumbing::try_execute_query::<rustc_query_impl[75a3021f06b975a9]::DynamicConfig<rustc_data_structures[708642cd674fc7e2]::vec_cache::VecCache<rustc_span[973df61984709bb1]::def_id::LocalDefId, rustc_middle[3618dc43a4e0fd99]::query::erase::Erased<[u8; 0usize]>, rustc_query_system[4850d857ad6bbb48]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[75a3021f06b975a9]::plumbing::QueryCtxt, false>
  18:     0x741a1b6c6a8c - rustc_query_impl[75a3021f06b975a9]::query_impl::check_liveness::get_query_non_incr::__rust_end_short_backtrace
  19:     0x741a1bd4fb5c - rustc_mir_build[96b51f06fe9d557f]::builder::build_mir
  20:     0x741a1b40a305 - rustc_mir_transform[54ef79dd46f38ead]::mir_built
  21:     0x741a1b40a2d7 - rustc_query_impl[75a3021f06b975a9]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[75a3021f06b975a9]::query_impl::mir_built::dynamic_query::{closure#2}::{closure#0}, rustc_middle[3618dc43a4e0fd99]::query::erase::Erased<[u8; 8usize]>>
  22:     0x741a1b61f12c - rustc_query_system[4850d857ad6bbb48]::query::plumbing::try_execute_query::<rustc_query_impl[75a3021f06b975a9]::DynamicConfig<rustc_data_structures[708642cd674fc7e2]::vec_cache::VecCache<rustc_span[973df61984709bb1]::def_id::LocalDefId, rustc_middle[3618dc43a4e0fd99]::query::erase::Erased<[u8; 8usize]>, rustc_query_system[4850d857ad6bbb48]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[75a3021f06b975a9]::plumbing::QueryCtxt, false>
  23:     0x741a1b61ec4b - rustc_query_impl[75a3021f06b975a9]::query_impl::mir_built::get_query_non_incr::__rust_end_short_backtrace
  24:     0x741a1b6c7943 - rustc_mir_build[96b51f06fe9d557f]::check_unsafety::check_unsafety
  25:     0x741a1b6c7719 - rustc_query_impl[75a3021f06b975a9]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[75a3021f06b975a9]::query_impl::check_unsafety::dynamic_query::{closure#2}::{closure#0}, rustc_middle[3618dc43a4e0fd99]::query::erase::Erased<[u8; 0usize]>>
  26:     0x741a1b6c6d1d - rustc_query_system[4850d857ad6bbb48]::query::plumbing::try_execute_query::<rustc_query_impl[75a3021f06b975a9]::DynamicConfig<rustc_data_structures[708642cd674fc7e2]::vec_cache::VecCache<rustc_span[973df61984709bb1]::def_id::LocalDefId, rustc_middle[3618dc43a4e0fd99]::query::erase::Erased<[u8; 0usize]>, rustc_query_system[4850d857ad6bbb48]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[75a3021f06b975a9]::plumbing::QueryCtxt, false>
  27:     0x741a1b6c69fe - rustc_query_impl[75a3021f06b975a9]::query_impl::check_unsafety::get_query_non_incr::__rust_end_short_backtrace
  28:     0x741a1b76d979 - rustc_interface[adb8a737eb8b1c5b]::passes::run_required_analyses
  29:     0x741a1c480dde - rustc_interface[adb8a737eb8b1c5b]::passes::analysis
  30:     0x741a1c480db3 - rustc_query_impl[75a3021f06b975a9]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[75a3021f06b975a9]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[3618dc43a4e0fd99]::query::erase::Erased<[u8; 0usize]>>
  31:     0x741a1c3f0a3d - rustc_query_system[4850d857ad6bbb48]::query::plumbing::try_execute_query::<rustc_query_impl[75a3021f06b975a9]::DynamicConfig<rustc_query_system[4850d857ad6bbb48]::query::caches::SingleCache<rustc_middle[3618dc43a4e0fd99]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[75a3021f06b975a9]::plumbing::QueryCtxt, false>
  32:     0x741a1c3f0738 - rustc_query_impl[75a3021f06b975a9]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  33:     0x741a1c71780b - rustc_interface[adb8a737eb8b1c5b]::passes::create_and_enter_global_ctxt::<core[5fdad39456196c28]::option::Option<rustc_interface[adb8a737eb8b1c5b]::queries::Linker>, rustc_driver_impl[4339cf40f8e3ed89]::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
  34:     0x741a1c586e39 - rustc_interface[adb8a737eb8b1c5b]::interface::run_compiler::<(), rustc_driver_impl[4339cf40f8e3ed89]::run_compiler::{closure#0}>::{closure#1}
  35:     0x741a1c3726cf - std[9466cf876ee11eca]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[adb8a737eb8b1c5b]::util::run_in_thread_with_globals<rustc_interface[adb8a737eb8b1c5b]::util::run_in_thread_pool_with_globals<rustc_interface[adb8a737eb8b1c5b]::interface::run_compiler<(), rustc_driver_impl[4339cf40f8e3ed89]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  36:     0x741a1c372fab - <<std[9466cf876ee11eca]::thread::Builder>::spawn_unchecked_<rustc_interface[adb8a737eb8b1c5b]::util::run_in_thread_with_globals<rustc_interface[adb8a737eb8b1c5b]::util::run_in_thread_pool_with_globals<rustc_interface[adb8a737eb8b1c5b]::interface::run_compiler<(), rustc_driver_impl[4339cf40f8e3ed89]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[5fdad39456196c28]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  37:     0x741a1c3743ab - std::sys::pal::unix::thread::Thread::new::thread_start::h6582d45fad4b4756
  38:     0x741a162a370a - <unknown>
  39:     0x741a16327aac - <unknown>
  40:                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.88.0-nightly (e643f59f6 2025-04-07) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [check_liveness] checking liveness of variables in `<impl at /tmp/icemaker_global_tempdir.FLH6GcVf8ZFZ/rustc_testrunner_tmpdir_reporting.xWsyd1fPpEDo/mvce.rs:17:1: 17:29>::foo`
#1 [mir_built] building MIR for `<impl at /tmp/icemaker_global_tempdir.FLH6GcVf8ZFZ/rustc_testrunner_tmpdir_reporting.xWsyd1fPpEDo/mvce.rs:17:1: 17:29>::foo`
#2 [check_unsafety] unsafety-checking `<impl at /tmp/icemaker_global_tempdir.FLH6GcVf8ZFZ/rustc_testrunner_tmpdir_reporting.xWsyd1fPpEDo/mvce.rs:17:1: 17:29>::foo`
#3 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 3 previous errors

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

@rustbot label +F-fn_delegation

@matthiaskrgr matthiaskrgr 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 Apr 8, 2025
@rustbot rustbot added needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. F-fn_delegation `#![feature(fn_delegation)]` labels Apr 8, 2025
@matthiaskrgr
Copy link
Member Author

smaller

mod a{
    fn b<c, d>(e : c, f : d) {}
}
trait g {
	reuse a::b {}
}

@fmease fmease removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Apr 8, 2025
@matthiaskrgr
Copy link
Member Author

bisects to #139035 it seems cc @nnethercote

nnethercote added a commit to nnethercote/rust that referenced this issue Apr 10, 2025
@nnethercote nnethercote self-assigned this Apr 10, 2025
@bors bors closed this as completed in 9bb1008 Apr 10, 2025
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-fn_delegation `#![feature(fn_delegation)]` 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

No branches or pull requests

4 participants