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: 'index out of bounds: the len is 1 but the index is 1' with Cdebuginfo=2 #105263

Open
matthiaskrgr opened this issue Dec 4, 2022 · 6 comments
Labels
A-debuginfo Area: Debugging information in compiled programs (DWARF, PDB, etc.) 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.

Comments

@matthiaskrgr
Copy link
Member

Code

code from official tests: ./src/test/ui/mir/ssa-analysis-regression-50041.rs

// build-pass
// compile-flags: -Z mir-opt-level=4

#![crate_type = "lib"]
#![feature(lang_items)]
#![no_std]

struct NonNull<T: ?Sized>(*const T);

struct Unique<T: ?Sized>(NonNull<T>);

#[lang = "owned_box"]
pub struct Box<T: ?Sized>(Unique<T>);

impl<T: ?Sized> Drop for Box<T> {
    fn drop(&mut self) {}
}

#[lang = "box_free"]
#[inline(always)]
unsafe fn box_free<T: ?Sized>(ptr: Unique<T>) {
    dealloc(ptr.0.0)
}

#[inline(never)]
fn dealloc<T: ?Sized>(_: *const T) {}

pub struct Foo<T>(T);

pub fn foo(a: Option<Box<Foo<usize>>>) -> usize {
    let f = match a {
        None => Foo(0),
        Some(vec) => *vec,
    };
    f.0
}

Meta

rustc --version --verbose:

rustc 1.67.0-nightly (234151769 2022-12-03)
binary: rustc
commit-hash: 23415176968e81e0aac92d0218612a89c4e68a82
commit-date: 2022-12-03
host: x86_64-unknown-linux-gnu
release: 1.67.0-nightly
LLVM version: 15.0.4

Error output

rustc ./src/test/ui/mir/ssa-analysis-regression-50041.rs -Cdebuginfo=2

<output>
Backtrace

thread '<unnamed>' panicked at 'index out of bounds: the len is 1 but the index is 1', /rustc/23415176968e81e0aac92d0218612a89c4e68a82/compiler/rustc_middle/src/ty/subst.rs:387:43
stack backtrace:
   0:     0x7f8d8936625a - std::backtrace_rs::backtrace::libunwind::trace::h39c51bcedb139b44
                               at /rustc/23415176968e81e0aac92d0218612a89c4e68a82/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7f8d8936625a - std::backtrace_rs::backtrace::trace_unsynchronized::h9cf890f6f509d0c3
                               at /rustc/23415176968e81e0aac92d0218612a89c4e68a82/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f8d8936625a - std::sys_common::backtrace::_print_fmt::h4a0d7673c4689a86
                               at /rustc/23415176968e81e0aac92d0218612a89c4e68a82/library/std/src/sys_common/backtrace.rs:65:5
   3:     0x7f8d8936625a - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hed99d8097fd95926
                               at /rustc/23415176968e81e0aac92d0218612a89c4e68a82/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7f8d893c8e4e - core::fmt::write::hdab16ae0136a16af
                               at /rustc/23415176968e81e0aac92d0218612a89c4e68a82/library/core/src/fmt/mod.rs:1208:17
   5:     0x7f8d89356675 - std::io::Write::write_fmt::h9619f0289bf5af21
                               at /rustc/23415176968e81e0aac92d0218612a89c4e68a82/library/std/src/io/mod.rs:1682:15
   6:     0x7f8d89366025 - std::sys_common::backtrace::_print::h2fbe09348ca97657
                               at /rustc/23415176968e81e0aac92d0218612a89c4e68a82/library/std/src/sys_common/backtrace.rs:47:5
   7:     0x7f8d89366025 - std::sys_common::backtrace::print::h72058f5ceb813403
                               at /rustc/23415176968e81e0aac92d0218612a89c4e68a82/library/std/src/sys_common/backtrace.rs:34:9
   8:     0x7f8d89368d6f - std::panicking::default_hook::{{closure}}::h1542b395e584376b
                               at /rustc/23415176968e81e0aac92d0218612a89c4e68a82/library/std/src/panicking.rs:267:22
   9:     0x7f8d89368aab - std::panicking::default_hook::hf92492522bb6bc51
                               at /rustc/23415176968e81e0aac92d0218612a89c4e68a82/library/std/src/panicking.rs:286:9
  10:     0x7f8d8936958c - std::panicking::rust_panic_with_hook::h8e3ba576266d6126
                               at /rustc/23415176968e81e0aac92d0218612a89c4e68a82/library/std/src/panicking.rs:688:13
  11:     0x7f8d89369329 - std::panicking::begin_panic_handler::{{closure}}::h5718d689762256a1
                               at /rustc/23415176968e81e0aac92d0218612a89c4e68a82/library/std/src/panicking.rs:579:13
  12:     0x7f8d8936670c - std::sys_common::backtrace::__rust_end_short_backtrace::hb4469c61f2390e29
                               at /rustc/23415176968e81e0aac92d0218612a89c4e68a82/library/std/src/sys_common/backtrace.rs:137:18
  13:     0x7f8d89369032 - rust_begin_unwind
                               at /rustc/23415176968e81e0aac92d0218612a89c4e68a82/library/std/src/panicking.rs:575:5
  14:     0x7f8d893c5863 - core::panicking::panic_fmt::h4dafe9d2577d7060
                               at /rustc/23415176968e81e0aac92d0218612a89c4e68a82/library/core/src/panicking.rs:64:14
  15:     0x7f8d893c5a32 - core::panicking::panic_bounds_check::hf370cb7cb7f7e64d
                               at /rustc/23415176968e81e0aac92d0218612a89c4e68a82/library/core/src/panicking.rs:147:5
  16:     0x7f8d8ad7cbd6 - rustc_codegen_llvm[503052878b417ad6]::debuginfo::metadata::type_di_node
  17:     0x7f8d8ad98d44 - <smallvec[70a3a4fd81953d85]::SmallVec<[&rustc_codegen_llvm[503052878b417ad6]::llvm_::ffi::Metadata; 16usize]> as core[ec9ef0a26f3cf28]::iter::traits::collect::Extend<&rustc_codegen_llvm[503052878b417ad6]::llvm_::ffi::Metadata>>::extend::<core[ec9ef0a26f3cf28]::iter::adapters::filter_map::FilterMap<core[ec9ef0a26f3cf28]::iter::adapters::zip::Zip<core[ec9ef0a26f3cf28]::iter::adapters::copied::Copied<core[ec9ef0a26f3cf28]::slice::iter::Iter<rustc_middle[eef20b0c23bc8b9b]::ty::subst::GenericArg>>, alloc[c9a67e0c95f99b51]::vec::into_iter::IntoIter<rustc_span[653636119034ca50]::symbol::Symbol>>, rustc_codegen_llvm[503052878b417ad6]::debuginfo::metadata::build_generic_type_param_di_nodes::{closure#0}>>
  18:     0x7f8d8ad80050 - rustc_codegen_llvm[503052878b417ad6]::debuginfo::metadata::build_generic_type_param_di_nodes
  19:     0x7f8d8ad8d6b5 - rustc_codegen_llvm[503052878b417ad6]::debuginfo::metadata::type_map::build_type_with_children::<rustc_codegen_llvm[503052878b417ad6]::debuginfo::metadata::enums::build_enum_variant_struct_type_di_node::{closure#0}, rustc_codegen_llvm[503052878b417ad6]::debuginfo::metadata::enums::build_enum_variant_struct_type_di_node::{closure#1}>
  20:     0x7f8d8ad8a297 - <smallvec[70a3a4fd81953d85]::SmallVec<[rustc_codegen_llvm[503052878b417ad6]::debuginfo::metadata::enums::native::VariantMemberInfo; 16usize]> as core[ec9ef0a26f3cf28]::iter::traits::collect::Extend<rustc_codegen_llvm[503052878b417ad6]::debuginfo::metadata::enums::native::VariantMemberInfo>>::extend::<core[ec9ef0a26f3cf28]::iter::adapters::map::Map<core[ec9ef0a26f3cf28]::ops::range::Range<rustc_target[b6f44fa0a8656faf]::abi::VariantIdx>, rustc_codegen_llvm[503052878b417ad6]::debuginfo::metadata::enums::native::build_enum_type_di_node::{closure#0}::{closure#0}>>
  21:     0x7f8d8ad88eb9 - rustc_codegen_llvm[503052878b417ad6]::debuginfo::metadata::type_map::build_type_with_children::<rustc_codegen_llvm[503052878b417ad6]::debuginfo::metadata::enums::native::build_enum_type_di_node::{closure#0}, for<'a, 'b, 'c> fn(&'a rustc_codegen_llvm[503052878b417ad6]::context::CodegenCx<'b, 'c>) -> smallvec[70a3a4fd81953d85]::SmallVec<[&'b rustc_codegen_llvm[503052878b417ad6]::llvm_::ffi::Metadata; 16usize]>>
  22:     0x7f8d8ad8565d - rustc_codegen_llvm[503052878b417ad6]::debuginfo::metadata::enums::native::build_enum_type_di_node
  23:     0x7f8d8ad84ccf - rustc_codegen_llvm[503052878b417ad6]::debuginfo::metadata::enums::build_enum_type_di_node
  24:     0x7f8d8ad7a634 - rustc_codegen_llvm[503052878b417ad6]::debuginfo::metadata::type_di_node
  25:     0x7f8d8ad762f4 - <rustc_codegen_llvm[503052878b417ad6]::context::CodegenCx as rustc_codegen_ssa[6d1b86094529188b]::traits::debuginfo::DebugInfoMethods>::dbg_scope_fn
  26:     0x7f8d8a7af911 - rustc_codegen_ssa[6d1b86094529188b]::mir::codegen_mir::<rustc_codegen_llvm[503052878b417ad6]::builder::Builder>
  27:     0x7f8d8aed58d1 - rustc_codegen_llvm[503052878b417ad6]::base::compile_codegen_unit::module_codegen
  28:     0x7f8d8bd702a3 - <rustc_query_system[c6fc551e4ef2763b]::dep_graph::graph::DepGraph<rustc_middle[eef20b0c23bc8b9b]::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle[eef20b0c23bc8b9b]::ty::context::TyCtxt, rustc_span[653636119034ca50]::symbol::Symbol, rustc_codegen_ssa[6d1b86094529188b]::ModuleCodegen<rustc_codegen_llvm[503052878b417ad6]::ModuleLlvm>>
  29:     0x7f8d8bd6ffba - rustc_codegen_llvm[503052878b417ad6]::base::compile_codegen_unit
  30:     0x7f8d8bb34cee - rustc_codegen_ssa[6d1b86094529188b]::base::codegen_crate::<rustc_codegen_llvm[503052878b417ad6]::LlvmCodegenBackend>
  31:     0x7f8d8bb3448e - <rustc_codegen_llvm[503052878b417ad6]::LlvmCodegenBackend as rustc_codegen_ssa[6d1b86094529188b]::traits::backend::CodegenBackend>::codegen_crate
  32:     0x7f8d8b84bdd1 - <rustc_session[87f0d63408877899]::session::Session>::time::<alloc[c9a67e0c95f99b51]::boxed::Box<dyn core[ec9ef0a26f3cf28]::any::Any>, rustc_interface[c57545daadc3fa09]::passes::start_codegen::{closure#0}>
  33:     0x7f8d8b84b8c5 - rustc_interface[c57545daadc3fa09]::passes::start_codegen
  34:     0x7f8d8b846fad - <rustc_interface[c57545daadc3fa09]::passes::QueryContext>::enter::<<rustc_interface[c57545daadc3fa09]::queries::Queries>::ongoing_codegen::{closure#0}::{closure#0}, core[ec9ef0a26f3cf28]::result::Result<alloc[c9a67e0c95f99b51]::boxed::Box<dyn core[ec9ef0a26f3cf28]::any::Any>, rustc_errors[57b9e96b8e7428c]::ErrorGuaranteed>>
  35:     0x7f8d8b8447c4 - <rustc_interface[c57545daadc3fa09]::queries::Queries>::ongoing_codegen
  36:     0x7f8d8b843991 - <rustc_interface[c57545daadc3fa09]::interface::Compiler>::enter::<rustc_driver[d87acf87108c2deb]::run_compiler::{closure#1}::{closure#2}, core[ec9ef0a26f3cf28]::result::Result<core[ec9ef0a26f3cf28]::option::Option<rustc_interface[c57545daadc3fa09]::queries::Linker>, rustc_errors[57b9e96b8e7428c]::ErrorGuaranteed>>
  37:     0x7f8d8b83e978 - rustc_span[653636119034ca50]::with_source_map::<core[ec9ef0a26f3cf28]::result::Result<(), rustc_errors[57b9e96b8e7428c]::ErrorGuaranteed>, rustc_interface[c57545daadc3fa09]::interface::run_compiler<core[ec9ef0a26f3cf28]::result::Result<(), rustc_errors[57b9e96b8e7428c]::ErrorGuaranteed>, rustc_driver[d87acf87108c2deb]::run_compiler::{closure#1}>::{closure#0}::{closure#0}>
  38:     0x7f8d8b83e465 - <scoped_tls[2510ce566f7fd87d]::ScopedKey<rustc_span[653636119034ca50]::SessionGlobals>>::set::<rustc_interface[c57545daadc3fa09]::interface::run_compiler<core[ec9ef0a26f3cf28]::result::Result<(), rustc_errors[57b9e96b8e7428c]::ErrorGuaranteed>, rustc_driver[d87acf87108c2deb]::run_compiler::{closure#1}>::{closure#0}, core[ec9ef0a26f3cf28]::result::Result<(), rustc_errors[57b9e96b8e7428c]::ErrorGuaranteed>>
  39:     0x7f8d8b83da52 - std[b988c8daa9554a2a]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[c57545daadc3fa09]::util::run_in_thread_pool_with_globals<rustc_interface[c57545daadc3fa09]::interface::run_compiler<core[ec9ef0a26f3cf28]::result::Result<(), rustc_errors[57b9e96b8e7428c]::ErrorGuaranteed>, rustc_driver[d87acf87108c2deb]::run_compiler::{closure#1}>::{closure#0}, core[ec9ef0a26f3cf28]::result::Result<(), rustc_errors[57b9e96b8e7428c]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[ec9ef0a26f3cf28]::result::Result<(), rustc_errors[57b9e96b8e7428c]::ErrorGuaranteed>>
  40:     0x7f8d8bfa6848 - <<std[b988c8daa9554a2a]::thread::Builder>::spawn_unchecked_<rustc_interface[c57545daadc3fa09]::util::run_in_thread_pool_with_globals<rustc_interface[c57545daadc3fa09]::interface::run_compiler<core[ec9ef0a26f3cf28]::result::Result<(), rustc_errors[57b9e96b8e7428c]::ErrorGuaranteed>, rustc_driver[d87acf87108c2deb]::run_compiler::{closure#1}>::{closure#0}, core[ec9ef0a26f3cf28]::result::Result<(), rustc_errors[57b9e96b8e7428c]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[ec9ef0a26f3cf28]::result::Result<(), rustc_errors[57b9e96b8e7428c]::ErrorGuaranteed>>::{closure#1} as core[ec9ef0a26f3cf28]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  41:     0x7f8d8d4b07f3 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hd24e4095bea58fc3
                               at /rustc/23415176968e81e0aac92d0218612a89c4e68a82/library/alloc/src/boxed.rs:2000:9
  42:     0x7f8d8d4b07f3 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h7c7f47af88aff778
                               at /rustc/23415176968e81e0aac92d0218612a89c4e68a82/library/alloc/src/boxed.rs:2000:9
  43:     0x7f8d8d4b07f3 - std::sys::unix::thread::Thread::new::thread_start::h8d5de08b8b3f2cac
                               at /rustc/23415176968e81e0aac92d0218612a89c4e68a82/library/std/src/sys/unix/thread.rs:108:17
  44:     0x7f8d890cc8fd - <unknown>
  45:     0x7f8d8914ea60 - <unknown>
  46:                0x0 - <unknown>

@matthiaskrgr matthiaskrgr added A-debuginfo Area: Debugging information in compiled programs (DWARF, PDB, etc.) 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 Dec 4, 2022
@matthiaskrgr
Copy link
Member Author

searched toolchains nightly-2022-03-05 through nightly-2022-12-04


Regression in nightly-2022-03-12


🤔

@matthiaskrgr
Copy link
Member Author

I wonder if this is #94728 cc @compiler-errors any ideas?

@compiler-errors
Copy link
Member

so this is because it's an invalid definition of Box -- not sure if we want to support no_core + custom Box impl w/ only a T and no allocator A

@matthiaskrgr
Copy link
Member Author

Since we have a test for this I would assume that this is expected to work? 😅

@compiler-errors
Copy link
Member

compiler-errors commented Dec 4, 2022

Well, this test wasn't modified after the allocator parameter was added to Box, so that's why. Not sure if it's intended to support this or not.

@matthiaskrgr
Copy link
Member Author

hmm.

The original ticket was about some mir inlining/llvm problem apparently #50041

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-debuginfo Area: Debugging information in compiled programs (DWARF, PDB, etc.) 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.
Projects
None yet
Development

No branches or pull requests

2 participants