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

underflow while calculating type sizes #122547

Open
matthiaskrgr opened this issue Mar 15, 2024 · 9 comments
Open

underflow while calculating type sizes #122547

matthiaskrgr opened this issue Mar 15, 2024 · 9 comments
Labels
A-layout Area: Memory layout of types C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ requires-debug-assertions This issue requires a build of rustc or tooling with debug-assertions in some way S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@matthiaskrgr
Copy link
Member

matthiaskrgr commented Mar 15, 2024

only happens when rustc is compiled with debug assertions enabled

auto-reduced (treereduce-rust):

#[repr(align(4))]
enum AlsoAlign16 {
    Foo { limb_with_noniche16: NoNiche16 },
    Bar,
}

struct NoNiche16(u64, u64);

fn main() {}
original code

original:

//@ run-pass
#![allow(dead_code)]

use std::mem;

// Raising alignment
#[repr(align(16))]
enum Align16 {
    Foo { foo: u32 },
    Bar { bar: u32 },
}

// Raise alignment by maximum
#[repr(align(1), align(16))]
#[repr(align(32))]
#[repr(align(4))]
enum Align32 {
    Foo,
    Bar,
}

// Not reducing alignment
#[repr(align(4))]
enum AlsoAlign16 {
    Foo { limb_with_noniche16: NoNiche16 },
    Bar,
}

// No niche for discriminant when used as limb
#[repr(align(16))]
struct NoNiche16(u64, u64);

// Discriminant will require extra space, but enum needs to stay compatible
// with alignment 16
#[repr(align(1))]
enum AnotherAlign16 {
    Foo { limb_with_noniche16: NoNiche16 },
    Bar,
    Baz,
}

fn main() {
    assert_eq!(mem::align_of::<Align16>(), 16);
    assert_eq!(mem::size_of::<Align16>(), 16);

    assert_eq!(mem::align_of::<Align32>(), 1);
    assert_eq!(mem::size_of::<Align32>(), 32);

    assert_eq!(mem::align_of::<AlsoAlign16>(), 16);
    assert_eq!(mem::size_of::<AlsoAlign16>(), 16);

    assert_eq!(mem::align_of::<AnotherAlign16>(), 16);
    assert_eq!(mem::size_of::<AnotherAlign16>(), 32);
}

Version information

rustc 1.78.0-dev
binary: rustc
commit-hash: unknown
commit-date: unknown
host: x86_64-unknown-linux-gnu
release: 1.78.0-dev
LLVM version: 18.1.0

Command:
/home/matthias/.rustup/toolchains/local-debug-assertions/bin/rustc -Zprint-type-sizes

Program output

warning: enum `AlsoAlign16` is never used
 --> /tmp/icemaker_global_tempdir.jQa79k0ZO1IC/rustc_testrunner_tmpdir_reporting.vxVUC0DEKwwH/mvce.rs:2:6
  |
