Skip to content

ICE: index out of bounds in rustc_codegen_ssa #125474

Closed

Description

@parasyte

Code

Minimal repro: https://github.com/parasyte/crashy

Meta

This is the first nightly that the ICE appears in. (Does not appear to affect 2024-05-22 or earlier.)

rustc --version --verbose:

rustc 1.80.0-nightly (867900499 2024-05-23)
binary: rustc
commit-hash: 8679004993f08807289911d9f400f4ac4391d2bc
commit-date: 2024-05-23
host: aarch64-apple-darwin
release: 1.80.0-nightly
LLVM version: 18.1.6

Error output

Backtrace

thread 'rustc' panicked at compiler/rustc_codegen_ssa/src/back/link.rs:2700:27:
index out of bounds: the len is 20 but the index is 20
stack backtrace:
   0:        0x102e97260 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hfa1323da475f800d
   1:        0x102ed9d14 - core::fmt::write::heaa8abb186c3047d
   2:        0x102e8d65c - std::io::Write::write_fmt::h3d08850e35aab4bf
   3:        0x102e970b8 - std::sys_common::backtrace::print::h4df82b4992ac1fc1
   4:        0x102e996c0 - std::panicking::default_hook::{{closure}}::h7ff64b2e0b9b22e2
   5:        0x102e9938c - std::panicking::default_hook::h22468db7cd0b8309
   6:        0x10c779e74 - <alloc[b3d7b17f3254a7e4]::boxed::Box<rustc_driver_impl[d78fc4912d252757]::install_ice_hook::{closure#0}> as core[7a0d7fb87c17620e]::ops::function::Fn<(&dyn for<'a, 'b> core[7a0d7fb87c17620e]::ops::function::Fn<(&'a core[7a0d7fb87c17620e]::panic::panic_info::PanicInfo<'b>,), Output = ()> + core[7a0d7fb87c17620e]::marker::Sync + core[7a0d7fb87c17620e]::marker::Send, &core[7a0d7fb87c17620e]::panic::panic_info::PanicInfo)>>::call
   7:        0x102e9a0ac - std::panicking::rust_panic_with_hook::h7f81e6b48edd822e
   8:        0x102e99ac0 - std::panicking::begin_panic_handler::{{closure}}::h61dc216c734bb31b
   9:        0x102e976e4 - std::sys_common::backtrace::__rust_end_short_backtrace::h14d37ee99da8f514
  10:        0x102e99830 - _rust_begin_unwind
  11:        0x102ef5608 - core::panicking::panic_fmt::h879022f43970f0ca
  12:        0x102ef5768 - core::panicking::panic_bounds_check::habf076b85f30241b
  13:        0x10c4d5efc - rustc_codegen_ssa[6b173b5bf0f2b0be]::back::link::linker_with_args
  14:        0x10c4cccac - rustc_codegen_ssa[6b173b5bf0f2b0be]::back::link::link_natively
  15:        0x10c4c8e70 - rustc_codegen_ssa[6b173b5bf0f2b0be]::back::link::link_binary
  16:        0x10c3da0e0 - <rustc_codegen_llvm[21fd93a69a5e3bd5]::LlvmCodegenBackend as rustc_codegen_ssa[6b173b5bf0f2b0be]::traits::backend::CodegenBackend>::link
  17:        0x10cf170a8 - <rustc_interface[9b74dd81a584a30b]::queries::Linker>::link
  18:        0x10c76cca4 - rustc_span[16eba1eb411798eb]::create_session_globals_then::<core[7a0d7fb87c17620e]::result::Result<(), rustc_span[16eba1eb411798eb]::ErrorGuaranteed>, rustc_interface[9b74dd81a584a30b]::util::run_in_thread_with_globals<rustc_interface[9b74dd81a584a30b]::util::run_in_thread_pool_with_globals<rustc_interface[9b74dd81a584a30b]::interface::run_compiler<core[7a0d7fb87c17620e]::result::Result<(), rustc_span[16eba1eb411798eb]::ErrorGuaranteed>, rustc_driver_impl[d78fc4912d252757]::run_compiler::{closure#0}>::{closure#1}, core[7a0d7fb87c17620e]::result::Result<(), rustc_span[16eba1eb411798eb]::ErrorGuaranteed>>::{closure#0}, core[7a0d7fb87c17620e]::result::Result<(), rustc_span[16eba1eb411798eb]::ErrorGuaranteed>>::{closure#0}::{closure#0}::{closure#0}>
  19:        0x10c73a9c8 - std[c992710344e8eb3f]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[9b74dd81a584a30b]::util::run_in_thread_with_globals<rustc_interface[9b74dd81a584a30b]::util::run_in_thread_pool_with_globals<rustc_interface[9b74dd81a584a30b]::interface::run_compiler<core[7a0d7fb87c17620e]::result::Result<(), rustc_span[16eba1eb411798eb]::ErrorGuaranteed>, rustc_driver_impl[d78fc4912d252757]::run_compiler::{closure#0}>::{closure#1}, core[7a0d7fb87c17620e]::result::Result<(), rustc_span[16eba1eb411798eb]::ErrorGuaranteed>>::{closure#0}, core[7a0d7fb87c17620e]::result::Result<(), rustc_span[16eba1eb411798eb]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[7a0d7fb87c17620e]::result::Result<(), rustc_span[16eba1eb411798eb]::ErrorGuaranteed>>
  20:        0x10c706024 - <<std[c992710344e8eb3f]::thread::Builder>::spawn_unchecked_<rustc_interface[9b74dd81a584a30b]::util::run_in_thread_with_globals<rustc_interface[9b74dd81a584a30b]::util::run_in_thread_pool_with_globals<rustc_interface[9b74dd81a584a30b]::interface::run_compiler<core[7a0d7fb87c17620e]::result::Result<(), rustc_span[16eba1eb411798eb]::ErrorGuaranteed>, rustc_driver_impl[d78fc4912d252757]::run_compiler::{closure#0}>::{closure#1}, core[7a0d7fb87c17620e]::result::Result<(), rustc_span[16eba1eb411798eb]::ErrorGuaranteed>>::{closure#0}, core[7a0d7fb87c17620e]::result::Result<(), rustc_span[16eba1eb411798eb]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[7a0d7fb87c17620e]::result::Result<(), rustc_span[16eba1eb411798eb]::ErrorGuaranteed>>::{closure#2} as core[7a0d7fb87c17620e]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  21:        0x102ea2a04 - std::sys::pal::unix::thread::Thread::new::thread_start::h020974cd53976785
  22:        0x195abaf94 - __pthread_joiner_wake

Activity

  1. added
    C-bugCategory: This is a bug.
    I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    on May 24, 2024
  2. added
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on May 24, 2024
  3. lqd commented on May 24, 2024

    @lqd
    Member

    This looks to be from #124976 cc @petrochenkov

  4. removed
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on May 24, 2024
  5. justsmth commented on May 24, 2024

    @justsmth

    I believe this is the same failure I'm seeing on nightly: https://github.com/aws/aws-lc-rs/actions/runs/9225266351/job/25382407173?pr=410#step:5:127

    Details
    thread 'rustc' panicked at compiler/rustc_codegen_ssa/src/back/link.rs:2700:27:
    index out of bounds: the len is 34 but the index is 34
    stack backtrace:
       0: rust_begin_unwind
                 at /rustc/8679004993f08807289911d9f400f4ac4391d2bc/library/std/src/panicking.rs:652:5
       1: core::panicking::panic_fmt
                 at /rustc/8679004993f08807289911d9f400f4ac4391d2bc/library/core/src/panicking.rs:72:14
       2: core::panicking::panic_bounds_check
                 at /rustc/8679004993f08807289911d9f400f4ac4391d2bc/library/core/src/panicking.rs:274:5
       3: rustc_codegen_ssa::back::link::linker_with_args
       4: rustc_codegen_ssa::back::link::link_natively
       5: rustc_codegen_ssa::back::link::link_binary
       6: <rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_ssa::traits::backend::CodegenBackend>::link
       7: <rustc_interface::queries::Linker>::link
       8: rustc_interface::interface::run_compiler::<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}
    note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
    
    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: please attach the file at `/home/runner/work/aws-lc-rs/aws-lc-rs/rustc-ice-2024-05-24T14_08_10-3884.txt` to your bug report
    
    note: compiler flags: -C embed-bitcode=no -C debuginfo=2 -Z sanitizer=address
    
    note: some of the compiler flags provided by cargo are hidden
    
    query stack during panic:
    end of query stack
    error: could not compile `aws-lc-rs` (lib test)
    

    This occurred in our CI, but I can attempt to reproduce locally to provide more details if needed.

  6. lqd commented on May 24, 2024

    @lqd
    Member

    I have a local fix but haven't yet managed to make a unit test out of the repros, making hard to ensure it won't regress.

  7. PickLL commented on May 25, 2024

    @PickLL

    I think I'm getting this too, if it's different I can make a new issue

    Details

    thread 'rustc' panicked at compiler/rustc_codegen_ssa/src/back/link.rs:2700:27:
    index out of bounds: the len is 197 but the index is 197
    stack backtrace:
       0:     0x729a9f383a15 - std::backtrace_rs::backtrace::libunwind::trace::h9fff41df29930226
                                   at /rustc/36153f1a4e3162f0a143c7b3e468ecb3beb0008e/library/std/src/../../backtrace/src/backtrace/libunwind.rs:105:5
       1:     0x729a9f383a15 - std::backtrace_rs::backtrace::trace_unsynchronized::hd333ee9fabe37696
                                   at /rustc/36153f1a4e3162f0a143c7b3e468ecb3beb0008e/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
       2:     0x729a9f383a15 - std::sys_common::backtrace::_print_fmt::ha8cea204a14d4b05
                                   at /rustc/36153f1a4e3162f0a143c7b3e468ecb3beb0008e/library/std/src/sys_common/backtrace.rs:68:5
       3:     0x729a9f383a15 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h23b6b3b597037ccc
                                   at /rustc/36153f1a4e3162f0a143c7b3e468ecb3beb0008e/library/std/src/sys_common/backtrace.rs:44:22
       4:     0x729a9f3d2aeb - core::fmt::rt::Argument::fmt::h108a26a03f438748
                                   at /rustc/36153f1a4e3162f0a143c7b3e468ecb3beb0008e/library/core/src/fmt/rt.rs:165:63
       5:     0x729a9f3d2aeb - core::fmt::write::h04064cb45a345462
                                   at /rustc/36153f1a4e3162f0a143c7b3e468ecb3beb0008e/library/core/src/fmt/mod.rs:1172:21
       6:     0x729a9f37881f - std::io::Write::write_fmt::h222f9a473033d72e
                                   at /rustc/36153f1a4e3162f0a143c7b3e468ecb3beb0008e/library/std/src/io/mod.rs:1835:15
       7:     0x729a9f3837ee - std::sys_common::backtrace::_print::h0d72338fa5455ac9
                                   at /rustc/36153f1a4e3162f0a143c7b3e468ecb3beb0008e/library/std/src/sys_common/backtrace.rs:47:5
       8:     0x729a9f3837ee - std::sys_common::backtrace::print::he02582a61c39a81d
                                   at /rustc/36153f1a4e3162f0a143c7b3e468ecb3beb0008e/library/std/src/sys_common/backtrace.rs:34:9
       9:     0x729a9f386219 - std::panicking::default_hook::{{closure}}::h93f8f6e01b4e4fd9
      10:     0x729a9f385fba - std::panicking::default_hook::hbc1b8395cdf679f0
                                   at /rustc/36153f1a4e3162f0a143c7b3e468ecb3beb0008e/library/std/src/panicking.rs:298:9
      11:     0x729a9bcf6ca0 - std[cc47417a42f879a6]::panicking::update_hook::<alloc[df7394d838fa0811]::boxed::Box<rustc_driver_impl[cc9fecfd491acb62]::install_ice_hook::{closure#0}>>::{closure#0}
      12:     0x729a9f38694b - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h79ea62f4492f4aab
                                   at /rustc/36153f1a4e3162f0a143c7b3e468ecb3beb0008e/library/alloc/src/boxed.rs:2077:9
      13:     0x729a9f38694b - std::panicking::rust_panic_with_hook::h2d3b3b5d41eafa75
                                   at /rustc/36153f1a4e3162f0a143c7b3e468ecb3beb0008e/library/std/src/panicking.rs:799:13
      14:     0x729a9f3866c4 - std::panicking::begin_panic_handler::{{closure}}::hc78e06bc8800937b
                                   at /rustc/36153f1a4e3162f0a143c7b3e468ecb3beb0008e/library/std/src/panicking.rs:664:13
      15:     0x729a9f383ed9 - std::sys_common::backtrace::__rust_end_short_backtrace::h10081666adae5ac0
                                   at /rustc/36153f1a4e3162f0a143c7b3e468ecb3beb0008e/library/std/src/sys_common/backtrace.rs:171:18
      16:     0x729a9f3863f7 - rust_begin_unwind
                                   at /rustc/36153f1a4e3162f0a143c7b3e468ecb3beb0008e/library/std/src/panicking.rs:652:5
      17:     0x729a9f3cf0b3 - core::panicking::panic_fmt::he2bec51da94b7c97
                                   at /rustc/36153f1a4e3162f0a143c7b3e468ecb3beb0008e/library/core/src/panicking.rs:72:14
      18:     0x729a9f3cf2d7 - core::panicking::panic_bounds_check::hb4329ed58f0884b5
                                   at /rustc/36153f1a4e3162f0a143c7b3e468ecb3beb0008e/library/core/src/panicking.rs:274:5
      19:     0x729a9de26bce - rustc_codegen_ssa[761b6f74a49dce2a]::back::link::linker_with_args
      20:     0x729a9de1b49e - rustc_codegen_ssa[761b6f74a49dce2a]::back::link::link_natively
      21:     0x729a9de3f28f - rustc_codegen_ssa[761b6f74a49dce2a]::back::link::link_binary
      22:     0x729a9de3e7a2 - <rustc_codegen_llvm[7475ce1e9176645d]::LlvmCodegenBackend as rustc_codegen_ssa[761b6f74a49dce2a]::traits::backend::CodegenBackend>::link
      23:     0x729a9de41fe4 - <rustc_interface[5237f8c382850565]::queries::Linker>::link
      24:     0x729a9dbab2a9 - rustc_interface[5237f8c382850565]::interface::run_compiler::<core[f15517118b5ac71d]::result::Result<(), rustc_span[c5bccc19da2c0bb2]::ErrorGuaranteed>, rustc_driver_impl[cc9fecfd491acb62]::run_compiler::{closure#0}>::{closure#1}
      25:     0x729a9db96b27 - std[cc47417a42f879a6]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[5237f8c382850565]::util::run_in_thread_with_globals<rustc_interface[5237f8c382850565]::util::run_in_thread_pool_with_globals<rustc_interface[5237f8c382850565]::interface::run_compiler<core[f15517118b5ac71d]::result::Result<(), rustc_span[c5bccc19da2c0bb2]::ErrorGuaranteed>, rustc_driver_impl[cc9fecfd491acb62]::run_compiler::{closure#0}>::{closure#1}, core[f15517118b5ac71d]::result::Result<(), rustc_span[c5bccc19da2c0bb2]::ErrorGuaranteed>>::{closure#0}, core[f15517118b5ac71d]::result::Result<(), rustc_span[c5bccc19da2c0bb2]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[f15517118b5ac71d]::result::Result<(), rustc_span[c5bccc19da2c0bb2]::ErrorGuaranteed>>
      26:     0x729a9db968ea - <<std[cc47417a42f879a6]::thread::Builder>::spawn_unchecked_<rustc_interface[5237f8c382850565]::util::run_in_thread_with_globals<rustc_interface[5237f8c382850565]::util::run_in_thread_pool_with_globals<rustc_interface[5237f8c382850565]::interface::run_compiler<core[f15517118b5ac71d]::result::Result<(), rustc_span[c5bccc19da2c0bb2]::ErrorGuaranteed>, rustc_driver_impl[cc9fecfd491acb62]::run_compiler::{closure#0}>::{closure#1}, core[f15517118b5ac71d]::result::Result<(), rustc_span[c5bccc19da2c0bb2]::ErrorGuaranteed>>::{closure#0}, core[f15517118b5ac71d]::result::Result<(), rustc_span[c5bccc19da2c0bb2]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[f15517118b5ac71d]::result::Result<(), rustc_span[c5bccc19da2c0bb2]::ErrorGuaranteed>>::{closure#2} as core[f15517118b5ac71d]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
      27:     0x729a9f39072b - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hde1d5bf43c23e9b6
                                   at /rustc/36153f1a4e3162f0a143c7b3e468ecb3beb0008e/library/alloc/src/boxed.rs:2063:9
      28:     0x729a9f39072b - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hd62d46857b01b0f7
                                   at /rustc/36153f1a4e3162f0a143c7b3e468ecb3beb0008e/library/alloc/src/boxed.rs:2063:9
      29:     0x729a9f39072b - std::sys::pal::unix::thread::Thread::new::thread_start::hffa103f3e3af41f3
                                   at /rustc/36153f1a4e3162f0a143c7b3e468ecb3beb0008e/library/std/src/sys/pal/unix/thread.rs:108:17
      30:     0x729a9f12fded - <unknown>
      31:     0x729a9f1b30dc - <unknown>
      32:                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: please attach the file at `/home/pickl/rust/ice/rustc-ice-2024-05-25T20_37_11-175362.txt` to your bug report
    
    note: compiler flags: --crate-type bin -C embed-bitcode=no -C debuginfo=2 -C incremental=[REDACTED] -C target-cpu=native
    
    note: some of the compiler flags provided by cargo are hidden
    
    query stack during panic:
    end of query stack
    

    rustc --version --verbose:

    rustc 1.80.0-nightly (36153f1a4 2024-05-24)
    binary: rustc
    commit-hash: 36153f1a4e3162f0a143c7b3e468ecb3beb0008e
    commit-date: 2024-05-24
    host: x86_64-unknown-linux-gnu
    release: 1.80.0-nightly
    LLVM version: 18.1.6
    

  8. bend-n commented on May 26, 2024

    @bend-n
    Contributor

    Care to explain why it happens?

  9. PickLL commented on May 26, 2024

    @PickLL

    In my case, having a re-export with different version than the one in Cargo.toml.
    Specifically egui and eframe, but I don't believe it's anything to do with them, or the specific struct.

    use eframe::egui;
    
    fn main() {
        egui::Key::A;
    }
    

    this is the Cargo.toml:

    [package]
    name = "ice"
    version = "0.1.0"
    edition = "2021"
    
    [dependencies]
    eframe = "0.27"
    egui = "0.26"
    
  10. apiraino commented on May 28, 2024

    @apiraino
    Contributor

    This is a regression that I think does not yet show up on beta (IIUC). In two weeks it will.

    Let's keep in mind the fix from @lqd in #125493 (thanks!)

    @rustbot label -I-prioritize +P-high

  11. added a commit that references this issue on Jun 6, 2024
  12. added a commit that references this issue on Jun 6, 2024
  13. added a commit that references this issue on Jun 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️P-highHigh priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions