rust-lang / rust-lang/rust

underflow while calculating type sizes

Open
#122,547 9 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-layout C-bug I-ICE requires-debug-assertions S-has-mcve T-compiler
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

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


Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with compiler/rustc_session/src/code_stats.rs:176 and reproduce the panic using -Zprint-type-sizes on the reduced enum example, with debug assertions enabled. Inspect the type-size calculation around that subtraction; done means the command completes without an underflow panic for the reported input.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.