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: SizeSkeleton::compute layout errored in layout.rs #109078

Closed
langston-barrett opened this issue Mar 13, 2023 · 2 comments · Fixed by #109101
Closed

ICE: SizeSkeleton::compute layout errored in layout.rs #109078

langston-barrett opened this issue Mar 13, 2023 · 2 comments · Fixed by #109101
Assignees
Labels
C-bug Category: This is a bug. 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.

Comments

@langston-barrett
Copy link

langston-barrett commented Mar 13, 2023

This is a fuzzed test case, found with tree-splicer and minimized with treereduce. I hope it's valid, please let me know (and many apologies) if it's not helpful! I searched the issue tracker like so, but found no similar issues.

Code

struct Foo(Option<Box<Fn(&EContext)>>);
const TRANSMUTED_U32: u32 = { std::mem::transmute(Foo(582)) };

Meta

rustc --version --verbose:

rustc 1.70.0-nightly (7b4f48927 2023-03-12)
binary: rustc
commit-hash: 7b4f48927dce585f747a58083b45ab62b9d73a53
commit-date: 2023-03-12
host: x86_64-unknown-linux-gnu
release: 1.70.0-nightly
LLVM version: 15.0.7

Error output

Backtrace

error[E0412]: cannot find type `EContext` in this scope
 --> ice_min.rs:1:27
  |
1 | struct Foo(Option<Box<Fn(&EContext)>>);
  |                           ^^^^^^^^ not found in this scope
  |
help: you might be missing a type parameter
  |
1 | struct Foo<EContext>(Option<Box<Fn(&EContext)>>);
  |           ++++++++++

warning: unnecessary braces around assigned value
 --> ice_min.rs:2:29
  |
2 | const TRANSMUTED_U32: u32 = { std::mem::transmute(Foo(582)) };
  |                             ^^                             ^^
  |
  = note: `#[warn(unused_braces)]` on by default
help: remove these braces
  |
2 - const TRANSMUTED_U32: u32 = { std::mem::transmute(Foo(582)) };
2 + const TRANSMUTED_U32: u32 = std::mem::transmute(Foo(582));
  |

error[E0601]: `main` function not found in crate `ice_min`
 --> ice_min.rs:2:63
  |
2 | const TRANSMUTED_U32: u32 = { std::mem::transmute(Foo(582)) };
  |                                                               ^ consider adding a `main` function to `ice_min.rs`

warning: trait objects without an explicit `dyn` are deprecated
 --> ice_min.rs:1:23
  |
1 | struct Foo(Option<Box<Fn(&EContext)>>);
  |                       ^^^^^^^^^^^^^
  |
  = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021!
  = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
  = note: `#[warn(bare_trait_objects)]` on by default
help: use `dyn`
  |
1 | struct Foo(Option<Box<dyn Fn(&EContext)>>);
  |                       +++

error: internal compiler error: compiler/rustc_middle/src/ty/layout.rs:320:26: SizeSkeleton::compute(*const (dyn for<'a> Fn(&'a [type error]) + 'static)): layout errored (the type `[type error]` has an unknown layout), yet tail `(dyn for<'a> Fn(&'a [type error]) + 'static)` is not a type parameter or a projection

thread 'rustc' panicked at 'Box<dyn Any>', /rustc/7b4f48927dce585f747a58083b45ab62b9d73a53/compiler/rustc_errors/src/lib.rs:1644:9
stack backtrace:
   0:     0x7f1b5ec5d51a - std::backtrace_rs::backtrace::libunwind::trace::hf7d75cca16fd1b61
                               at /rustc/7b4f48927dce585f747a58083b45ab62b9d73a53/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7f1b5ec5d51a - std::backtrace_rs::backtrace::trace_unsynchronized::hf5ec95734aab509d
                               at /rustc/7b4f48927dce585f747a58083b45ab62b9d73a53/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f1b5ec5d51a - std::sys_common::backtrace::_print_fmt::he95113413355c8cd
                               at /rustc/7b4f48927dce585f747a58083b45ab62b9d73a53/library/std/src/sys_common/backtrace.rs:65:5
   3:     0x7f1b5ec5d51a - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h072d12f2e69ca92b
                               at /rustc/7b4f48927dce585f747a58083b45ab62b9d73a53/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7f1b5ecc0c5e - core::fmt::write::h1d23f16415e96af2
                               at /rustc/7b4f48927dce585f747a58083b45ab62b9d73a53/library/core/src/fmt/mod.rs:1232:17
   5:     0x7f1b5ec50275 - std::io::Write::write_fmt::hcf1e413fde4ffcd5
                               at /rustc/7b4f48927dce585f747a58083b45ab62b9d73a53/library/std/src/io/mod.rs:1684:15
   6:     0x7f1b5ec5d2e5 - std::sys_common::backtrace::_print::h6b2b14bedd5177e7
                               at /rustc/7b4f48927dce585f747a58083b45ab62b9d73a53/library/std/src/sys_common/backtrace.rs:47:5
   7:     0x7f1b5ec5d2e5 - std::sys_common::backtrace::print::h09ccebfbcd382e89
                               at /rustc/7b4f48927dce585f747a58083b45ab62b9d73a53/library/std/src/sys_common/backtrace.rs:34:9
   8:     0x7f1b5ec6005f - std::panicking::default_hook::{{closure}}::h4ee055db778febc2
                               at /rustc/7b4f48927dce585f747a58083b45ab62b9d73a53/library/std/src/panicking.rs:271:22
   9:     0x7f1b5ec5fd9b - std::panicking::default_hook::ha74f60e3a15d95fb
                               at /rustc/7b4f48927dce585f747a58083b45ab62b9d73a53/library/std/src/panicking.rs:290:9
  10:     0x7f1b61fdf085 - rustc_driver_impl[d355a67661263e47]::DEFAULT_HOOK::{closure#0}::{closure#0}
  11:     0x7f1b5ec6089d - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h7f34603beb945e8f
                               at /rustc/7b4f48927dce585f747a58083b45ab62b9d73a53/library/alloc/src/boxed.rs:2002:9
  12:     0x7f1b5ec6089d - std::panicking::rust_panic_with_hook::h4b5d379936d4932f
                               at /rustc/7b4f48927dce585f747a58083b45ab62b9d73a53/library/std/src/panicking.rs:696:13
  13:     0x7f1b6254a371 - std[e52d7c968ed01318]::panicking::begin_panic::<rustc_errors[45159b7f7e36021d]::ExplicitBug>::{closure#0}
  14:     0x7f1b62545aa6 - std[e52d7c968ed01318]::sys_common::backtrace::__rust_end_short_backtrace::<std[e52d7c968ed01318]::panicking::begin_panic<rustc_errors[45159b7f7e36021d]::ExplicitBug>::{closure#0}, !>
  15:     0x7f1b625ce046 - std[e52d7c968ed01318]::panicking::begin_panic::<rustc_errors[45159b7f7e36021d]::ExplicitBug>
  16:     0x7f1b62599e06 - std[e52d7c968ed01318]::panic::panic_any::<rustc_errors[45159b7f7e36021d]::ExplicitBug>
  17:     0x7f1b62595966 - <rustc_errors[45159b7f7e36021d]::HandlerInner>::bug::<&alloc[fc860cae0dfa1ab1]::string::String>
  18:     0x7f1b62595630 - <rustc_errors[45159b7f7e36021d]::Handler>::bug::<&alloc[fc860cae0dfa1ab1]::string::String>
  19:     0x7f1b62581a9b - rustc_middle[a96ac5d591578447]::util::bug::opt_span_bug_fmt::<rustc_span[f8bdfaef83e46314]::span_encoding::Span>::{closure#0}
  20:     0x7f1b625804fa - rustc_middle[a96ac5d591578447]::ty::context::tls::with_opt::<rustc_middle[a96ac5d591578447]::util::bug::opt_span_bug_fmt<rustc_span[f8bdfaef83e46314]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  21:     0x7f1b625804c6 - rustc_middle[a96ac5d591578447]::ty::context::tls::with_context_opt::<rustc_middle[a96ac5d591578447]::ty::context::tls::with_opt<rustc_middle[a96ac5d591578447]::util::bug::opt_span_bug_fmt<rustc_span[f8bdfaef83e46314]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  22:     0x7f1b625819e6 - rustc_middle[a96ac5d591578447]::util::bug::opt_span_bug_fmt::<rustc_span[f8bdfaef83e46314]::span_encoding::Span>
  23:     0x7f1b605fc4b3 - rustc_middle[a96ac5d591578447]::util::bug::bug_fmt
  24:     0x7f1b60fad01c - <rustc_middle[a96ac5d591578447]::ty::layout::SizeSkeleton>::compute
  25:     0x7f1b62539aba - <rustc_middle[a96ac5d591578447]::ty::layout::SizeSkeleton>::compute::{closure#0}
  26:     0x7f1b60fad07c - <rustc_middle[a96ac5d591578447]::ty::layout::SizeSkeleton>::compute
  27:     0x7f1b62539aba - <rustc_middle[a96ac5d591578447]::ty::layout::SizeSkeleton>::compute::{closure#0}
  28:     0x7f1b60fad07c - <rustc_middle[a96ac5d591578447]::ty::layout::SizeSkeleton>::compute
  29:     0x7f1b62539aba - <rustc_middle[a96ac5d591578447]::ty::layout::SizeSkeleton>::compute::{closure#0}
  30:     0x7f1b60fad07c - <rustc_middle[a96ac5d591578447]::ty::layout::SizeSkeleton>::compute
  31:     0x7f1b62539aba - <rustc_middle[a96ac5d591578447]::ty::layout::SizeSkeleton>::compute::{closure#0}
  32:     0x7f1b60fad143 - <rustc_middle[a96ac5d591578447]::ty::layout::SizeSkeleton>::compute
  33:     0x7f1b62539aba - <rustc_middle[a96ac5d591578447]::ty::layout::SizeSkeleton>::compute::{closure#0}
  34:     0x7f1b60fad07c - <rustc_middle[a96ac5d591578447]::ty::layout::SizeSkeleton>::compute
  35:     0x7f1b6154bd55 - <rustc_hir_typeck[8554c3125ad8338a]::fn_ctxt::FnCtxt>::check_transmute
  36:     0x7f1b60ecf984 - rustc_hir_typeck[8554c3125ad8338a]::typeck
  37:     0x7f1b60a52536 - rustc_query_system[704b80a7bc44cd49]::query::plumbing::try_execute_query::<rustc_query_impl[217bee59c5548bf5]::queries::typeck, rustc_query_impl[217bee59c5548bf5]::plumbing::QueryCtxt>
  38:     0x7f1b60a51e83 - <rustc_query_impl[217bee59c5548bf5]::Queries as rustc_middle[a96ac5d591578447]::ty::query::QueryEngine>::typeck
  39:     0x7f1b5ffd9299 - rustc_hir_analysis[357075c2c3fc2a7b]::check::check::check_mod_item_types
  40:     0x7f1b61614a0e - rustc_query_system[704b80a7bc44cd49]::query::plumbing::try_execute_query::<rustc_query_impl[217bee59c5548bf5]::queries::check_mod_item_types, rustc_query_impl[217bee59c5548bf5]::plumbing::QueryCtxt>
  41:     0x7f1b61614593 - <rustc_query_impl[217bee59c5548bf5]::Queries as rustc_middle[a96ac5d591578447]::ty::query::QueryEngine>::check_mod_item_types
  42:     0x7f1b602f7e44 - <rustc_session[7e23441c2db8ce4a]::session::Session>::time::<(), rustc_hir_analysis[357075c2c3fc2a7b]::check_crate::{closure#6}>
  43:     0x7f1b602f4d88 - rustc_hir_analysis[357075c2c3fc2a7b]::check_crate
  44:     0x7f1b602ead12 - rustc_interface[6bf42eb308c32713]::passes::analysis
  45:     0x7f1b617f371c - rustc_query_system[704b80a7bc44cd49]::query::plumbing::try_execute_query::<rustc_query_impl[217bee59c5548bf5]::queries::analysis, rustc_query_impl[217bee59c5548bf5]::plumbing::QueryCtxt>
  46:     0x7f1b617f3410 - <rustc_query_impl[217bee59c5548bf5]::Queries as rustc_middle[a96ac5d591578447]::ty::query::QueryEngine>::analysis
  47:     0x7f1b616182f9 - <rustc_middle[a96ac5d591578447]::ty::context::GlobalCtxt>::enter::<rustc_driver_impl[d355a67661263e47]::run_compiler::{closure#1}::{closure#2}::{closure#4}, core[125d846441ac421f]::result::Result<(), rustc_span[f8bdfaef83e46314]::ErrorGuaranteed>>
  48:     0x7f1b61210498 - rustc_span[f8bdfaef83e46314]::with_source_map::<core[125d846441ac421f]::result::Result<(), rustc_span[f8bdfaef83e46314]::ErrorGuaranteed>, rustc_interface[6bf42eb308c32713]::interface::run_compiler<core[125d846441ac421f]::result::Result<(), rustc_span[f8bdfaef83e46314]::ErrorGuaranteed>, rustc_driver_impl[d355a67661263e47]::run_compiler::{closure#1}>::{closure#0}::{closure#0}>
  49:     0x7f1b6120770c - std[e52d7c968ed01318]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[6bf42eb308c32713]::util::run_in_thread_pool_with_globals<rustc_interface[6bf42eb308c32713]::interface::run_compiler<core[125d846441ac421f]::result::Result<(), rustc_span[f8bdfaef83e46314]::ErrorGuaranteed>, rustc_driver_impl[d355a67661263e47]::run_compiler::{closure#1}>::{closure#0}, core[125d846441ac421f]::result::Result<(), rustc_span[f8bdfaef83e46314]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[125d846441ac421f]::result::Result<(), rustc_span[f8bdfaef83e46314]::ErrorGuaranteed>>
  50:     0x7f1b6120713a - <<std[e52d7c968ed01318]::thread::Builder>::spawn_unchecked_<rustc_interface[6bf42eb308c32713]::util::run_in_thread_pool_with_globals<rustc_interface[6bf42eb308c32713]::interface::run_compiler<core[125d846441ac421f]::result::Result<(), rustc_span[f8bdfaef83e46314]::ErrorGuaranteed>, rustc_driver_impl[d355a67661263e47]::run_compiler::{closure#1}>::{closure#0}, core[125d846441ac421f]::result::Result<(), rustc_span[f8bdfaef83e46314]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[125d846441ac421f]::result::Result<(), rustc_span[f8bdfaef83e46314]::ErrorGuaranteed>>::{closure#1} as core[125d846441ac421f]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  51:     0x7f1b5ec6a793 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hc0a50816e1eb2bba
                               at /rustc/7b4f48927dce585f747a58083b45ab62b9d73a53/library/alloc/src/boxed.rs:1988:9
  52:     0x7f1b5ec6a793 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hb2f83fc2049033c3
                               at /rustc/7b4f48927dce585f747a58083b45ab62b9d73a53/library/alloc/src/boxed.rs:1988:9
  53:     0x7f1b5ec6a793 - std::sys::unix::thread::Thread::new::thread_start::hce5861512f8bf7ea
                               at /rustc/7b4f48927dce585f747a58083b45ab62b9d73a53/library/std/src/sys/unix/thread.rs:108:17
  54:     0x7f1b5e9d4ff2 - start_thread
  55:     0x7f1b5ea57bfc - clone3
  56:                0x0 - <unknown>

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.70.0-nightly (7b4f48927 2023-03-12) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [typeck] type-checking `TRANSMUTED_U32`
#1 [check_mod_item_types] checking item types in top-level module
#2 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 3 previous errors; 2 warnings emitted

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

@langston-barrett langston-barrett added C-bug Category: This is a bug. 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. labels Mar 13, 2023
@Noratrieb
Copy link
Member

searched nightlies: from nightly-2021-01-01 to nightly-2023-03-12
regressed nightly: nightly-2023-01-05
searched commit range: c757267...659e169
regressed commit: ddad1e1

bisected with cargo-bisect-rustc v0.6.5

Host triple: x86_64-unknown-linux-gnu
Reproduce with:

cargo bisect-rustc 2021-01-01 --end 2023-03-12 --regress ice --access github

Note that this requires edition 2015/2018, as edition 2021 hard errors on the bare trait object before ever getting to layout code.

cc @compiler-errors

@compiler-errors
Copy link
Member

@rustbot claim

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. 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.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants