Open matthiaskrgr opened 6 months ago
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
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
A "quick" fix would probably need to do saturating sub...
triage: no ice on stable or nightly rust (playground)
this requires debug assertions...
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.
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.
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 :sweat_smile:
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
only happens when rustc is compiled with debug assertions enabled
auto-reduced (treereduce-rust):
original code
original: ````rust //@ 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::(), 16);
assert_eq!(mem::size_of::(), 16);
assert_eq!(mem::align_of::(), 1);
assert_eq!(mem::size_of::(), 32);
assert_eq!(mem::align_of::(), 16);
assert_eq!(mem::size_of::(), 16);
assert_eq!(mem::align_of::(), 16);
assert_eq!(mem::size_of::(), 32);
}
````
Version information
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 -::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 - 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 - as core::ops::function::Fn>::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 - ::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 - ::enter::, 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::, 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::, rustc_interface[e9562a9c472c94f0]::interface::run_compiler, 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::, 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_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 - >::set::, 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::, rustc_interface[e9562a9c472c94f0]::util::run_in_thread_pool_with_globals, 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_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_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 - ::spawn_unchecked_::, 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 - ::spawn_unchecked_, 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::::spawn_unchecked_, 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]::panic::unwind_safe::AssertUnwindSafe<::spawn_unchecked_, 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::::spawn_unchecked_, 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 - ::spawn_unchecked_::, 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 - <::spawn_unchecked_, 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 - as core::ops::function::FnOnce>::call_once::h6534edd00de45d0a
at /home/matthias/vcs/github/rust_debug_assertions/library/alloc/src/boxed.rs:2020:9
40: 0x7f6901de823e - as core::ops::function::FnOnce>::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 -
43: 0x7f68fbd26a3c -
44: 0x0 -
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
```