Skip to content

Rustc panicked struct cannot be packed and aligned #83107

Closed
@Andy-Python-Programmer

Description

@Andy-Python-Programmer

Code

#[repr(packed, align(0x1000))]
struct GDT {
    kernel_null: GDTEntry,
    kernel_code: GDTEntry,
    kernel_data: GDTEntry,
    user_null: GDTEntry,
    user_code: GDTEntry,
    user_data: GDTEntry,
}

Meta

rustc --version --verbose:

rustc 1.51.0-nightly (44e3daf5e 2020-12-31)
binary: rustc
commit-hash: 44e3daf5eee8263dfc3a2509e78ddd1f6f783a0e
commit-date: 2020-12-31
host: x86_64-pc-windows-msvc
release: 1.51.0-nightly

Error output

error[E0587]: type has conflicting packed and align representation hints
  --> src\gdt.rs:34:1
   |
34 | / struct GDT {
35 | |     kernel_null: GDTEntry,
36 | |     kernel_code: GDTEntry,
37 | |     kernel_data: GDTEntry,
...  |
40 | |     user_data: GDTEntry,
41 | | }
   | |_^

error: internal compiler error: compiler\rustc_middle\src\ty\layout.rs:283:13: struct cannot be packed and aligned

thread 'rustc' panicked at 'Box<Any>', compiler\rustc_errors\src\lib.rs:958:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

note: 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.51.0-nightly (44e3daf5e 2020-12-31) running on x86_64-pc-windows-msvc

note: compiler flags: -Z unstable-options -C panic=abort -C embed-bitcode=no -C debuginfo=2 -C incremental --crate-type bin   

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
#0 [layout_raw] computing layout of `gdt::GDT`
#1 [layout_raw] computing layout of `core::option::Option<gdt::GDT>`
end of query stack
error: aborting due to 2 previous errors
Backtrace

PS H:\Andy\Rust\aero> $Env:RUST_BACKTRACE="full"; cargo run -- -L H:\Programs\qemu
   Compiling aero v0.1.0 (H:\Andy\Rust\aero)
error[E0587]: type has conflicting packed and align representation hints
  --> src\gdt.rs:34:1
   |
34 | / struct GDT {
35 | |     kernel_null: GDTEntry,
36 | |     kernel_code: GDTEntry,
37 | |     kernel_data: GDTEntry,
...  |
40 | |     user_data: GDTEntry,
41 | | }
   | |_^

error: internal compiler error: compiler\rustc_middle\src\ty\layout.rs:283:13: struct cannot be packed and aligned

thread 'rustc' panicked at 'Box<Any>', compiler\rustc_errors\src\lib.rs:958:9
stack backtrace:
   0:     0x7ff8a16bbcf5 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h17841712fc816a42
   1:     0x7ff8a16e84fb - core::fmt::write::ha3ea633b18d2da75
   2:     0x7ff8a16ad5dd - <std::io::IoSlice as core::fmt::Debug>::fmt::h9df41d37d9186c48
   3:     0x7ff8a16bfecd - std::panicking::take_hook::h78f8a454f3a4df82
   4:     0x7ff8a16bf9d3 - std::panicking::take_hook::h78f8a454f3a4df82
   5:     0x7ff8a1c72267 - rustc_driver::report_ice::h1d5c5221edf9c73d
   6:     0x7ff8a16c09af - std::panicking::rust_panic_with_hook::h9fd6ff93f12148ea
   7:     0x7ff8a6434cc0 - <rustc_errors::diagnostic::StringPart as core::fmt::Debug>::fmt::h7af67de8d2c3b61b
   8:     0x7ff8a6434c49 - <rustc_errors::diagnostic::StringPart as core::fmt::Debug>::fmt::h7af67de8d2c3b61b
   9:     0x7ff8a6434c61 - <rustc_errors::diagnostic::StringPart as core::fmt::Debug>::fmt::h7af67de8d2c3b61b
  10:     0x7ff8a642c3cb - rustc_errors::HandlerInner::err_count::h50c6ffc480963ac8
  11:     0x7ff8a642a532 - rustc_errors::Handler::bug::hb269e1fa812030f1
  12:     0x7ff8a5f72f5f - rustc_middle::util::bug::bug_fmt::ha0061901ad88904d
  13:     0x7ff8a5f6c260 - rustc_middle::ty::context::TyCtxt::article_and_description::h7f14ebacbcec16d1
  14:     0x7ff8a5f6c203 - rustc_middle::ty::context::TyCtxt::article_and_description::h7f14ebacbcec16d1
  15:     0x7ff8a5f72e89 - rustc_middle::util::bug::bug_fmt::ha0061901ad88904d
  16:     0x7ff8a5f72df7 - rustc_middle::util::bug::bug_fmt::ha0061901ad88904d
  17:     0x7ff8a6193605 - rustc_middle::ty::layout::provide::ha2084c0ba82f554f
  18:     0x7ff8a6198f58 - rustc_middle::ty::layout::provide::ha2084c0ba82f554f
  19:     0x7ff8a61910ce - <rustc_middle::ty::layout::LayoutError as core::fmt::Display>::fmt::h34fee29140973e21
  20:     0x7ff8a61aa2ce - rustc_middle::ty::print::pretty::<impl core::fmt::Display for &rustc_middle::ty::consts::Const>::fmt::he09b2b8aabe4d576
  21:     0x7ff8a615393f - rustc_middle::dep_graph::<impl rustc_query_system::dep_graph::DepKind for rustc_middle::dep_graph::dep_node::DepKind>::debug_node::h067a466f347afbfa
  22:     0x7ff8a60a3b9d - ZN12rustc_middle2ty111_DERIVE_rustc_data_structures_stable_hasher_HashStable_rustc_middle_ich_StableHashingContext_ctx_FOR_SymbolName159_$LT$impl$u20$rustc_data_structures..stable_hasher..HashStable$LT$rustc_middle..ich..hcx..StableHashingContext$GT$$u20$
  23:     0x7ff8a5f9f759 - <rustc_middle::traits::query::type_op::AscribeUserType as core::fmt::Debug>::fmt::h49093761cb58c0fe
  24:     0x7ff8a61cffcf - rustc_middle::ty::context::tls::TLV::__getit::h11706421b91a7f31
  25:     0x7ff8a61a0ae5 - <rustc_middle::ty::layout::LayoutCx<rustc_middle::ty::context::TyCtxt> as rustc_target::abi::LayoutOf>::layout_of::hf8e84e4cfee5d9c9
  26:     0x7ff8a604976f - rustc_middle::ty::structural_impls::<impl rustc_middle::ty::context::Lift for rustc_ast::ast::InlineAsmOptions>::lift_to_tcx::h4b1c274e9c27b41d
  27:     0x7ff8a5dfcd3a - <rustc_infer::infer::error_reporting::nice_region_error::find_anon_type::TyPathVisitor as rustc_hir::intravisit::Visitor>::visit_lifetime::hd4dc4e580c3cd603
  28:     0x7ff8a6049c14 - rustc_middle::ty::structural_impls::<impl rustc_middle::ty::context::Lift for rustc_ast::ast::InlineAsmOptions>::lift_to_tcx::h4b1c274e9c27b41d
  29:     0x7ff8a5deee98 - <rustc_infer::infer::error_reporting::nice_region_error::find_anon_type::TyPathVisitor as rustc_hir::intravisit::Visitor>::visit_lifetime::hd4dc4e580c3cd603
  30:     0x7ff8a61946d7 - rustc_middle::ty::layout::provide::ha2084c0ba82f554f
  31:     0x7ff8a61910ce - <rustc_middle::ty::layout::LayoutError as core::fmt::Display>::fmt::h34fee29140973e21
  32:     0x7ff8a61aa2ce - rustc_middle::ty::print::pretty::<impl core::fmt::Display for &rustc_middle::ty::consts::Const>::fmt::he09b2b8aabe4d576
  33:     0x7ff8a615393f - rustc_middle::dep_graph::<impl rustc_query_system::dep_graph::DepKind for rustc_middle::dep_graph::dep_node::DepKind>::debug_node::h067a466f347afbfa
  34:     0x7ff8a60a3b9d - ZN12rustc_middle2ty111_DERIVE_rustc_data_structures_stable_hasher_HashStable_rustc_middle_ich_StableHashingContext_ctx_FOR_SymbolName159_$LT$impl$u20$rustc_data_structures..stable_hasher..HashStable$LT$rustc_middle..ich..hcx..StableHashingContext$GT$$u20$
  35:     0x7ff8a5f9f759 - <rustc_middle::traits::query::type_op::AscribeUserType as core::fmt::Debug>::fmt::h49093761cb58c0fe
  36:     0x7ff8a61cffcf - rustc_middle::ty::context::tls::TLV::__getit::h11706421b91a7f31
  37:     0x7ff8a61a0ae5 - <rustc_middle::ty::layout::LayoutCx<rustc_middle::ty::context::TyCtxt> as rustc_target::abi::LayoutOf>::layout_of::hf8e84e4cfee5d9c9
  38:     0x7ff8a604976f - rustc_middle::ty::structural_impls::<impl rustc_middle::ty::context::Lift for rustc_ast::ast::InlineAsmOptions>::lift_to_tcx::h4b1c274e9c27b41d
  39:     0x7ff8a5dfcd3a - <rustc_infer::infer::error_reporting::nice_region_error::find_anon_type::TyPathVisitor as rustc_hir::intravisit::Visitor>::visit_lifetime::hd4dc4e580c3cd603
  40:     0x7ff8a6049c14 - rustc_middle::ty::structural_impls::<impl rustc_middle::ty::context::Lift for rustc_ast::ast::InlineAsmOptions>::lift_to_tcx::h4b1c274e9c27b41d
  41:     0x7ff8a5deedfe - <rustc_infer::infer::error_reporting::nice_region_error::find_anon_type::TyPathVisitor as rustc_hir::intravisit::Visitor>::visit_lifetime::hd4dc4e580c3cd603
  42:     0x7ff8a61946d7 - rustc_middle::ty::layout::provide::ha2084c0ba82f554f
  43:     0x7ff8a61910ce - <rustc_middle::ty::layout::LayoutError as core::fmt::Display>::fmt::h34fee29140973e21
  44:     0x7ff8a61aa2ce - rustc_middle::ty::print::pretty::<impl core::fmt::Display for &rustc_middle::ty::consts::Const>::fmt::he09b2b8aabe4d576
  45:     0x7ff8a615393f - rustc_middle::dep_graph::<impl rustc_query_system::dep_graph::DepKind for rustc_middle::dep_graph::dep_node::DepKind>::debug_node::h067a466f347afbfa
  46:     0x7ff8a60a3b9d - ZN12rustc_middle2ty111_DERIVE_rustc_data_structures_stable_hasher_HashStable_rustc_middle_ich_StableHashingContext_ctx_FOR_SymbolName159_$LT$impl$u20$rustc_data_structures..stable_hasher..HashStable$LT$rustc_middle..ich..hcx..StableHashingContext$GT$$u20$
  47:     0x7ff8a5f9f759 - <rustc_middle::traits::query::type_op::AscribeUserType as core::fmt::Debug>::fmt::h49093761cb58c0fe
  48:     0x7ff8a61cffcf - rustc_middle::ty::context::tls::TLV::__getit::h11706421b91a7f31
  49:     0x7ff8a61a0ae5 - <rustc_middle::ty::layout::LayoutCx<rustc_middle::ty::context::TyCtxt> as rustc_target::abi::LayoutOf>::layout_of::hf8e84e4cfee5d9c9
  50:     0x7ff8a604976f - rustc_middle::ty::structural_impls::<impl rustc_middle::ty::context::Lift for rustc_ast::ast::InlineAsmOptions>::lift_to_tcx::h4b1c274e9c27b41d
  51:     0x7ff8a5dfcdbc - <rustc_infer::infer::error_reporting::nice_region_error::find_anon_type::TyPathVisitor as rustc_hir::intravisit::Visitor>::visit_lifetime::hd4dc4e580c3cd603
  52:     0x7ff8a6049c14 - rustc_middle::ty::structural_impls::<impl rustc_middle::ty::context::Lift for rustc_ast::ast::InlineAsmOptions>::lift_to_tcx::h4b1c274e9c27b41d
  53:     0x7ff8a5deedfe - <rustc_infer::infer::error_reporting::nice_region_error::find_anon_type::TyPathVisitor as rustc_hir::intravisit::Visitor>::visit_lifetime::hd4dc4e580c3cd603
  54:     0x7ff8a61946d7 - rustc_middle::ty::layout::provide::ha2084c0ba82f554f
  55:     0x7ff8a61910ce - <rustc_middle::ty::layout::LayoutError as core::fmt::Display>::fmt::h34fee29140973e21
  56:     0x7ff8a61aa2ce - rustc_middle::ty::print::pretty::<impl core::fmt::Display for &rustc_middle::ty::consts::Const>::fmt::he09b2b8aabe4d576
  57:     0x7ff8a615393f - rustc_middle::dep_graph::<impl rustc_query_system::dep_graph::DepKind for rustc_middle::dep_graph::dep_node::DepKind>::debug_node::h067a466f347afbfa
  58:     0x7ff8a60a3b9d - ZN12rustc_middle2ty111_DERIVE_rustc_data_structures_stable_hasher_HashStable_rustc_middle_ich_StableHashingContext_ctx_FOR_SymbolName159_$LT$impl$u20$rustc_data_structures..stable_hasher..HashStable$LT$rustc_middle..ich..hcx..StableHashingContext$GT$$u20$
  59:     0x7ff8a5f9f759 - <rustc_middle::traits::query::type_op::AscribeUserType as core::fmt::Debug>::fmt::h49093761cb58c0fe
  60:     0x7ff8a61cffcf - rustc_middle::ty::context::tls::TLV::__getit::h11706421b91a7f31
  61:     0x7ff8a61a0ae5 - <rustc_middle::ty::layout::LayoutCx<rustc_middle::ty::context::TyCtxt> as rustc_target::abi::LayoutOf>::layout_of::hf8e84e4cfee5d9c9
  62:     0x7ff8a604976f - rustc_middle::ty::structural_impls::<impl rustc_middle::ty::context::Lift for rustc_ast::ast::InlineAsmOptions>::lift_to_tcx::h4b1c274e9c27b41d
  63:     0x7ff8a5dfcd3a - <rustc_infer::infer::error_reporting::nice_region_error::find_anon_type::TyPathVisitor as rustc_hir::intravisit::Visitor>::visit_lifetime::hd4dc4e580c3cd603
  64:     0x7ff8a6049c14 - rustc_middle::ty::structural_impls::<impl rustc_middle::ty::context::Lift for rustc_ast::ast::InlineAsmOptions>::lift_to_tcx::h4b1c274e9c27b41d
  65:     0x7ff8a5deedfe - <rustc_infer::infer::error_reporting::nice_region_error::find_anon_type::TyPathVisitor as rustc_hir::intravisit::Visitor>::visit_lifetime::hd4dc4e580c3cd603
  66:     0x7ff8a61946d7 - rustc_middle::ty::layout::provide::ha2084c0ba82f554f
  67:     0x7ff8a61910ce - <rustc_middle::ty::layout::LayoutError as core::fmt::Display>::fmt::h34fee29140973e21
  68:     0x7ff8a61aa2ce - rustc_middle::ty::print::pretty::<impl core::fmt::Display for &rustc_middle::ty::consts::Const>::fmt::he09b2b8aabe4d576
  69:     0x7ff8a615393f - rustc_middle::dep_graph::<impl rustc_query_system::dep_graph::DepKind for rustc_middle::dep_graph::dep_node::DepKind>::debug_node::h067a466f347afbfa
  70:     0x7ff8a60a3b9d - ZN12rustc_middle2ty111_DERIVE_rustc_data_structures_stable_hasher_HashStable_rustc_middle_ich_StableHashingContext_ctx_FOR_SymbolName159_$LT$impl$u20$rustc_data_structures..stable_hasher..HashStable$LT$rustc_middle..ich..hcx..StableHashingContext$GT$$u20$
  71:     0x7ff8a5f9f759 - <rustc_middle::traits::query::type_op::AscribeUserType as core::fmt::Debug>::fmt::h49093761cb58c0fe
  72:     0x7ff8a61cffcf - rustc_middle::ty::context::tls::TLV::__getit::h11706421b91a7f31
  73:     0x7ff8a61a0ae5 - <rustc_middle::ty::layout::LayoutCx<rustc_middle::ty::context::TyCtxt> as rustc_target::abi::LayoutOf>::layout_of::hf8e84e4cfee5d9c9
  74:     0x7ff8a44471fd - rustc_typeck::check::check::check_wf_new::hf875d581dce6c8aa
  75:     0x7ff8a4448182 - rustc_typeck::check::check::check_item_type::h47398e2438eb86aa
  76:     0x7ff8a4476b46 - <rustc_typeck::check::diverges::Diverges as core::fmt::Debug>::fmt::h7504e50660f2fc6e
  77:     0x7ff8a445329d - rustc_typeck::check::check::check_item_type::h47398e2438eb86aa
  78:     0x7ff8a454350d - <rustc_typeck::check::method::probe::ProbeScope as core::fmt::Debug>::fmt::h59d2657f5d430788
  79:     0x7ff8a44a47c6 - <rustc_typeck::check::closure::ExpectedSig as core::fmt::Debug>::fmt::h63fe94f68923706f
  80:     0x7ff8a446b90b - <rustc_typeck::check::diverges::Diverges as core::fmt::Debug>::fmt::h7504e50660f2fc6e
  81:     0x7ff8a44f73d4 - <rustc_typeck::outlives::explicit::ExplicitPredicatesMap as core::fmt::Debug>::fmt::h15dabe84aedef1e5
  82:     0x7ff8a43dd6f1 - rustc_typeck::check::writeback::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::resolve_type_vars_in_body::h4f2ac8a0d3054276
  83:     0x7ff8a440948f - rustc_typeck::check::writeback::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::resolve_type_vars_in_body::h4f2ac8a0d3054276
  84:     0x7ff8a45672f0 - rustc_typeck::check_crate::h5df5a5c81bc68977
  85:     0x7ff8a1e7bf6a - rustc_interface::passes::QueryContext::print_stats::h17fbfce938bb87d2
  86:     0x7ff8a1ca68cb - rustc_ast::util::parser::prec_let_scrutinee_needs_par::h0da38a96661182e5
  87:     0x7ff8a1ca82e6 - rustc_ast::util::parser::prec_let_scrutinee_needs_par::h0da38a96661182e5
  88:     0x7ff8a1c3023f - chalk_engine::table::AnswerIndex::increment::h2f98e994e5b69c67
  89:     0x7ff8a1c827d1 - <rustc_driver::Compilation as core::fmt::Debug>::fmt::hc313d7aa265f4349
  90:     0x7ff8a1c2c07c - chalk_engine::table::AnswerIndex::increment::h2f98e994e5b69c67
  91:     0x7ff8a1ca9a95 - rustc_ast::util::parser::prec_let_scrutinee_needs_par::h0da38a96661182e5
  92:     0x7ff8a1c744e5 - <rustc_driver::Compilation as core::fmt::Debug>::fmt::hc313d7aa265f4349
  93:     0x7ff8a1cabc0c - rustc_ast::util::parser::prec_let_scrutinee_needs_par::h0da38a96661182e5
  94:     0x7ff8a1c76395 - <rustc_driver::Compilation as core::fmt::Debug>::fmt::hc313d7aa265f4349
  95:     0x7ff8a1c9e8f5 - rustc_ast::util::parser::prec_let_scrutinee_needs_par::h0da38a96661182e5
  96:     0x7ff8a1c0d80d - <tracing_subscriber::util::TryInitError as core::fmt::Display>::fmt::hbce8757813226e4d
  97:     0x7ff8a16cffd3 - std::sys::windows::thread::Thread::new::h0de7ecb752bc4a62
  98:     0x7ff9231d7034 - BaseThreadInitThunk
  99:     0x7ff9241a2651 - RtlUserThreadStart

note: 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.51.0-nightly (44e3daf5e 2020-12-31) running on x86_64-pc-windows-msvc

note: compiler flags: -Z unstable-options -C panic=abort -C embed-bitcode=no -C debuginfo=2 -C incremental --crate-type bin

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
#0 [layout_raw] computing layout of `gdt::GDT`
#1 [layout_raw] computing layout of `core::option::Option<gdt::GDT>`
#2 [layout_raw] computing layout of `core::cell::UnsafeCell<core::option::Option<gdt::GDT>>`
#3 [layout_raw] computing layout of `spin::Once<gdt::GDT>`
#4 [layout_raw] computing layout of `lazy_static::lazy::Lazy<gdt::GDT>`
#5 [check_mod_item_types] checking item types in module `gdt`
#6 [analysis] running analysis passes on this crate
end of query stack

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-layoutArea: Memory layout of typesC-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️P-mediumMedium priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.glacierICE tracked in rust-lang/glacier.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions