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: rustc_abi the len is 0 but the index is 0 calculating offset #123917

Closed
matthiaskrgr opened this issue Apr 14, 2024 · 5 comments
Closed

ICE: rustc_abi the len is 0 but the index is 0 calculating offset #123917

matthiaskrgr opened this issue Apr 14, 2024 · 5 comments
Labels
-Zpolymorphize Unstable option: Polymorphization. A-ABI Area: Concerning the application binary interface (ABI) C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@matthiaskrgr
Copy link
Member

matthiaskrgr commented Apr 14, 2024

auto-reduced (treereduce-rust) + some manual reduction

use std::marker::PhantomData;

pub struct Id<'id>();

pub struct Item<'life, T> {
    data: T,
}

pub struct Token<'life, 'borrow, 'compact, 'reborrow, T>
where
    'life: 'reborrow,
    T: Tokenize,
{
    ptr: *mut <T as Tokenize>::Tokenized,
    ptr: core::ptr::NonNull<T::Tokenized>,
    _phantom: PhantomData<Id<'life>>,
}

impl<'life> Arena<'life> {
    pub fn tokenize<'before, 'compact, 'borrow, 'reborrow, T, U>(
        item: Item<'life, &'before mut T>,
    ) -> Token<'life, 'borrow, 'compact, 'reborrow, U>
    where
        T: Tokenize<'life, 'borrow, 'compact, 'reborrow, Untokenized = U>,
        T::Untokenized: Tokenize<'life, 'borrow, 'compact, 'reborrow>,
    {
        let dst = item.data as *mut T as *mut T::Tokenized;
        Token {
            ptr: core::ptr::NonNull::new(dst as *mut _).unwrap(),
            _phantom: PhantomData,
        }
    }
}

pub trait Tokenize {
    type Tokenized;
    type Untokenized;
}
original code

original:

//@ check-pass
#![feature(inline_const)]
#![feature(generic_const_exprs)]

#![allow(incomplete_features)]
use std::marker::PhantomData;

pub struct Equal<const T: usize, const R: usize>();
pub trait True {}
impl<const T: usize> True for Equal<T, T> {}

// replacement for generativity
pub struct Id<'id>(PhantomData<fn(&'id ()) -> &'id ()>);
pub struct Guard<'id>(Id<'id>);
fn make_guard<'id>(i: &'id Id<'id>) -> Guard<'id> {
    Guard(Id(PhantomData))
}

impl<'id> Into<Id<'id>> for Guard<'id> {
    fn into(self) -> Id<'id> {
        self.0
    }
}

pub struct Arena<'life> {
    bytes: *mut [u8],
    //bitmap: RefCell<RoaringBitmap>,
    _token: PhantomData<Id<'life>>,
}

#[repr(transparent)]
pub struct Item<'life, T> {
    data: T,
    _phantom: PhantomData<Id<'life>>,
}

#[repr(transparent)]
pub struct Token<'life, 'borrow, 'compact, 'reborrow, T>
where
    'life: 'reborrow,
    T: Tokenize<'life, 'borrow, 'compact, 'reborrow>,
{
    ptr: *mut <T as Tokenize>::Tokenized,
    ptr: core::ptr::NonNull<T::Tokenized>,
    _phantom: PhantomData<Id<'life>>,
    _compact: PhantomData<&'borrow Guard<'compact>>,
    _result: PhantomData<&'reborrow T::Untokenized>,
}

impl<'life> Arena<'life> {
    pub fn tokenize<'before, 'compact, 'borrow, 'reborrow, T, U>(
        &self,
        guard: &'borrow Guard<'compact>,
        item: Item<'life, &'before mut T>,
    ) -> Token<'life, 'borrow, 'compact, 'reborrow, U>
    where
        T: Tokenize<'life, 'borrow, 'compact, 'reborrow, Untokenized = U>,
        T::Untokenized: Tokenize<'life, 'borrow, 'compact, 'reborrow>,
        Equal<{ core::mem::size_of::<T>() }, { core::mem::size_of::<U>() }>: True,
        'compact: 'borrow,
        'life: 'reborrow,
        'life: 'compact,
        'life: 'borrow,
        // 'borrow: 'before ??
    {
        let dst = item.data as *mut T as *mut T::Tokenized;
        Token {
            ptr: core::ptr::NonNull::new(dst as *mut _).unwrap(),
            _phantom: PhantomData,
            _compact: PhantomData,
            _result: PhantomData,
        }
    }
}

