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: assertion failed: layout.is_sized() #123154

Closed
Naserume opened this issue Mar 28, 2024 · 2 comments · Fixed by #123491
Closed

ICE: assertion failed: layout.is_sized() #123154

Naserume opened this issue Mar 28, 2024 · 2 comments · Fixed by #123491
Assignees
Labels
A-const-eval Area: Constant evaluation (MIR interpretation) 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) ❄️ S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. 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

@Naserume
Copy link

Naserume commented Mar 28, 2024

Code

(reduced)

struct AA {
    pub data: [&usize]
}

impl AA {
    const fn new() -> Self { }
}

static AA = AA::new();

fn main() { }
Original

//@ check-pass

pub struct AA {
    pub data: [&usize],
}

impl AA {
    pub const fn new() -> Self {
        let mut res: AA = AA { data: [0; W 1] };
        res.data[0] = 5;
        res
    }
}

static mut BB: AA = AA::new();

fn main() {
    let ptr = unsafe { &mut BB };
    //~^ WARN mutable reference to mutable static is discouraged [static_mut_refs]
    for a in ptr.data.iter() {
        println!("{}", a);
    }
}

Meta

rustc --version --verbose:

rustc 1.79.0-nightly (c9f8f3438 2024-03-27)
binary: rustc
commit-hash: c9f8f3438a8134a413aa5d4903e0196e44e37bbc
commit-date: 2024-03-27
host: x86_64-apple-darwin
release: 1.79.0-nightly
LLVM version: 18.1.2

Error output

error[E0106]: missing lifetime specifier
 --> ./2A05930450229E90EA4891C95FF25ECB266E9736590D4E1A90761DAAF428CA86.rs:2:16
  |
2 |     pub data: [&usize]
  |                ^ expected named lifetime parameter
  |
help: consider introducing a named lifetime parameter
  |
1 ~ struct AA<'a> {
2 ~     pub data: [&'a usize]
  |

error: missing type for `static` item
 --> ./2A05930450229E90EA4891C95FF25ECB266E9736590D4E1A90761DAAF428CA86.rs:9:10
  |
9 | static AA = AA::new();
  |          ^ help: provide a type for the static variable: `: AA`

thread 'rustc' panicked at compiler/rustc_const_eval/src/const_eval/eval_queries.rs:53:5:
assertion failed: layout.is_sized()
Backtrace

thread 'rustc' panicked at compiler/rustc_const_eval/src/const_eval/eval_queries.rs:53:5:
assertion failed: layout.is_sized()
stack backtrace:
   0:        0x10f1aee93 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h8622fa9b8f01ae29
   1:        0x10f1fccab - core::fmt::write::hfef1e936b89e9e59
   2:        0x10f1a4fee - std::io::Write::write_fmt::h6a176982c498677c
   3:        0x10f1aec81 - std::sys_common::backtrace::print::hc48f34eaebaf416f
   4:        0x10f1b1ca9 - std::panicking::default_hook::{{closure}}::h3b950a0bf2b644e8
   5:        0x10f1b1a10 - std::panicking::default_hook::he2d3412695f2d7b9
   6:        0x117d4d97d - std[a2ca1e908c4c108d]::panicking::update_hook::<alloc[8ecff88a291c7d81]::boxed::Box<rustc_driver_impl[629facdbd27b12dd]::install_ice_hook::{closure#0}>>::{closure#0}
   7:        0x10f1b27db - std::panicking::rust_panic_with_hook::h46c3037f3fbe8331
   8:        0x10f1b20cc - std::panicking::begin_panic_handler::{{closure}}::h0477e56916a6d858
   9:        0x10f1af369 - std::sys_common::backtrace::__rust_end_short_backtrace::hdac1cdd195496470
  10:        0x10f1b1e36 - _rust_begin_unwind
  11:        0x10f2178c5 - core::panicking::panic_fmt::hfd6b5bd1f65fa77f
  12:        0x10f217997 - core::panicking::panic::h3b6d6fec553595b9
  13:        0x117cd734e - rustc_const_eval[933ace3783df84a7]::const_eval::eval_queries::eval_static_initializer_provider
  14:        0x119197a52 - rustc_query_impl[7ec918e69dd505e]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[7ec918e69dd505e]::query_impl::eval_static_initializer::dynamic_query::{closure#2}::{closure#0}, rustc_middle[d0b008c68dae455]::query::erase::Erased<[u8; 16usize]>>
  15:        0x11915150e - <rustc_query_impl[7ec918e69dd505e]::query_impl::eval_static_initializer::dynamic_query::{closure#2} as core[d5cb36deb602d542]::ops::function::FnOnce<(rustc_middle[d0b008c68dae455]::ty::context::TyCtxt, rustc_span[8dae231bb2118e0f]::def_id::DefId)>>::call_once
  16:        0x118f5ece8 - rustc_query_system[40399bf5d3ff25f]::query::plumbing::try_execute_query::<rustc_query_impl[7ec918e69dd505e]::DynamicConfig<rustc_query_system[40399bf5d3ff25f]::query::caches::DefIdCache<rustc_middle[d0b008c68dae455]::query::erase::Erased<[u8; 16usize]>>, false, false, false>, rustc_query_impl[7ec918e69dd505e]::plumbing::QueryCtxt, false>
  17:        0x1191c174d - rustc_query_impl[7ec918e69dd505e]::query_impl::eval_static_initializer::get_query_non_incr::__rust_end_short_backtrace
  18:        0x117f85cab - <rustc_middle[d0b008c68dae455]::hir::map::Map>::par_body_owners::<rustc_hir_analysis[2d5e89c8dacd405d]::check_crate::{closure#3}>::{closure#0}
  19:        0x11808d24c - rustc_hir_analysis[2d5e89c8dacd405d]::check_crate
  20:        0x118504c40 - rustc_interface[cb93122c76eb07a8]::passes::analysis
  21:        0x119198eaa - rustc_query_impl[7ec918e69dd505e]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[7ec918e69dd505e]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[d0b008c68dae455]::query::erase::Erased<[u8; 1usize]>>
  22:        0x118f7fdde - rustc_query_system[40399bf5d3ff25f]::query::plumbing::try_execute_query::<rustc_query_impl[7ec918e69dd505e]::DynamicConfig<rustc_query_system[40399bf5d3ff25f]::query::caches::SingleCache<rustc_middle[d0b008c68dae455]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[7ec918e69dd505e]::plumbing::QueryCtxt, false>
  23:        0x1191a3287 - rustc_query_impl[7ec918e69dd505e]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  24:        0x117cfb942 - <rustc_interface[cb93122c76eb07a8]::queries::QueryResult<&rustc_middle[d0b008c68dae455]::ty::context::GlobalCtxt>>::enter::<core[d5cb36deb602d542]::result::Result<(), rustc_span[8dae231bb2118e0f]::ErrorGuaranteed>, rustc_driver_impl[629facdbd27b12dd]::run_compiler::{closure#0}::{closure#1}::{closure#3}>
  25:        0x117d5464b - rustc_interface[cb93122c76eb07a8]::interface::run_compiler::<core[d5cb36deb602d542]::result::Result<(), rustc_span[8dae231bb2118e0f]::ErrorGuaranteed>, rustc_driver_impl[629facdbd27b12dd]::run_compiler::{closure#0}>::{closure#0}
  26:        0x117d43d36 - std[a2ca1e908c4c108d]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[cb93122c76eb07a8]::util::run_in_thread_with_globals<rustc_interface[cb93122c76eb07a8]::util::run_in_thread_pool_with_globals<rustc_interface[cb93122c76eb07a8]::interface::run_compiler<core[d5cb36deb602d542]::result::Result<(), rustc_span[8dae231bb2118e0f]::ErrorGuaranteed>, rustc_driver_impl[629facdbd27b12dd]::run_compiler::{closure#0}>::{closure#0}, core[d5cb36deb602d542]::result::Result<(), rustc_span[8dae231bb2118e0f]::ErrorGuaranteed>>::{closure#0}, core[d5cb36deb602d542]::result::Result<(), rustc_span[8dae231bb2118e0f]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[d5cb36deb602d542]::result::Result<(), rustc_span[8dae231bb2118e0f]::ErrorGuaranteed>>
  27:        0x117d5a3a8 - <<std[a2ca1e908c4c108d]::thread::Builder>::spawn_unchecked_<rustc_interface[cb93122c76eb07a8]::util::run_in_thread_with_globals<rustc_interface[cb93122c76eb07a8]::util::run_in_thread_pool_with_globals<rustc_interface[cb93122c76eb07a8]::interface::run_compiler<core[d5cb36deb602d542]::result::Result<(), rustc_span[8dae231bb2118e0f]::ErrorGuaranteed>, rustc_driver_impl[629facdbd27b12dd]::run_compiler::{closure#0}>::{closure#0}, core[d5cb36deb602d542]::result::Result<(), rustc_span[8dae231bb2118e0f]::ErrorGuaranteed>>::{closure#0}, core[d5cb36deb602d542]::result::Result<(), rustc_span[8dae231bb2118e0f]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[d5cb36deb602d542]::result::Result<(), rustc_span[8dae231bb2118e0f]::ErrorGuaranteed>>::{closure#1} as core[d5cb36deb602d542]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  28:        0x10f1bbab9 - std::sys::pal::unix::thread::Thread::new::thread_start::h78e3183c2153313c
  29:     0x7ff818270202 - __pthread_start

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, I-ICE, T-compiler&template=ice.md

query stack during panic:
#0 [eval_static_initializer] evaluating initializer of static `AA`
#1 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0106`.

@Naserume Naserume 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 28, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Mar 28, 2024
@GrigorenkoPV
Copy link
Contributor

Regression in rust-lang-ci@fa215ae
The PR introducing the regression in this rollup is #122749 (cc @aliemjay)

searched nightlies: from nightly-2024-02-09 to nightly-2024-03-26
regressed nightly: nightly-2024-03-22
searched commit range: 1388d7a...0ad927c
regressed commit: 6a6cd65

bisected with cargo-bisect-rustc v0.6.8

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

cargo bisect-rustc -vv --preserve --access=github --start=2024-02-09 --end=2024-03-26 --regress=ice 

@jieyouxu jieyouxu added A-const-eval Area: Constant evaluation (MIR interpretation) 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 28, 2024
@gurry
Copy link
Contributor

gurry commented Apr 4, 2024

@rustbot claim

@matthiaskrgr matthiaskrgr added the S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. label Apr 15, 2024
jieyouxu added a commit to jieyouxu/rust that referenced this issue Apr 15, 2024
…al, r=oli-obk

Fix ICE in `eval_body_using_ecx`

Ensures `TypeckResults` is tainted by failing candidate assembly for types with error

Fixes rust-lang#123154
@bors bors closed this as completed in ea7eb71 Apr 16, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Apr 16, 2024
Rollup merge of rust-lang#123491 - gurry:123154-ice-unsized-struct-eval, r=oli-obk

Fix ICE in `eval_body_using_ecx`

Ensures `TypeckResults` is tainted by failing candidate assembly for types with error

Fixes rust-lang#123154
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-const-eval Area: Constant evaluation (MIR interpretation) 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) ❄️ S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. 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

Successfully merging a pull request may close this issue.

6 participants