2 | enum AlsoAlign16 {
  |      ^^^^^^^^^^^
  |
  = note: `#[warn(dead_code)]` on by default

warning: struct `NoNiche16` is never constructed
 --> /tmp/icemaker_global_tempdir.jQa79k0ZO1IC/rustc_testrunner_tmpdir_reporting.vxVUC0DEKwwH/mvce.rs:7:8
  |
7 | struct NoNiche16(u64, u64);
  |        ^^^^^^^^^

thread 'rustc' panicked at compiler/rustc_session/src/code_stats.rs:176:32:
attempt to subtract with overflow
stack backtrace:
   0:     0x7f6901ded829 - std::backtrace_rs::backtrace::libunwind::trace::h71aa28bdc5089aab
                               at /home/matthias/vcs/github/rust_debug_assertions/library/std/src/../../backtrace/src/backtrace/libunwind.rs:105:5
   1:     0x7f6901ded829 - std::backtrace_rs::backtrace::trace_unsynchronized::hc71f6f29c4d7cf67
                               at /home/matthias/vcs/github/rust_debug_assertions/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f6901ded829 - std::sys_common::backtrace::_print_fmt::h8e1e2ea27397ed17
                               at /home/matthias/vcs/github/rust_debug_assertions/library/std/src/sys_common/backtrace.rs:68:5
   3:     0x7f6901ded829 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h28aca7b36a9d50a9
                               at /home/matthias/vcs/github/rust_debug_assertions/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7f6901e82737 - core::fmt::rt::Argument::fmt::h67bfbe6caf20ecda
                               at /home/matthias/vcs/github/rust_debug_assertions/library/core/src/fmt/rt.rs:142:9
   5:     0x7f6901e82737 - core::fmt::write::h2b3e0bd86bdfc209
                               at /home/matthias/vcs/github/rust_debug_assertions/library/core/src/fmt/mod.rs:1153:17
   6:     0x7f6901e01855 - std::io::Write::write_fmt::h136db78b548c4ef6
                               at /home/matthias/vcs/github/rust_debug_assertions/library/std/src/io/mod.rs:1843:15
   7:     0x7f6901ded5e4 - std::sys_common::backtrace::_print::h5b92b1853c8de3bd
                               at /home/matthias/vcs/github/rust_debug_assertions/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x7f6901ded5e4 - std::sys_common::backtrace::print::h490b617a207e3b67
                               at /home/matthias/vcs/github/rust_debug_assertions/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7f6901e11733 - std::panicking::default_hook::{{closure}}::h45adea5532c8b211
  10:     0x7f6901e11431 - std::panicking::default_hook::hd02efd9905101244
                               at /home/matthias/vcs/github/rust_debug_assertions/library/std/src/panicking.rs:292:9
  11:     0x7f68fe91e6f8 - rustc_driver_impl[392676b3d88fadab]::install_ice_hook::{closure#0}
                               at /home/matthias/vcs/github/rust_debug_assertions/compiler/rustc_driver_impl/src/lib.rs:1350:17
  12:     0x7f68fe91e6f8 - <alloc[7d65993373035c28]::boxed::Box<rustc_driver_impl[392676b3d88fadab]::install_ice_hook::{closure#0}> as core[aa444211b5f41879]::ops::function::Fn<(&dyn for<'a, 'b> core[aa444211b5f41879]::ops::function::Fn<(&'a core[aa444211b5f41879]::panic::panic_info::PanicInfo<'b>,), Output = ()> + core[aa444211b5f41879]::marker::Sync + core[aa444211b5f41879]::marker::Send, &core[aa444211b5f41879]::panic::panic_info::PanicInfo)>>::call
                               at /home/matthias/vcs/github/rust_debug_assertions/library/alloc/src/boxed.rs:2034:9
  13:     0x7f6901e11e65 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::hc3e26a573d0d775a
                               at /home/matthias/vcs/github/rust_debug_assertions/library/alloc/src/boxed.rs:2034:9
  14:     0x7f6901e11e65 - std::panicking::rust_panic_with_hook::h62b1349491684a47
                               at /home/matthias/vcs/github/rust_debug_assertions/library/std/src/panicking.rs:783:13
  15:     0x7f6901dee699 - std::panicking::begin_panic_handler::{{closure}}::ha9ba801d79b7df26
                               at /home/matthias/vcs/github/rust_debug_assertions/library/std/src/panicking.rs:649:13
  16:     0x7f6901dedad6 - std::sys_common::backtrace::__rust_end_short_backtrace::h143ebb6cbd4c764e
                               at /home/matthias/vcs/github/rust_debug_assertions/library/std/src/sys_common/backtrace.rs:171:18
  17:     0x7f6901e11a34 - rust_begin_unwind
                               at /home/matthias/vcs/github/rust_debug_assertions/library/std/src/panicking.rs:645:5
  18:     0x7f6901e9b425 - core::panicking::panic_fmt::h7cdaca6ac7987f65
                               at /home/matthias/vcs/github/rust_debug_assertions/library/core/src/panicking.rs:72:14
  19:     0x7f6901e9b4d5 - core::panicking::panic::h0a00db0f39d75437
                               at /home/matthias/vcs/github/rust_debug_assertions/library/core/src/panicking.rs:145:5
  20:     0x7f6900e5db52 - <rustc_session[96c1b509bcbd92de]::code_stats::CodeStats>::print_type_sizes
                               at /home/matthias/vcs/github/rust_debug_assertions/compiler/rustc_session/src/code_stats.rs:176:32
  21:     0x7f68fe944339 - rustc_driver_impl[392676b3d88fadab]::run_compiler::{closure#0}::{closure#1}
                               at /home/matthias/vcs/github/rust_debug_assertions/compiler/rustc_driver_impl/src/lib.rs:451:17
  22:     0x7f68fe944339 - <rustc_interface[e9562a9c472c94f0]::interface::Compiler>::enter::<rustc_driver_impl[392676b3d88fadab]::run_compiler::{closure#0}::{closure#1}, core[aa444211b5f41879]::result::Result<core[aa444211b5f41879]::option::Option<rustc_interface[e9562a9c472c94f0]::queries::Linker>, rustc_span[87e9bd33af79061d]::ErrorGuaranteed>>
                               at /home/matthias/vcs/github/rust_debug_assertions/compiler/rustc_interface/src/queries.rs:309:19
  23:     0x7f68fe974320 - rustc_driver_impl[392676b3d88fadab]::run_compiler::{closure#0}
                               at /home/matthias/vcs/github/rust_debug_assertions/compiler/rustc_driver_impl/src/lib.rs:388:22
  24:     0x7f68fe974320 - rustc_interface[e9562a9c472c94f0]::interface::run_compiler::<core[aa444211b5f41879]::result::Result<(), rustc_span[87e9bd33af79061d]::ErrorGuaranteed>, rustc_driver_impl[392676b3d88fadab]::run_compiler::{closure#0}>::{closure#0}::{closure#0}
                               at /home/matthias/vcs/github/rust_debug_assertions/compiler/rustc_interface/src/interface.rs:477:31
  25:     0x7f68fe974320 - rustc_span[87e9bd33af79061d]::set_source_map::<core[aa444211b5f41879]::result::Result<(), rustc_span[87e9bd33af79061d]::ErrorGuaranteed>, rustc_interface[e9562a9c472c94f0]::interface::run_compiler<core[aa444211b5f41879]::result::Result<(), rustc_span[87e9bd33af79061d]::ErrorGuaranteed>, rustc_driver_impl[392676b3d88fadab]::run_compiler::{closure#0}>::{closure#0}::{closure#0}>
                               at /home/matthias/vcs/github/rust_debug_assertions/compiler/rustc_span/src/lib.rs:1275:5
  26:     0x7f68fe9251b2 - rustc_interface[e9562a9c472c94f0]::interface::run_compiler::<core[aa444211b5f41879]::result::Result<(), rustc_span[87e9bd33af79061d]::ErrorGuaranteed>, rustc_driver_impl[392676b3d88fadab]::run_compiler::{closure#0}>::{closure#0}
                               at /home/matthias/vcs/github/rust_debug_assertions/compiler/rustc_interface/src/interface.rs:463:13
  27:     0x7f68fe9251b2 - rustc_interface[e9562a9c472c94f0]::util::run_in_thread_pool_with_globals::<rustc_interface[e9562a9c472c94f0]::interface::run_compiler<core[aa444211b5f41879]::result::Result<(), rustc_span[87e9bd33af79061d]::ErrorGuaranteed>, rustc_driver_impl[392676b3d88fadab]::run_compiler::{closure#0}>::{closure#0}, core[aa444211b5f41879]::result::Result<(), rustc_span[87e9bd33af79061d]::ErrorGuaranteed>>::{closure#0}
                               at /home/matthias/vcs/github/rust_debug_assertions/compiler/rustc_interface/src/util.rs:119:13
  28:     0x7f68fe9251b2 - <scoped_tls[af7c8664e9f149d3]::ScopedKey<rustc_span[87e9bd33af79061d]::SessionGlobals>>::set::<rustc_interface[e9562a9c472c94f0]::util::run_in_thread_pool_with_globals<rustc_interface[e9562a9c472c94f0]::interface::run_compiler<core[aa444211b5f41879]::result::Result<(), rustc_span[87e9bd33af79061d]::ErrorGuaranteed>, rustc_driver_impl[392676b3d88fadab]::run_compiler::{closure#0}>::{closure#0}, core[aa444211b5f41879]::result::Result<(), rustc_span[87e9bd33af79061d]::ErrorGuaranteed>>::{closure#0}, core[aa444211b5f41879]::result::Result<(), rustc_span[87e9bd33af79061d]::ErrorGuaranteed>>
                               at /home/matthias/.cargo/registry/src/index.crates.io-6f17d22bba15001f/scoped-tls-1.0.1/src/lib.rs:137:9
  29:     0x7f68fe97e341 - rustc_span[87e9bd33af79061d]::create_session_globals_then::<core[aa444211b5f41879]::result::Result<(), rustc_span[87e9bd33af79061d]::ErrorGuaranteed>, rustc_interface[e9562a9c472c94f0]::util::run_in_thread_pool_with_globals<rustc_interface[e9562a9c472c94f0]::interface::run_compiler<core[aa444211b5f41879]::result::Result<(), rustc_span[87e9bd33af79061d]::ErrorGuaranteed>, rustc_driver_impl[392676b3d88fadab]::run_compiler::{closure#0}>::{closure#0}, core[aa444211b5f41879]::result::Result<(), rustc_span[87e9bd33af79061d]::ErrorGuaranteed>>::{closure#0}>
                               at /home/matthias/vcs/github/rust_debug_assertions/compiler/rustc_span/src/lib.rs:136:5
  30:     0x7f68fe97e341 - rustc_interface[e9562a9c472c94f0]::util::run_in_thread_with_globals::<rustc_interface[e9562a9c472c94f0]::util::run_in_thread_pool_with_globals<rustc_interface[e9562a9c472c94f0]::interface::run_compiler<core[aa444211b5f41879]::result::Result<(), rustc_span[87e9bd33af79061d]::ErrorGuaranteed>, rustc_driver_impl[392676b3d88fadab]::run_compiler::{closure#0}>::{closure#0}, core[aa444211b5f41879]::result::Result<(), rustc_span[87e9bd33af79061d]::ErrorGuaranteed>>::{closure#0}, core[aa444211b5f41879]::result::Result<(), rustc_span[87e9bd33af79061d]::ErrorGuaranteed>>::{closure#0}::{closure#0}
                               at /home/matthias/vcs/github/rust_debug_assertions/compiler/rustc_interface/src/util.rs:80:38
  31:     0x7f68fe97e341 - std[9e45a94ab2b939d9]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[e9562a9c472c94f0]::util::run_in_thread_with_globals<rustc_interface[e9562a9c472c94f0]::util::run_in_thread_pool_with_globals<rustc_interface[e9562a9c472c94f0]::interface::run_compiler<core[aa444211b5f41879]::result::Result<(), rustc_span[87e9bd33af79061d]::ErrorGuaranteed>, rustc_driver_impl[392676b3d88fadab]::run_compiler::{closure#0}>::{closure#0}, core[aa444211b5f41879]::result::Result<(), rustc_span[87e9bd33af79061d]::ErrorGuaranteed>>::{closure#0}, core[aa444211b5f41879]::result::Result<(), rustc_span[87e9bd33af79061d]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[aa444211b5f41879]::result::Result<(), rustc_span[87e9bd33af79061d]::ErrorGuaranteed>>
                               at /home/matthias/vcs/github/rust_debug_assertions/library/std/src/sys_common/backtrace.rs:155:18
  32:     0x7f68fe931da3 - <std[9e45a94ab2b939d9]::thread::Builder>::spawn_unchecked_::<rustc_interface[e9562a9c472c94f0]::util::run_in_thread_with_globals<rustc_interface[e9562a9c472c94f0]::util::run_in_thread_pool_with_globals<rustc_interface[e9562a9c472c94f0]::interface::run_compiler<core[aa444211b5f41879]::result::Result<(), rustc_span[87e9bd33af79061d]::ErrorGuaranteed>, rustc_driver_impl[392676b3d88fadab]::run_compiler::{closure#0}>::{closure#0}, core[aa444211b5f41879]::result::Result<(), rustc_span[87e9bd33af79061d]::ErrorGuaranteed>>::{closure#0}, core[aa444211b5f41879]::result::Result<(), rustc_span[87e9bd33af79061d]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[aa444211b5f41879]::result::Result<(), rustc_span[87e9bd33af79061d]::ErrorGuaranteed>>::{closure#1}::{closure#0}
                               at /home/matthias/vcs/github/rust_debug_assertions/library/std/src/thread/mod.rs:528:17
  33:     0x7f68fe931da3 - <core[aa444211b5f41879]::panic::unwind_safe::AssertUnwindSafe<<std[9e45a94ab2b939d9]::thread::Builder>::spawn_unchecked_<rustc_interface[e9562a9c472c94f0]::util::run_in_thread_with_globals<rustc_interface[e9562a9c472c94f0]::util::run_in_thread_pool_with_globals<rustc_interface[e9562a9c472c94f0]::interface::run_compiler<core[aa444211b5f41879]::result::Result<(), rustc_span[87e9bd33af79061d]::ErrorGuaranteed>, rustc_driver_impl[392676b3d88fadab]::run_compiler::{closure#0}>::{closure#0}, core[aa444211b5f41879]::result::Result<(), rustc_span[87e9bd33af79061d]::ErrorGuaranteed>>::{closure#0}, core[aa444211b5f41879]::result::Result<(), rustc_span[87e9bd33af79061d]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[aa444211b5f41879]::result::Result<(), rustc_span[87e9bd33af79061d]::ErrorGuaranteed>>::{closure#1}::{closure#0}> as core[aa444211b5f41879]::ops::function::FnOnce<()>>::call_once
                               at /home/matthias/vcs/github/rust_debug_assertions/library/core/src/panic/unwind_safe.rs:272:9
  34:     0x7f68fe931da3 - std[9e45a94ab2b939d9]::panicking::try::do_call::<core[aa444211b5f41879]::panic::unwind_safe::AssertUnwindSafe<<std[9e45a94ab2b939d9]::thread::Builder>::spawn_unchecked_<rustc_interface[e9562a9c472c94f0]::util::run_in_thread_with_globals<rustc_interface[e9562a9c472c94f0]::util::run_in_thread_pool_with_globals<rustc_interface[e9562a9c472c94f0]::interface::run_compiler<core[aa444211b5f41879]::result::Result<(), rustc_span[87e9bd33af79061d]::ErrorGuaranteed>, rustc_driver_impl[392676b3d88fadab]::run_compiler::{closure#0}>::{closure#0}, core[aa444211b5f41879]::result::Result<(), rustc_span[87e9bd33af79061d]::ErrorGuaranteed>>::{closure#0}, core[aa444211b5f41879]::result::Result<(), rustc_span[87e9bd33af79061d]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[aa444211b5f41879]::result::Result<(), rustc_span[87e9bd33af79061d]::ErrorGuaranteed>>::{closure#1}::{closure#0}>, core[aa444211b5f41879]::result::Result<(), rustc_span[87e9bd33af79061d]::ErrorGuaranteed>>
                               at /home/matthias/vcs/github/rust_debug_assertions/library/std/src/panicking.rs:552:40
  35:     0x7f68fe931da3 - std[9e45a94ab2b939d9]::panicking::try::<core[aa444211b5f41879]::result::Result<(), rustc_span[87e9bd33af79061d]::ErrorGuaranteed>, core[aa444211b5f41879]::panic::unwind_safe::AssertUnwindSafe<<std[9e45a94ab2b939d9]::thread::Builder>::spawn_unchecked_<rustc_interface[e9562a9c472c94f0]::util::run_in_thread_with_globals<rustc_interface[e9562a9c472c94f0]::util::run_in_thread_pool_with_globals<rustc_interface[e9562a9c472c94f0]::interface::run_compiler<core[aa444211b5f41879]::result::Result<(), rustc_span[87e9bd33af79061d]::ErrorGuaranteed>, rustc_driver_impl[392676b3d88fadab]::run_compiler::{closure#0}>::{closure#0}, core[aa444211b5f41879]::result::Result<(), rustc_span[87e9bd33af79061d]::ErrorGuaranteed>>::{closure#0}, core[aa444211b5f41879]::result::Result<(), rustc_span[87e9bd33af79061d]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[aa444211b5f41879]::result::Result<(), rustc_span[87e9bd33af79061d]::ErrorGuaranteed>>::{closure#1}::{closure#0}>>
                               at /home/matthias/vcs/github/rust_debug_assertions/library/std/src/panicking.rs:516:19
  36:     0x7f68fe931da3 - std[9e45a94ab2b939d9]::panic::catch_unwind::<core[aa444211b5f41879]::panic::unwind_safe::AssertUnwindSafe<<std[9e45a94ab2b939d9]::thread::Builder>::spawn_unchecked_<rustc_interface[e9562a9c472c94f0]::util::run_in_thread_with_globals<rustc_interface[e9562a9c472c94f0]::util::run_in_thread_pool_with_globals<rustc_interface[e9562a9c472c94f0]::interface::run_compiler<core[aa444211b5f41879]::result::Result<(), rustc_span[87e9bd33af79061d]::ErrorGuaranteed>, rustc_driver_impl[392676b3d88fadab]::run_compiler::{closure#0}>::{closure#0}, core[aa444211b5f41879]::result::Result<(), rustc_span[87e9bd33af79061d]::ErrorGuaranteed>>::{closure#0}, core[aa444211b5f41879]::result::Result<(), rustc_span[87e9bd33af79061d]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[aa444211b5f41879]::result::Result<(), rustc_span[87e9bd33af79061d]::ErrorGuaranteed>>::{closure#1}::{closure#0}>, core[aa444211b5f41879]::result::Result<(), rustc_span[87e9bd33af79061d]::ErrorGuaranteed>>
                               at /home/matthias/vcs/github/rust_debug_assertions/library/std/src/panic.rs:146:14
  37:     0x7f68fe931da3 - <std[9e45a94ab2b939d9]::thread::Builder>::spawn_unchecked_::<rustc_interface[e9562a9c472c94f0]::util::run_in_thread_with_globals<rustc_interface[e9562a9c472c94f0]::util::run_in_thread_pool_with_globals<rustc_interface[e9562a9c472c94f0]::interface::run_compiler<core[aa444211b5f41879]::result::Result<(), rustc_span[87e9bd33af79061d]::ErrorGuaranteed>, rustc_driver_impl[392676b3d88fadab]::run_compiler::{closure#0}>::{closure#0}, core[aa444211b5f41879]::result::Result<(), rustc_span[87e9bd33af79061d]::ErrorGuaranteed>>::{closure#0}, core[aa444211b5f41879]::result::Result<(), rustc_span[87e9bd33af79061d]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[aa444211b5f41879]::result::Result<(), rustc_span[87e9bd33af79061d]::ErrorGuaranteed>>::{closure#1}
                               at /home/matthias/vcs/github/rust_debug_assertions/library/std/src/thread/mod.rs:527:30
  38:     0x7f68fe931da3 - <<std[9e45a94ab2b939d9]::thread::Builder>::spawn_unchecked_<rustc_interface[e9562a9c472c94f0]::util::run_in_thread_with_globals<rustc_interface[e9562a9c472c94f0]::util::run_in_thread_pool_with_globals<rustc_interface[e9562a9c472c94f0]::interface::run_compiler<core[aa444211b5f41879]::result::Result<(), rustc_span[87e9bd33af79061d]::ErrorGuaranteed>, rustc_driver_impl[392676b3d88fadab]::run_compiler::{closure#0}>::{closure#0}, core[aa444211b5f41879]::result::Result<(), rustc_span[87e9bd33af79061d]::ErrorGuaranteed>>::{closure#0}, core[aa444211b5f41879]::result::Result<(), rustc_span[87e9bd33af79061d]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[aa444211b5f41879]::result::Result<(), rustc_span[87e9bd33af79061d]::ErrorGuaranteed>>::{closure#1} as core[aa444211b5f41879]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
                               at /home/matthias/vcs/github/rust_debug_assertions/library/core/src/ops/function.rs:250:5
  39:     0x7f6901de823e - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h6534edd00de45d0a
                               at /home/matthias/vcs/github/rust_debug_assertions/library/alloc/src/boxed.rs:2020:9
  40:     0x7f6901de823e - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hfc923cc959abd00c
                               at /home/matthias/vcs/github/rust_debug_assertions/library/alloc/src/boxed.rs:2020:9
  41:     0x7f6901de823e - std::sys::pal::unix::thread::Thread::new::thread_start::h57135b15377165e8
                               at /home/matthias/vcs/github/rust_debug_assertions/library/std/src/sys/pal/unix/thread.rs:108:17
  42:     0x7f68fbca955a - <unknown>
  43:     0x7f68fbd26a3c - <unknown>
  44:                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-dev running on x86_64-unknown-linux-gnu

note: compiler flags: -Z print-type-sizes -Z dump-mir-dir=dir

query stack during panic:
end of query stack
warning: 2 warnings emitted


@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. requires-debug-assertions This issue requires a build of rustc or tooling with debug-assertions in some way labels Mar 15, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Mar 15, 2024
@matthiaskrgr
Copy link
Member Author

print-type-size type: `unwind::libunwind::_Unwind_Exception`: 32 bytes, alignment: 8 bytes
print-type-size     field `.exception_class`: 8 bytes
print-type-size     field `.exception_cleanup`: 8 bytes
print-type-size     field `.private`: 16 bytes
print-type-size type: `AlsoAlign16`: 24 bytes, alignment: 8 bytes
print-type-size     discriminant: 8 bytes
print-type-size     variant `Foo`: 16 bytes
print-type-size         field `.limb_with_noniche16`: 16 bytes
print-type-size     variant `Bar`: 18446744073709551612 bytes  // <<<<<<<<<<<<<< ------------- lol

@matthiaskrgr
Copy link
Member Author

without debug assertions:

print-type-size type: `unwind::libunwind::_Unwind_Exception`: 32 bytes, alignment: 8 bytes
print-type-size     field `.exception_class`: 8 bytes
print-type-size     field `.exception_cleanup`: 8 bytes
print-type-size     field `.private`: 16 bytes
print-type-size type: `AlsoAlign16`: 24 bytes, alignment: 8 bytes
print-type-size     discriminant: 8 bytes
print-type-size     variant `Foo`: 16 bytes
print-type-size         field `.limb_with_noniche16`: 16 bytes
print-type-size     variant `Bar`: 18446744073709551612 bytes
print-type-size type: `NoNiche16`: 16 bytes, alignment: 8 bytes
print-type-size     field `.0`: 8 bytes
print-type-size     field `.1`: 8 bytes
print-type-size type: `std::option::Option<extern "C" fn(unwind::libunwind::_Unwind_Reason_Code, *mut unwind::libunwind::_Unwind_Exception)>`: 8 bytes, alignment: 8 bytes
print-type-size     variant `Some`: 8 bytes
print-type-size         field `.0`: 8 bytes
print-type-size     variant `None`: 0 bytes
print-type-size type: `std::ptr::DynMetadata<dyn std::ops::Fn() -> i32 + std::marker::Sync + std::panic::RefUnwindSafe>`: 8 bytes, alignment: 8 bytes
print-type-size     field `.vtable_ptr`: 8 bytes
print-type-size     field `.phantom`: 0 bytes
print-type-size type: `std::result::Result<isize, !>`: 8 bytes, alignment: 8 bytes
print-type-size     variant `Ok`: 8 bytes
print-type-size         field `.0`: 8 bytes
print-type-size type: `{closure@std::rt::lang_start<()>::{closure#0}}`: 8 bytes, alignment: 8 bytes
print-type-size     end padding: 8 bytes
print-type-size type: `unwind::libunwind::_Unwind_Action`: 4 bytes, alignment: 4 bytes
print-type-size     discriminant: 4 bytes
print-type-size     variant `_UA_SEARCH_PHASE`: 0 bytes
print-type-size     variant `_UA_CLEANUP_PHASE`: 0 bytes
print-type-size     variant `_UA_HANDLER_FRAME`: 0 bytes
print-type-size     variant `_UA_FORCE_UNWIND`: 0 bytes
print-type-size     variant `_UA_END_OF_STACK`: 0 bytes
print-type-size type: `unwind::libunwind::_Unwind_Reason_Code`: 4 bytes, alignment: 4 bytes
print-type-size     discriminant: 4 bytes
print-type-size     variant `_URC_NO_REASON`: 0 bytes
print-type-size     variant `_URC_FOREIGN_EXCEPTION_CAUGHT`: 0 bytes
print-type-size     variant `_URC_FATAL_PHASE2_ERROR`: 0 bytes
print-type-size     variant `_URC_FATAL_PHASE1_ERROR`: 0 bytes
print-type-size     variant `_URC_NORMAL_STOP`: 0 bytes
print-type-size     variant `_URC_END_OF_STACK`: 0 bytes
print-type-size     variant `_URC_HANDLER_FOUND`: 0 bytes
print-type-size     variant `_URC_INSTALL_CONTEXT`: 0 bytes
print-type-size     variant `_URC_CONTINUE_UNWIND`: 0 bytes
print-type-size     variant `_URC_FAILURE`: 0 bytes
print-type-size type: `std::process::ExitCode`: 1 bytes, alignment: 1 bytes
print-type-size     field `.0`: 1 bytes
print-type-size type: `std::sys::pal::unix::process::process_common::ExitCode`: 1 bytes, alignment: 1 bytes
print-type-size     field `.0`: 1 bytes
print-type-size type: `std::marker::PhantomData<dyn std::ops::Fn() -> i32 + std::marker::Sync + std::panic::RefUnwindSafe>`: 0 bytes, alignment: 1 bytes
print-type-size type: `unwind::libunwind::_Unwind_Context`: 0 bytes, alignment: 1 bytes

@compiler-errors
Copy link
Member

A "quick" fix would probably need to do saturating sub...

@jieyouxu jieyouxu added A-layout Area: Memory layout of types S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Mar 15, 2024
@lolbinarycat
Copy link
Contributor

triage: no ice on stable or nightly rust (playground)

@matthiaskrgr
Copy link
Member Author

image

this requires debug assertions...

@matthiaskrgr matthiaskrgr reopened this Sep 8, 2024
@matthiaskrgr
Copy link
Member Author

also also required "-Zprint-type-sizes" back then which you can't even enable on the playground?

in general, its bad idea to use playground or godbolt in order to try to reproduce ices since you have very limited control of how these compilers are actually called.

@lolbinarycat
Copy link
Contributor

i think it's also a bad idea to put essential information for reproduction in the labels.

that label's description is also very unclear as to what needs to be compiled with debug assertions.

@matthiaskrgr
Copy link
Member Author

fair, I've updated the label description, hopefully its a bit more clear now, if you have a better idea, feel free to alter it any further!

imo if it was the mvce that would require debug assertions to crash rustc, there would be a -Cdebug-assertions or something like that in the reproduction steps, but I'm also the one that wrote the ticket and created the requires-debug-assertions label so I'm biased a fair bit 😅

@lolbinarycat
Copy link
Contributor

i've edited the issue description to be more clear. i'm a firm believer that labels should only be used for metadata, the issue should be entirely self-explanatory without reading labels, and expecially without reading label descriptions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-layout Area: Memory layout of types C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ requires-debug-assertions This issue requires a build of rustc or tooling with debug-assertions in some way S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue 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

5 participants