pub trait Tokenize<'life, 'borrow, 'compact, 'reborrow>
where
    'compact: 'borrow,
    'life: 'reborrow,
    'life: 'borrow,
    'life: 'compact,
{
    type Tokenized;
    type Untokenized;
    const TO: fn(&Arena<'life>, &'borrow Guard<'compact>, Self) -> Self::Tokenized;
    const FROM: fn(&'reborrow Arena<'life>, Self::Tokenized) -> Self::Untokenized;
}

macro_rules! tokenize {
    ($to:expr, $from:expr) => {
        const TO: fn(&Arena<'life>, &'borrow Guard<'compact>, Self) -> Self::Tokenized = $to;
        const FROM: fn(&'reborrow Arena<'life>, Self::Tokenized) -> Self::Untokenized = $from;
    };
}

struct Foo<'life, 'borrow>(Option<Item<'life, &'borrow mut Bar>>);
struct UnitVariant<'life, 'borrow, 'compact, 'reborrow>(
    Option<Token<'life, 'borrow, 'compact, 'reborrow, Bar>>,
);
struct Bar(u8);

impl<'life, 'before, 'borrow, 'compact, 'reborrow> Tokenize<'life, 'borrow, 'compact, 'reborrow>
    for Foo<'life, 'before>
where
    'compact: 'borrow,
    'life: 'reborrow,
    'life: 'borrow,
    'life: 'compact,
{
    type Tokenized = TokenFoo<'life, 'borrow, 'compact, 'reborrow>;
    type Untokenized = Foo<'life, 'reborrow>;
    tokenize!(foo_to, foo_from);
}

impl<'life, 'borrow, 'compact, 'reborrow> Tokenize<'life, 'borrow, 'compact, 'reborrow> for Bar
where
    'compact: 'borrow,
    'life: 'reborrow,
    'life: 'borrow,
    'life: 'compact,
{
    type Tokenized = Bar;
    type Untokenized = Bar;
    tokenize!(bar_to, bar_from);
}

fn bar_to<'life, 'borrow, 'compact>(
    arena: &Arena<'life>,
    guard: &'borrow Guard<'compact>,
    s: Bar,
) -> Bar {
    s
}
fn bar_from<'life, 'reborrow>(arena: &'reborrow Arena<'life>, s: Bar) -> Bar {
    s
}

fn foo_to<'life, 'borrow, 'compact, 'reborrow, 'before>(
    arena: &'before Arena<'life>,
    guard: &'borrow Guard<'compact>,
    s: Foo<'life, 'before>,
) -> TokenFoo<'life, 'borrow, 'compact, 'reborrow> {
    let Foo(bar) = s;
    TokenFoo(bar.map(|bar| arena.tokenize(guard, bar)))
}
fn foo_from<'life, 'borrow, 'compact, 'reborrow>(
    arena: &'reborrow Arena<'life>,
    s: TokenFoo<'life, 'borrow, 'compact, 'reborrow>,
) -> Foo<'life, 'reborrow> {
    Foo(s.0.map(|bar| panic!()))
}

fn main() {}

Version information

rustc 1.79.0-nightly (f3c660886 2024-04-14)
binary: rustc
commit-hash: f3c66088610c1b80110297c2d9a8b5f9265b013f
commit-date: 2024-04-14
host: x86_64-unknown-linux-gnu
release: 1.79.0-nightly
LLVM version: 18.1.3

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc -Zmir-opt-level=5 -Zpolymorphize=on

Program output

error[E0412]: cannot find type `Arena` in this scope
  --> /tmp/icemaker_global_tempdir.iy1H39B5cCGu/rustc_testrunner_tmpdir_reporting.szJD7axysECi/mvce.rs:19:13
   |
19 | impl<'life> Arena<'life> {
   |             ^^^^^ not found in this scope

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

error[E0124]: field `ptr` is already declared
  --> /tmp/icemaker_global_tempdir.iy1H39B5cCGu/rustc_testrunner_tmpdir_reporting.szJD7axysECi/mvce.rs:15:5
   |
14 |     ptr: *mut <T as Tokenize>::Tokenized,
   |     ------------------------------------ `ptr` first declared here
15 |     ptr: core::ptr::NonNull<T::Tokenized>,
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ field already declared

error[E0392]: lifetime parameter `'id` is never used
 --> /tmp/icemaker_global_tempdir.iy1H39B5cCGu/rustc_testrunner_tmpdir_reporting.szJD7axysECi/mvce.rs:3:15
  |
3 | pub struct Id<'id>();
  |               ^^^ unused lifetime parameter
  |
  = help: consider removing `'id`, referring to it in a field, or using a marker such as `PhantomData`

error[E0392]: lifetime parameter `'life` is never used
 --> /tmp/icemaker_global_tempdir.iy1H39B5cCGu/rustc_testrunner_tmpdir_reporting.szJD7axysECi/mvce.rs:5:17
  |
5 | pub struct Item<'life, T> {
  |                 ^^^^^ unused lifetime parameter
  |
  = help: consider removing `'life`, referring to it in a field, or using a marker such as `PhantomData`

error[E0392]: lifetime parameter `'life` is never used
 --> /tmp/icemaker_global_tempdir.iy1H39B5cCGu/rustc_testrunner_tmpdir_reporting.szJD7axysECi/mvce.rs:9:18
  |
9 | pub struct Token<'life, 'borrow, 'compact, 'reborrow, T>
  |                  ^^^^^ unused lifetime parameter
  |
  = help: consider removing `'life`, referring to it in a field, or using a marker such as `PhantomData`

error[E0392]: lifetime parameter `'borrow` is never used
 --> /tmp/icemaker_global_tempdir.iy1H39B5cCGu/rustc_testrunner_tmpdir_reporting.szJD7axysECi/mvce.rs:9:25
  |
9 | pub struct Token<'life, 'borrow, 'compact, 'reborrow, T>
  |                         ^^^^^^^ unused lifetime parameter
  |
  = help: consider removing `'borrow`, referring to it in a field, or using a marker such as `PhantomData`

error[E0392]: lifetime parameter `'compact` is never used
 --> /tmp/icemaker_global_tempdir.iy1H39B5cCGu/rustc_testrunner_tmpdir_reporting.szJD7axysECi/mvce.rs:9:34
  |
9 | pub struct Token<'life, 'borrow, 'compact, 'reborrow, T>
  |                                  ^^^^^^^^ unused lifetime parameter
  |
  = help: consider removing `'compact`, referring to it in a field, or using a marker such as `PhantomData`

error[E0392]: lifetime parameter `'reborrow` is never used
 --> /tmp/icemaker_global_tempdir.iy1H39B5cCGu/rustc_testrunner_tmpdir_reporting.szJD7axysECi/mvce.rs:9:44
  |
9 | pub struct Token<'life, 'borrow, 'compact, 'reborrow, T>
  |                                            ^^^^^^^^^ unused lifetime parameter
  |
  = help: consider removing `'reborrow`, referring to it in a field, or using a marker such as `PhantomData`

error[E0107]: trait takes 0 lifetime arguments but 4 lifetime arguments were supplied
  --> /tmp/icemaker_global_tempdir.iy1H39B5cCGu/rustc_testrunner_tmpdir_reporting.szJD7axysECi/mvce.rs:24:12
   |
24 |         T: Tokenize<'life, 'borrow, 'compact, 'reborrow, Untokenized = U>,
   |            ^^^^^^^^------------------------------------------------------ help: remove these generics
   |            |
   |            expected 0 lifetime arguments
   |
note: trait defined here, with 0 lifetime parameters
  --> /tmp/icemaker_global_tempdir.iy1H39B5cCGu/rustc_testrunner_tmpdir_reporting.szJD7axysECi/mvce.rs:35:11
   |
35 | pub trait Tokenize {
   |           ^^^^^^^^

error[E0107]: trait takes 0 lifetime arguments but 4 lifetime arguments were supplied
  --> /tmp/icemaker_global_tempdir.iy1H39B5cCGu/rustc_testrunner_tmpdir_reporting.szJD7axysECi/mvce.rs:25:25
   |
25 |         T::Untokenized: Tokenize<'life, 'borrow, 'compact, 'reborrow>,
   |                         ^^^^^^^^------------------------------------- help: remove these generics
   |                         |
   |                         expected 0 lifetime arguments
   |
note: trait defined here, with 0 lifetime parameters
  --> /tmp/icemaker_global_tempdir.iy1H39B5cCGu/rustc_testrunner_tmpdir_reporting.szJD7axysECi/mvce.rs:35:11
   |
35 | pub trait Tokenize {
   |           ^^^^^^^^

thread 'rustc' panicked at /rustc/f3c66088610c1b80110297c2d9a8b5f9265b013f/compiler/rustc_abi/src/lib.rs:1201:66:
index out of bounds: the len is 0 but the index is 0
stack backtrace:
   0:     0x7f75db283b55 - std::backtrace_rs::backtrace::libunwind::trace::h03dc4c75a602abd6
                               at /rustc/f3c66088610c1b80110297c2d9a8b5f9265b013f/library/std/src/../../backtrace/src/backtrace/libunwind.rs:105:5
   1:     0x7f75db283b55 - std::backtrace_rs::backtrace::trace_unsynchronized::h1821d384db4b0e26
                               at /rustc/f3c66088610c1b80110297c2d9a8b5f9265b013f/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f75db283b55 - std::sys_common::backtrace::_print_fmt::h1412fd631a460d8d
                               at /rustc/f3c66088610c1b80110297c2d9a8b5f9265b013f/library/std/src/sys_common/backtrace.rs:68:5
   3:     0x7f75db283b55 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h585bce00fd030aee
                               at /rustc/f3c66088610c1b80110297c2d9a8b5f9265b013f/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7f75db2d2e3b - core::fmt::rt::Argument::fmt::h51a122f876b01508
                               at /rustc/f3c66088610c1b80110297c2d9a8b5f9265b013f/library/core/src/fmt/rt.rs:165:63
   5:     0x7f75db2d2e3b - core::fmt::write::h4dfb720a2f630255
                               at /rustc/f3c66088610c1b80110297c2d9a8b5f9265b013f/library/core/src/fmt/mod.rs:1157:21
   6:     0x7f75db27875f - std::io::Write::write_fmt::hb827ffc1239a96a6
                               at /rustc/f3c66088610c1b80110297c2d9a8b5f9265b013f/library/std/src/io/mod.rs:1832:15
   7:     0x7f75db28392e - std::sys_common::backtrace::_print::h34ff464c9a4e054c
                               at /rustc/f3c66088610c1b80110297c2d9a8b5f9265b013f/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x7f75db28392e - std::sys_common::backtrace::print::hb47d1eaca16fac84
                               at /rustc/f3c66088610c1b80110297c2d9a8b5f9265b013f/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7f75db2862a9 - std::panicking::default_hook::{{closure}}::h7fc91e7cfecf6096
  10:     0x7f75db285fed - std::panicking::default_hook::h677e761d182faf87
                               at /rustc/f3c66088610c1b80110297c2d9a8b5f9265b013f/library/std/src/panicking.rs:291:9
  11:     0x7f75d7c7731c - std[184458c9395fed62]::panicking::update_hook::<alloc[945b23d7edb322c9]::boxed::Box<rustc_driver_impl[f047c15e8130c94f]::install_ice_hook::{closure#0}>>::{closure#0}
  12:     0x7f75db2869ac - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::ha779244beb256d6f
                               at /rustc/f3c66088610c1b80110297c2d9a8b5f9265b013f/library/alloc/src/boxed.rs:2032:9
  13:     0x7f75db2869ac - std::panicking::rust_panic_with_hook::h74b58e16e7d0027a
                               at /rustc/f3c66088610c1b80110297c2d9a8b5f9265b013f/library/std/src/panicking.rs:792:13
  14:     0x7f75db286756 - std::panicking::begin_panic_handler::{{closure}}::h3945bb507775f2bc
                               at /rustc/f3c66088610c1b80110297c2d9a8b5f9265b013f/library/std/src/panicking.rs:657:13
  15:     0x7f75db284019 - std::sys_common::backtrace::__rust_end_short_backtrace::hc7e0fa976db9fff0
                               at /rustc/f3c66088610c1b80110297c2d9a8b5f9265b013f/library/std/src/sys_common/backtrace.rs:171:18
  16:     0x7f75db286487 - rust_begin_unwind
                               at /rustc/f3c66088610c1b80110297c2d9a8b5f9265b013f/library/std/src/panicking.rs:645:5
  17:     0x7f75db2cf2e6 - core::panicking::panic_fmt::ha9dbe3d7803e94c3
                               at /rustc/f3c66088610c1b80110297c2d9a8b5f9265b013f/library/core/src/panicking.rs:72:14
  18:     0x7f75db2cf507 - core::panicking::panic_bounds_check::h6b123be699451bc5
                               at /rustc/f3c66088610c1b80110297c2d9a8b5f9265b013f/library/core/src/panicking.rs:268:5
  19:     0x7f75da677ac8 - <rustc_abi[79353852cb49b78b]::FieldsShape<rustc_target[c1582aecfafb9bc]::abi::FieldIdx>>::offset.cold
  20:     0x7f75d9973082 - <rustc_const_eval[3991ad9ab9a5ab30]::interpret::eval_context::InterpCx<rustc_const_eval[3991ad9ab9a5ab30]::const_eval::dummy_machine::DummyMachine>>::project_field::<rustc_const_eval[3991ad9ab9a5ab30]::interpret::operand::OpTy>
  21:     0x7f75d82fb944 - <rustc_mir_transform[560a276af31fbb04]::dataflow_const_prop::ConstAnalysis>::assign_constant::{closure#0}
  22:     0x7f75d8259929 - <rustc_mir_dataflow[6f840b518e755586]::value_analysis::Map>::for_each_projection_value::<rustc_const_eval[3991ad9ab9a5ab30]::interpret::operand::OpTy, <rustc_mir_transform[560a276af31fbb04]::dataflow_const_prop::ConstAnalysis>::assign_constant::{closure#0}, <rustc_mir_transform[560a276af31fbb04]::dataflow_const_prop::ConstAnalysis>::assign_constant::{closure#1}>
  23:     0x7f75d82fb8f6 - <rustc_mir_transform[560a276af31fbb04]::dataflow_const_prop::ConstAnalysis>::assign_constant
  24:     0x7f75d82cac17 - <rustc_mir_transform[560a276af31fbb04]::dataflow_const_prop::ConstAnalysis>::assign_operand
  25:     0x7f75d82c9b27 - <rustc_mir_transform[560a276af31fbb04]::dataflow_const_prop::ConstAnalysis as rustc_mir_dataflow[6f840b518e755586]::value_analysis::ValueAnalysis>::handle_assign
  26:     0x7f75d82f9cce - <rustc_mir_transform[560a276af31fbb04]::dataflow_const_prop::DataflowConstProp as rustc_middle[55da801b9dd73f34]::mir::MirPass>::run_pass
  27:     0x7f75d900188d - rustc_mir_transform[560a276af31fbb04]::pass_manager::run_passes_inner
  28:     0x7f75d96259b1 - rustc_mir_transform[560a276af31fbb04]::optimized_mir
  29:     0x7f75d9624b9b - rustc_query_impl[8a57831cea33f912]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[8a57831cea33f912]::query_impl::optimized_mir::dynamic_query::{closure#2}::{closure#0}, rustc_middle[55da801b9dd73f34]::query::erase::Erased<[u8; 8usize]>>
  30:     0x7f75d91041de - rustc_query_system[698870ff4aca75a8]::query::plumbing::try_execute_query::<rustc_query_impl[8a57831cea33f912]::DynamicConfig<rustc_query_system[698870ff4aca75a8]::query::caches::DefIdCache<rustc_middle[55da801b9dd73f34]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[8a57831cea33f912]::plumbing::QueryCtxt, false>
  31:     0x7f75d910391e - rustc_query_impl[8a57831cea33f912]::query_impl::optimized_mir::get_query_non_incr::__rust_end_short_backtrace
  32:     0x7f75d92f261e - rustc_middle[55da801b9dd73f34]::query::plumbing::query_get_at::<rustc_query_system[698870ff4aca75a8]::query::caches::DefIdCache<rustc_middle[55da801b9dd73f34]::query::erase::Erased<[u8; 8usize]>>>
  33:     0x7f75d958ebc7 - rustc_query_impl[8a57831cea33f912]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[8a57831cea33f912]::query_impl::unused_generic_params::dynamic_query::{closure#2}::{closure#0}, rustc_middle[55da801b9dd73f34]::query::erase::Erased<[u8; 4usize]>>
  34:     0x7f75d958e399 - rustc_query_system[698870ff4aca75a8]::query::plumbing::try_execute_query::<rustc_query_impl[8a57831cea33f912]::DynamicConfig<rustc_query_system[698870ff4aca75a8]::query::caches::DefaultCache<rustc_middle[55da801b9dd73f34]::ty::instance::InstanceDef, rustc_middle[55da801b9dd73f34]::query::erase::Erased<[u8; 4usize]>>, false, false, false>, rustc_query_impl[8a57831cea33f912]::plumbing::QueryCtxt, false>
  35:     0x7f75d958e08e - rustc_query_impl[8a57831cea33f912]::query_impl::unused_generic_params::get_query_non_incr::__rust_end_short_backtrace
  36:     0x7f75d9589bc0 - rustc_interface[e2c21f0ab22f590a]::passes::analysis
  37:     0x7f75d95888c7 - rustc_query_impl[8a57831cea33f912]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[8a57831cea33f912]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[55da801b9dd73f34]::query::erase::Erased<[u8; 1usize]>>
  38:     0x7f75d9e61ea5 - rustc_query_system[698870ff4aca75a8]::query::plumbing::try_execute_query::<rustc_query_impl[8a57831cea33f912]::DynamicConfig<rustc_query_system[698870ff4aca75a8]::query::caches::SingleCache<rustc_middle[55da801b9dd73f34]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[8a57831cea33f912]::plumbing::QueryCtxt, false>
  39:     0x7f75d9e61c09 - rustc_query_impl[8a57831cea33f912]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  40:     0x7f75d9cc0793 - rustc_interface[e2c21f0ab22f590a]::interface::run_compiler::<core[cfe0013222fec553]::result::Result<(), rustc_span[27037ef1f63d3fc0]::ErrorGuaranteed>, rustc_driver_impl[f047c15e8130c94f]::run_compiler::{closure#0}>::{closure#0}
  41:     0x7f75d9d93d1d - std[184458c9395fed62]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[e2c21f0ab22f590a]::util::run_in_thread_with_globals<rustc_interface[e2c21f0ab22f590a]::util::run_in_thread_pool_with_globals<rustc_interface[e2c21f0ab22f590a]::interface::run_compiler<core[cfe0013222fec553]::result::Result<(), rustc_span[27037ef1f63d3fc0]::ErrorGuaranteed>, rustc_driver_impl[f047c15e8130c94f]::run_compiler::{closure#0}>::{closure#0}, core[cfe0013222fec553]::result::Result<(), rustc_span[27037ef1f63d3fc0]::ErrorGuaranteed>>::{closure#0}, core[cfe0013222fec553]::result::Result<(), rustc_span[27037ef1f63d3fc0]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[cfe0013222fec553]::result::Result<(), rustc_span[27037ef1f63d3fc0]::ErrorGuaranteed>>
  42:     0x7f75d9d93b2a - <<std[184458c9395fed62]::thread::Builder>::spawn_unchecked_<rustc_interface[e2c21f0ab22f590a]::util::run_in_thread_with_globals<rustc_interface[e2c21f0ab22f590a]::util::run_in_thread_pool_with_globals<rustc_interface[e2c21f0ab22f590a]::interface::run_compiler<core[cfe0013222fec553]::result::Result<(), rustc_span[27037ef1f63d3fc0]::ErrorGuaranteed>, rustc_driver_impl[f047c15e8130c94f]::run_compiler::{closure#0}>::{closure#0}, core[cfe0013222fec553]::result::Result<(), rustc_span[27037ef1f63d3fc0]::ErrorGuaranteed>>::{closure#0}, core[cfe0013222fec553]::result::Result<(), rustc_span[27037ef1f63d3fc0]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[cfe0013222fec553]::result::Result<(), rustc_span[27037ef1f63d3fc0]::ErrorGuaranteed>>::{closure#2} as core[cfe0013222fec553]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  43:     0x7f75db29089b - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h5913e9e2478013f2
                               at /rustc/f3c66088610c1b80110297c2d9a8b5f9265b013f/library/alloc/src/boxed.rs:2018:9
  44:     0x7f75db29089b - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hc7951dd75ee74cd3
                               at /rustc/f3c66088610c1b80110297c2d9a8b5f9265b013f/library/alloc/src/boxed.rs:2018:9
  45:     0x7f75db29089b - std::sys::pal::unix::thread::Thread::new::thread_start::h59778d43da0379b7
                               at /rustc/f3c66088610c1b80110297c2d9a8b5f9265b013f/library/std/src/sys/pal/unix/thread.rs:108:17
  46:     0x7f75d4aa955a - <unknown>
  47:     0x7f75d4b26a3c - <unknown>
  48:                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.79.0-nightly (f3c660886 2024-04-14) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z mir-opt-level=5 -Z polymorphize=on -Z dump-mir-dir=dir

query stack during panic:
#0 [optimized_mir] optimizing MIR for `<impl at /tmp/icemaker_global_tempdir.iy1H39B5cCGu/rustc_testrunner_tmpdir_reporting.szJD7axysECi/mvce.rs:19:1: 19:25>::tokenize`
#1 [unused_generic_params] determining which generic parameters are unused by `<impl at /tmp/icemaker_global_tempdir.iy1H39B5cCGu/rustc_testrunner_tmpdir_reporting.szJD7axysECi/mvce.rs:19:1: 19:25>::tokenize`
#2 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 11 previous errors

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

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

Another one for #120550

@matthiaskrgr matthiaskrgr changed the title ICE: rustc_abi the len is 0 but the index is 0 ICE: rustc_abi the len is 0 but the index is 0 calculating offset Apr 14, 2024
@Noratrieb
Copy link
Member

would be great if someone could minimize it further (remove as many of the errors as possible, I doubt all of them are necessary)

@Noratrieb Noratrieb added the E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example label Apr 14, 2024
@jieyouxu jieyouxu added A-ABI Area: Concerning the application binary interface (ABI) and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Apr 15, 2024
@Luk-ESC
Copy link
Contributor

Luk-ESC commented Apr 18, 2024

Minimized further:

struct NonNull<T>(*mut T);

struct Token<T> {
    ptr: *mut T,
    ptr: NonNull<T>,
    _extra_field: ()
}

fn tokenize<T>(item: *mut T) -> Token<T> {
    Token {
        ptr: NonNull(item),
        _extra_field: ()
    }
}

@matthiaskrgr matthiaskrgr added the S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. label Apr 18, 2024
@fmease fmease added the -Zpolymorphize Unstable option: Polymorphization. label Apr 20, 2024
@adwinwhite
Copy link
Contributor

Cannot reproduce. May be fixed by #126045.

@Noratrieb Noratrieb removed the E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example label Aug 8, 2024
@matthiaskrgr
Copy link
Member Author

This was fixed by 2e3842b but the ticket wasn't closed 😿 cc @oli-obk

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
-Zpolymorphize Unstable option: Polymorphization. A-ABI Area: Concerning the application binary interface (ABI) C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. 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

7 participants