Skip to content

Broken MIR in DropGlue, Transmute is not supported in non-runtime phase Analysis(PostCleanup) #139698

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

Closed
saethlin opened this issue Apr 12, 2025 · 3 comments · Fixed by #139699
Closed
Labels
-Zvalidate-mir Unstable option: MIR validation A-MIR Area: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.html 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

@saethlin
Copy link
Member

I'm seeing the same ICE in about 70 crates. I should really build in some system to find the smallest one.

One of them that looks decently small is https://github.com/vmenge/speare, on commit 87f6a29f91ca60f17d6f9ed5757280a3bf73ffea if I run RUSTFLAGS=-Zvalidate-mir cargo +nightly build --tests I will get this ICE:

thread 'rustc' panicked at compiler/rustc_mir_transform/src/validate.rs:80:25:
broken MIR in DropGlue(DefId(2:2919 ~ core[74f8]::ptr::drop_in_place), Some(Coroutine(DefId(22:235 ~ speare[6d99]::spawn::{closure#0}), [one_for_all::Dad, one_for_all::Dad, (), std::future::ResumeTy, (), (), CoroutineWitness(DefId(22:235 ~ speare[6d99]::spawn::{closure#0}), [one_for_all::Dad, one_for_all::Dad]), (std::option::Option<std::time::Duration>, speare::Ctx<one_for_all::Dad>)]))) (after pass MentionedItems) at bb191[0]:
Transmute is not supported in non-runtime phase Analysis(PostCleanup).
stack backtrace:
   0: __rustc::rust_begin_unwind
   1: core::panicking::panic_fmt
   2: <rustc_mir_transform::validate::CfgChecker>::fail::<alloc::string::String>
   3: <rustc_mir_transform::validate::Validator as rustc_mir_transform::pass_manager::MirPass>::run_pass
   4: rustc_mir_transform::pass_manager::validate_body
   5: rustc_mir_transform::pass_manager::run_passes_inner
   6: rustc_mir_transform::shim::make_shim
      [... omitted 3 frames ...]
   7: <rustc_middle::ty::context::TyCtxt>::instance_mir
   8: rustc_monomorphize::mono_checks::check_mono_item
      [... omitted 1 frame ...]
   9: rustc_monomorphize::collector::items_of_instance
      [... omitted 1 frame ...]
  10: rustc_monomorphize::collector::collect_items_rec::{closure#0}
  11: rustc_monomorphize::collector::collect_items_rec
  12: rustc_monomorphize::collector::collect_items_rec
  13: rustc_monomorphize::collector::collect_items_rec
  14: rustc_monomorphize::collector::collect_items_rec
  15: rustc_monomorphize::collector::collect_items_rec
  16: rustc_monomorphize::collector::collect_items_rec
  17: rustc_monomorphize::collector::collect_items_rec
  18: rustc_monomorphize::collector::collect_items_rec
  19: rustc_monomorphize::collector::collect_items_rec
  20: rustc_monomorphize::collector::collect_items_rec
  21: rustc_monomorphize::partitioning::collect_and_partition_mono_items
      [... omitted 2 frames ...]
  22: <rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_ssa::traits::backend::CodegenBackend>::codegen_crate
  23: <rustc_interface::queries::Linker>::codegen_and_build_linker
  24: rustc_interface::passes::create_and_enter_global_ctxt::<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
  25: rustc_interface::interface::run_compiler::<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

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: please make sure that you have updated to the latest nightly

note: rustc 1.88.0-nightly (d2b3dd7c1 2025-04-11) running on x86_64-unknown-linux-gnu

note: compiler flags: -C embed-bitcode=no -C debuginfo=2 -C incremental=[REDACTED] -Z validate-mir

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

query stack during panic:
#0 [mir_shims] generating MIR shim for `core::ptr::drop_in_place`
#1 [check_mono_item] monomorphization-time checking
#2 [items_of_instance] collecting items used by `core::ptr::drop_in_place::<{async block@speare::spawn<one_for_all::Dad, one_for_all::Dad>::{closure#0}}> - shim(Some({async block@speare::spawn<one_for_all::Dad, one_for_all::Dad>::{closure#0}}))`
#3 [collect_and_partition_mono_items] collect_and_partition_mono_items
end of query stack
@saethlin saethlin added the C-bug Category: This is a bug. label Apr 12, 2025
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Apr 12, 2025
@saethlin saethlin added I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Apr 12, 2025
@saethlin
Copy link
Member Author

Bisects to #137112 cc @scottmcm

@saethlin
Copy link
Member Author

Ah it seems this was predicted in the PR that added the validation that is now failing (I've unresolved the conversation so that this link works properly): https://github.com/rust-lang/rust/pull/108442/files#r1118186993

@saethlin saethlin added -Zvalidate-mir Unstable option: MIR validation A-MIR Area: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.html T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Apr 12, 2025
@scottmcm
Copy link
Member

Dup of #137243 ?

@bors bors closed this as completed in c0ad72e Apr 14, 2025
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Apr 14, 2025
Rollup merge of rust-lang#139699 - compiler-errors:coroutine-drop-phase, r=scottmcm

Proactively update coroutine drop shim's phase to account for later passes applied during shim query

See comments in the pass and on test. Also see rust-lang#137264 (comment).

Fixes rust-lang#137243
Fixes rust-lang#139698

r? scottmcm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
-Zvalidate-mir Unstable option: MIR validation A-MIR Area: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.html 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
3 participants