Skip to content

ICE: Cannot transmute to non-Sized type #110151

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
stevefan1999-personal opened this issue Apr 10, 2023 · 2 comments · Fixed by #109959
Closed

ICE: Cannot transmute to non-Sized type #110151

stevefan1999-personal opened this issue Apr 10, 2023 · 2 comments · Fixed by #109959
Labels
C-bug Category: This is a bug. E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example 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

@stevefan1999-personal
Copy link

stevefan1999-personal commented Apr 10, 2023

Error

facebook/buck2#136

Meta

rustc --version --verbose:

rustc 1.70.0-nightly (23ee2af2f 2023-04-07)
binary: rustc
commit-hash: 23ee2af2f7669d521ad39ef8a506a4fa3d37ea5a
commit-date: 2023-04-07
host: x86_64-pc-windows-msvc
release: 1.70.0-nightly
LLVM version: 16.0.2

Notice

Should be able to consistently trigger on Windows platform

Backtrace
warning: error finalizing incremental compilation session directory `\\?\C:\Users\steve\AppData\Local\Temp\cargo-installeWlLuT\release\incremental\buck2_build_api-3bpejjqwe8ssu\s-gjx1f497xi-18v2t4g-working`: The system cannot find the file specified. (os error 2)

error: internal compiler error: no errors encountered even though `delay_span_bug` issued

error: internal compiler error: broken MIR in Item(WithOptConstParam { did: DefId(0:7299 ~ buck2_build_api[daa8]::artifact_groups::calculation::_assert_ensure_artifact_group_future_size::{closure#0}), const_param_did: None }) (after phase change to runtime-optimized) at bb2[1]:
                                Cannot transmute to non-`Sized` type impl futures::Future<Output = std::result::Result<artifact_groups::calculation::EnsureArtifactGroupReady, anyhow::Error>> + '_
   --> app\buck2_build_api\src\artifact_groups\calculation.rs:238:5
    |
238 |     static_assertions::assert_eq_size_ptr!(&v, &e);
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: delayed at    0: std::backtrace::Backtrace::disabled
               1: std::backtrace::Backtrace::force_capture
               2: <rustc_errors::HandlerInner>::emit_diagnostic
               3: <rustc_const_eval::transform::check_consts::qualifs::CustomEq as rustc_const_eval::transform::check_consts::qualifs::Qualif>::in_qualifs
               4: rustc_const_eval::transform::promote_consts::is_const_fn_in_array_repeat_expression
               5: <rustc_const_eval::transform::validate::Validator as rustc_middle::mir::MirPass>::run_pass
               6: <rustc_mir_transform::large_enums::EnumSizeOpt as rustc_middle::mir::MirPass>::is_enabled
               7: <rustc_mir_transform::remove_noop_landing_pads::RemoveNoopLandingPads as rustc_middle::mir::MirPass>::run_pass
               8: <&rustc_index::vec::IndexVec<rustc_middle::mir::Promoted, rustc_middle::mir::Body> as rustc_serialize::serialize::Decodable<rustc_query_impl::on_disk_cache::CacheDecoder>>::decode
               9: <rustc_span::def_id::DefId as rustc_serialize::serialize::Encodable<rustc_query_impl::on_disk_cache::CacheEncoder>>::encode
              10: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::as_any
              11: <rustc_metadata::creader::CStore>::from_tcx
              12: rustc_metadata::rmeta::encoder::encode_metadata
              13: rustc_metadata::rmeta::decoder::cstore_impl::provide_extern
              14: rustc_metadata::rmeta::encoder::encode_metadata
              15: rustc_metadata::fs::encode_and_write_metadata
              16: rustc_interface::passes::start_codegen
              17: rustc_interface::proc_macro_decls::provide
              18: <rustc_interface::queries::Queries>::ongoing_codegen
              19: <rustc_middle::ty::SymbolName as core::fmt::Display>::fmt
              20: rustc_driver_impl::args::arg_expand_all
              21: rustc_driver_impl::main
              22: rustc_driver_impl::args::arg_expand_all
              23: rustc_driver_impl::args::arg_expand_all
              24: std::sys::windows::thread::Thread::new
              25: BaseThreadInitThunk
              26: RtlUserThreadStart

    = note: this error: internal compiler error originates in the macro `static_assertions::assert_eq_size_ptr` (in Nightly builds, run with -Z macro-backtrace for more info)

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 (23ee2af2f 2023-04-07) running on x86_64-pc-windows-msvc

note: compiler flags: --crate-type lib -C opt-level=3 -C panic=abort -C embed-bitcode=no -C incremental=[REDACTED]

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

query stack during panic:
end of query stack
warning: `buck2_build_api` (lib) generated 1 warning
error: could not compile `buck2_build_api` (lib); 1 warning emitted
error: failed to compile `buck2 v0.1.0 (https://github.com/facebook/buck2.git#9178ac50)`, intermediate artifacts can be f
@stevefan1999-personal stevefan1999-personal 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 Apr 10, 2023
@Noratrieb Noratrieb changed the title static_assertions::assert_eq_size_ptr ICE ICE: Cannot transmute to non-Sized type Apr 10, 2023
@Noratrieb
Copy link
Member

I attempted to create a minimial reproduction based on the code I saw and was not able to get an ICE on the latest nightly (2023-04-09).

async fn empty() {}

async fn meow(a: [u8; 100]) {
	empty().await;
	dbg!(a);
}

fn main() {
	let v = meow([0; 100]);
	let e = [0u8; 202];
	let _ = || unsafe {
		use std::{mem, ptr};
		let mut copy = ptr::read(&v);
		ptr::write(&mut copy, mem::transmute(ptr::read(&e)));
		mem::forget(copy);
	};
}

Could you try updating to the latest nightly and see whether that fixed it? There have been a few issues with transmute that got fixed in the last few days.

@Noratrieb Noratrieb added the E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example label Apr 10, 2023
@JakobDegen
Copy link
Contributor

This is fixed by #109959

JohnTitor added a commit to JohnTitor/rust that referenced this issue Apr 11, 2023
…ompiler-errors

Fix transmute intrinsic mir validation ICE

I stumbled across this at work, the minimal reproducer is included as a test which ICEs before this change.

I'm not 100% sure this is the right fix, but it matches what we do in `mir_assign_valid_types` so seems reasonable at least.

fixes rust-lang#110151

r? `@lcnr` since they've been keeping the relevant logic correct, cc `@scottmcm`
@bors bors closed this as completed in fd40f51 Apr 12, 2023
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
C-bug Category: This is a bug. E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example 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