Repository navigation
Description
Code
I am unable to provide a minimal, standalone reproduction code.
I attempted to extract the offending logic into a minimal reproduction (creating a !Sync async block and coercing it into a Pin<Box<dyn Future + Send + Sync>>), but the compiler correctly identified the type error and refused to compile without crashing.
However, in my full project (which involves hyper, tokio, and more complex control flow/enum wrapping), the compiler fails to catch this at the type-checking stage and instead crashes (ICE) during the MIR optimization phase.
Reproduction:
I have pushed the state of the project that triggers the ICE to a repository. You can reproduce it as follows:
- Clone the repository:
git clone https://github.com/canmi21/vane.git - Checkout the ICE state branch:
cd vane
git checkout future_sync_ice - Run the compiler to reproduce the ICE:
cargo check
Context of the crashing code:
The crash happens when trying to assign a !Sync future (due to hyper::upgrade::Upgraded) into a struct field that expects Send + Sync.
// In src/modules/stack/protocol/application/http/httpx.rs (approx line 160)
// 'tunnel_future' captures 'client_io' (hyper::upgrade::Upgraded) which is !Sync.
let tunnel_future = Box::pin(async move {
// Logic holding !Sync types across await points
match tokio::try_join!(client_upgrade, upstream_upgrade) {
// ...
}
});
// The crash happens here, when moving this future into a field expecting Sync:
// payload is an Enum variant where 'tunnel_task' is Option<Pin<Box<dyn Future + Send + Sync>>>
payload = PayloadState::Http(VaneBody::UpgradeBridge {
tunnel_task: Some(tunnel_future), // ICE triggers here
});Meta
rustc --version --verbose:
rustc 1.92.0 (ded5c06cf 2025-12-08)
binary: rustc
commit-hash: ded5c06cf21d2b93bffd5d884aa6e96934ee4234
commit-date: 2025-12-08
host: aarch64-apple-darwin
release: 1.92.0
LLVM version: 21.1.3
Error output
(vane) canmi@xyy ~/C/P/vane (latest)> cargo c
Compiling vane v0.6.7 (/Users/canmi/Canmi/Project/vane)
error: internal compiler error: compiler/rustc_mir_transform/src/validate.rs:81:25: broken MIR in Item(DefId(0:1845 ~ vane[1ecf]::modules::stack::protocol::application::http::httpx::serve_request::{closure#0})) (after phase change to runtime-optimized) at bb107[0]:
Unsize coercion, but `std::pin::Pin<std::boxed::Box<{async block@src/modules/stack/protocol/application/http/httpx.rs:134:35: 134:45}>>` isn't coercible to `std::pin::Pin<std::boxed::Box<dyn futures_util::Future<Output = ()> + std::marker::Send + std::marker::Sync>>`
--> src/modules/stack/protocol/application/http/httpx.rs:167:25
|
167 | tunnel_task: Some(tunnel_future),
| ^^^^^^^^^^^^^
thread 'rustc' (518628) panicked at compiler/rustc_mir_transform/src/validate.rs:81:25:
Box<dyn Any>
Backtrace
thread 'rustc' (519641) panicked at compiler/rustc_mir_transform/src/validate.rs:81:25:
Box<dyn Any>
stack backtrace:
0: 0x110f29384 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h2808c764b780ef77
1: 0x10e36b6d8 - core::fmt::write::h164e2e78980a3344
2: 0x110ee2504 - std::io::Write::write_fmt::hc5b2a4d160c11c86
3: 0x110ef45a8 - std::sys::backtrace::BacktraceLock::print::h765d16e49e83c7b3
4: 0x110efae2c - std::panicking::default_hook::{{closure}}::hf5d7ef6cefa10586
5: 0x110efaacc - std::panicking::default_hook::h8781bd6c5c54e4cc
6: 0x10ef19ae0 - std[dc0ae436bb89db06]::panicking::update_hook::<alloc[bc4fa8be2c1bb627]::boxed::Box<rustc_driver_impl[50cf2a748b5c59a1]::install_ice_hook::{closure#1}>>::{closure#0}
7: 0x110efb354 - std::panicking::panic_with_hook::h93c775fc227522dd
8: 0x10ef9ae04 - std[dc0ae436bb89db06]::panicking::begin_panic::<rustc_errors[49e2b406ffe14c44]::ExplicitBug>::{closure#0}
9: 0x10ef8859c - std[dc0ae436bb89db06]::sys::backtrace::__rust_end_short_backtrace::<std[dc0ae436bb89db06]::panicking::begin_panic<rustc_errors[49e2b406ffe14c44]::ExplicitBug>::{closure#0}, !>
10: 0x113cc7218 - std[dc0ae436bb89db06]::panicking::begin_panic::<rustc_errors[49e2b406ffe14c44]::ExplicitBug>
11: 0x113cc7dc8 - <rustc_errors[49e2b406ffe14c44]::diagnostic::BugAbort as rustc_errors[49e2b406ffe14c44]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
12: 0x113d3393c - <rustc_errors[49e2b406ffe14c44]::DiagCtxtHandle>::span_bug::<rustc_span[b61ca60f5275f53a]::span_encoding::Span, alloc[bc4fa8be2c1bb627]::string::String>
13: 0x113d349a8 - rustc_middle[3debd01596c306bb]::util::bug::opt_span_bug_fmt::<rustc_span[b61ca60f5275f53a]::span_encoding::Span>::{closure#0}
14: 0x10fb5dc04 - rustc_middle[3debd01596c306bb]::ty::context::tls::with_opt::<rustc_middle[3debd01596c306bb]::util::bug::opt_span_bug_fmt<rustc_span[b61ca60f5275f53a]::span_encoding::Span>::{closure#0}, !>::{closure#0}
15: 0x10fb36a68 - rustc_middle[3debd01596c306bb]::ty::context::tls::with_context_opt::<rustc_middle[3debd01596c306bb]::ty::context::tls::with_opt<rustc_middle[3debd01596c306bb]::util::bug::opt_span_bug_fmt<rustc_span[b61ca60f5275f53a]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
16: 0x113d33c64 - rustc_middle[3debd01596c306bb]::util::bug::span_bug_fmt::<rustc_span[b61ca60f5275f53a]::span_encoding::Span>
17: 0x10fe1ad7c - <rustc_mir_transform[30feda94a763ca72]::validate::CfgChecker>::fail::<alloc[bc4fa8be2c1bb627]::string::String>
18: 0x10ff43240 - <rustc_mir_transform[30feda94a763ca72]::validate::Validator as rustc_mir_transform[30feda94a763ca72]::pass_manager::MirPass>::run_pass
19: 0x10fed4a3c - rustc_mir_transform[30feda94a763ca72]::pass_manager::run_passes_inner
20: 0x10fe92928 - rustc_mir_transform[30feda94a763ca72]::run_optimization_passes
21: 0x10fe91cb8 - rustc_mir_transform[30feda94a763ca72]::optimized_mir
22: 0x1103abf30 - rustc_query_impl[1913c4dc82019177]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[1913c4dc82019177]::query_impl::optimized_mir::dynamic_query::{closure#2}::{closure#0}, rustc_middle[3debd01596c306bb]::query::erase::Erased<[u8; 8usize]>>
23: 0x1103f4e54 - rustc_query_system[55b68c9b31defbbe]::query::plumbing::try_execute_query::<rustc_query_impl[1913c4dc82019177]::DynamicConfig<rustc_query_system[55b68c9b31defbbe]::query::caches::DefIdCache<rustc_middle[3debd01596c306bb]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[1913c4dc82019177]::plumbing::QueryCtxt, true>
24: 0x1103a056c - rustc_query_impl[1913c4dc82019177]::plumbing::force_from_dep_node::<rustc_query_impl[1913c4dc82019177]::DynamicConfig<rustc_query_system[55b68c9b31defbbe]::query::caches::DefIdCache<rustc_middle[3debd01596c306bb]::query::erase::Erased<[u8; 8usize]>>, false, false, false>>
25: 0x11066c1a0 - <rustc_query_impl[1913c4dc82019177]::plumbing::query_callback<rustc_query_impl[1913c4dc82019177]::query_impl::optimized_mir::QueryType>::{closure#0} as core[efaf33ed1a5ac28d]::ops::function::FnOnce<(rustc_middle[3debd01596c306bb]::ty::context::TyCtxt, rustc_query_system[55b68c9b31defbbe]::dep_graph::dep_node::DepNode, rustc_query_system[55b68c9b31defbbe]::dep_graph::serialized::SerializedDepNodeIndex)>>::call_once
26: 0x110390780 - <rustc_query_system[55b68c9b31defbbe]::dep_graph::graph::DepGraphData<rustc_middle[3debd01596c306bb]::dep_graph::DepsType>>::try_mark_previous_green::<rustc_query_impl[1913c4dc82019177]::plumbing::QueryCtxt>
27: 0x11039072c - <rustc_query_system[55b68c9b31defbbe]::dep_graph::graph::DepGraphData<rustc_middle[3debd01596c306bb]::dep_graph::DepsType>>::try_mark_previous_green::<rustc_query_impl[1913c4dc82019177]::plumbing::QueryCtxt>
28: 0x11039072c - <rustc_query_system[55b68c9b31defbbe]::dep_graph::graph::DepGraphData<rustc_middle[3debd01596c306bb]::dep_graph::DepsType>>::try_mark_previous_green::<rustc_query_impl[1913c4dc82019177]::plumbing::QueryCtxt>
29: 0x1103905d8 - <rustc_query_system[55b68c9b31defbbe]::dep_graph::graph::DepGraphData<rustc_middle[3debd01596c306bb]::dep_graph::DepsType>>::try_mark_green::<rustc_query_impl[1913c4dc82019177]::plumbing::QueryCtxt>
30: 0x11040735c - rustc_query_system[55b68c9b31defbbe]::query::plumbing::try_execute_query::<rustc_query_impl[1913c4dc82019177]::DynamicConfig<rustc_query_system[55b68c9b31defbbe]::query::caches::DefaultCache<rustc_middle[3debd01596c306bb]::ty::PseudoCanonicalInput<rustc_middle[3debd01596c306bb]::ty::Ty>, rustc_middle[3debd01596c306bb]::query::erase::Erased<[u8; 16usize]>>, false, true, false>, rustc_query_impl[1913c4dc82019177]::plumbing::QueryCtxt, true>
31: 0x11056ada8 - rustc_query_impl[1913c4dc82019177]::query_impl::layout_of::get_query_incr::__rust_end_short_backtrace
32: 0x110e85b5c - <rustc_middle[3debd01596c306bb]::ty::layout::LayoutCx as rustc_middle[3debd01596c306bb]::ty::layout::LayoutOf>::spanned_layout_of
33: 0x110e495bc - <core[efaf33ed1a5ac28d]::iter::adapters::GenericShunt<core[efaf33ed1a5ac28d]::iter::adapters::by_ref_sized::ByRefSized<core[efaf33ed1a5ac28d]::iter::adapters::map::Map<core[efaf33ed1a5ac28d]::slice::iter::Iter<rustc_middle[3debd01596c306bb]::mir::query::CoroutineSavedTy>, rustc_ty_utils[f20e79acf91c0c4d]::layout::layout_of_uncached::{closure#12}>>, core[efaf33ed1a5ac28d]::result::Result<core[efaf33ed1a5ac28d]::convert::Infallible, &rustc_middle[3debd01596c306bb]::ty::layout::LayoutError>> as core[efaf33ed1a5ac28d]::iter::traits::iterator::Iterator>::next
34: 0x110e04a58 - core[efaf33ed1a5ac28d]::iter::adapters::try_process::<core[efaf33ed1a5ac28d]::iter::adapters::by_ref_sized::ByRefSized<core[efaf33ed1a5ac28d]::iter::adapters::map::Map<core[efaf33ed1a5ac28d]::slice::iter::Iter<rustc_middle[3debd01596c306bb]::mir::query::CoroutineSavedTy>, rustc_ty_utils[f20e79acf91c0c4d]::layout::layout_of_uncached::{closure#12}>>, rustc_abi[b9b81dfdd0cd95d4]::layout::ty::TyAndLayout<rustc_middle[3debd01596c306bb]::ty::Ty>, core[efaf33ed1a5ac28d]::result::Result<core[efaf33ed1a5ac28d]::convert::Infallible, &rustc_middle[3debd01596c306bb]::ty::layout::LayoutError>, <core[efaf33ed1a5ac28d]::iter::adapters::map::Map<core[efaf33ed1a5ac28d]::slice::iter::Iter<rustc_middle[3debd01596c306bb]::mir::query::CoroutineSavedTy>, rustc_ty_utils[f20e79acf91c0c4d]::layout::layout_of_uncached::{closure#12}> as core[efaf33ed1a5ac28d]::iter::traits::iterator::Iterator>::try_collect<rustc_index[3b6d27c33e9a86b4]::vec::IndexVec<rustc_middle[3debd01596c306bb]::mir::query::CoroutineSavedLocal, rustc_abi[b9b81dfdd0cd95d4]::layout::ty::TyAndLayout<rustc_middle[3debd01596c306bb]::ty::Ty>>>::{closure#0}, rustc_index[3b6d27c33e9a86b4]::vec::IndexVec<rustc_middle[3debd01596c306bb]::mir::query::CoroutineSavedLocal, rustc_abi[b9b81dfdd0cd95d4]::layout::ty::TyAndLayout<rustc_middle[3debd01596c306bb]::ty::Ty>>>
35: 0x110e40088 - rustc_ty_utils[f20e79acf91c0c4d]::layout::layout_of
36: 0x1103b1b74 - rustc_query_impl[1913c4dc82019177]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[1913c4dc82019177]::query_impl::layout_of::dynamic_query::{closure#2}::{closure#0}, rustc_middle[3debd01596c306bb]::query::erase::Erased<[u8; 16usize]>>
37: 0x1106c3f8c - <rustc_query_impl[1913c4dc82019177]::query_impl::layout_of::dynamic_query::{closure#2} as core[efaf33ed1a5ac28d]::ops::function::FnOnce<(rustc_middle[3debd01596c306bb]::ty::context::TyCtxt, rustc_middle[3debd01596c306bb]::ty::PseudoCanonicalInput<rustc_middle[3debd01596c306bb]::ty::Ty>)>>::call_once
38: 0x11040763c - rustc_query_system[55b68c9b31defbbe]::query::plumbing::try_execute_query::<rustc_query_impl[1913c4dc82019177]::DynamicConfig<rustc_query_system[55b68c9b31defbbe]::query::caches::DefaultCache<rustc_middle[3debd01596c306bb]::ty::PseudoCanonicalInput<rustc_middle[3debd01596c306bb]::ty::Ty>, rustc_middle[3debd01596c306bb]::query::erase::Erased<[u8; 16usize]>>, false, true, false>, rustc_query_impl[1913c4dc82019177]::plumbing::QueryCtxt, true>
39: 0x11056ada8 - rustc_query_impl[1913c4dc82019177]::query_impl::layout_of::get_query_incr::__rust_end_short_backtrace
40: 0x10f7c74bc - <rustc_middle[3debd01596c306bb]::ty::context::TyCtxt>::par_hir_body_owners::<rustc_interface[4523f22467e79f56]::passes::run_required_analyses::{closure#1}::{closure#0}>::{closure#0}
41: 0x10f80ffec - rustc_interface[4523f22467e79f56]::passes::analysis
42: 0x1103b1820 - rustc_query_impl[1913c4dc82019177]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[1913c4dc82019177]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[3debd01596c306bb]::query::erase::Erased<[u8; 0usize]>>
43: 0x1103f8708 - rustc_query_system[55b68c9b31defbbe]::query::plumbing::try_execute_query::<rustc_query_impl[1913c4dc82019177]::DynamicConfig<rustc_query_system[55b68c9b31defbbe]::query::caches::SingleCache<rustc_middle[3debd01596c306bb]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[1913c4dc82019177]::plumbing::QueryCtxt, true>
44: 0x110569204 - rustc_query_impl[1913c4dc82019177]::query_impl::analysis::get_query_incr::__rust_end_short_backtrace
45: 0x10eecd560 - rustc_interface[4523f22467e79f56]::passes::create_and_enter_global_ctxt::<core[efaf33ed1a5ac28d]::option::Option<rustc_interface[4523f22467e79f56]::queries::Linker>, rustc_driver_impl[50cf2a748b5c59a1]::run_compiler::{closure#0}::{closure#2}>
46: 0x10ef18174 - rustc_interface[4523f22467e79f56]::interface::run_compiler::<(), rustc_driver_impl[50cf2a748b5c59a1]::run_compiler::{closure#0}>::{closure#1}
47: 0x10ef0c734 - std[dc0ae436bb89db06]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[4523f22467e79f56]::util::run_in_thread_with_globals<rustc_interface[4523f22467e79f56]::util::run_in_thread_pool_with_globals<rustc_interface[4523f22467e79f56]::interface::run_compiler<(), rustc_driver_impl[50cf2a748b5c59a1]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
48: 0x10ef1e970 - <<std[dc0ae436bb89db06]::thread::Builder>::spawn_unchecked_<rustc_interface[4523f22467e79f56]::util::run_in_thread_with_globals<rustc_interface[4523f22467e79f56]::util::run_in_thread_pool_with_globals<rustc_interface[4523f22467e79f56]::interface::run_compiler<(), rustc_driver_impl[50cf2a748b5c59a1]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[efaf33ed1a5ac28d]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
49: 0x110ef1190 - std::sys::thread::unix::Thread::new::thread_start::h98270432b6aefc44
50: 0x18a0efbc8 - __pthread_cond_wait
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.92.0 (ded5c06cf 2025-12-08) running on aarch64-apple-darwin
note: compiler flags: --crate-type bin -C embed-bitcode=no -C debuginfo=2 -C split-debuginfo=unpacked -C incremental=[REDACTED]
note: some of the compiler flags provided by cargo are hidden
query stack during panic:
#0 [optimized_mir] optimizing MIR for `modules::stack::protocol::application::http::httpx::serve_request::{closure#0}`
#1 [layout_of] computing layout of `core::mem::maybe_uninit::MaybeUninit<{async fn body of modules::stack::protocol::application::http::httpx::serve_request()}>`
#2 [layout_of] computing layout of `{async block@src/modules/stack/protocol/application/http/httpx.rs:40:3: 40:13}`
#3 [analysis] running analysis passes on this crate
end of query stack
there was a panic while trying to force a dep node
try_mark_green dep node stack:
#0 layout_of(9d50d7303d967ddd-de30433fcf58b9f4)
#1 layout_of(dde471a2b8d826d3-3506269fa919b8c0)
#2 layout_of(7a4411078140b98a-63f10cb589b7d29b)
end of try_mark_green dep node stack
Activity
moxian commentedon Dec 25, 2025
Smaller, but still reliant on
futures_util::join(playground):Regression bisects to nightly-2024-09-26. PRs in range:
@rustbot label: +S-has-bisection +A-coercions +A-async-await
canmi21 commentedon Dec 26, 2025
One observation from my side: on macOS (rustc 1.92.0 (ded5c06 2025-12-08)), the provided reproducer does NOT ICE locally. Instead, it is rejected earlier with proper Send/Sync errors during type checking.
However, rust-analyzer reports a "broken MIR" diagnostic pointing to an unsize coercion from
Pin<Box<async block>>toPin<Box<dyn Future + Send + Sync>>, which suggests the compiler is still able to generate invalid MIR in some code paths.So it seems the behavior depends on the compilation pipeline / flags: some paths correctly reject the code, while others allow it to reach MIR validation and ICE.
Happy to provide logs if useful.
macOS rejected earlier
canmi21 commentedon Dec 26, 2025
@moxian It seems that this minimum reproduction code still has some conditional triggers. This cannot be directly triggered on my macos, but my project can be 100% triggered. Further investigation might be needed
moxian commentedon Dec 26, 2025
This is surprising! The example above ICEs for me both on WSL (ubuntu) and Windows (and on rust playground as linked). I can't think of a reason MacOS would behave differently here.
To minimize the code I used cargo-minimize (or more specifically my fork of it) run as
cargo minimize --cargo-subcmd 'check' --verify-fn='|output | output.out.contains("internal compiler error") && output.out.contains("compiler/rustc_mir_transform/src/validate.rs:81:25: broken MIR")' --bisect-delete-imports src/which did the bulk of the work, followed by some light manual cleanup.You can try following similar steps to get a repro that ICEs for you locally and maybe see what's the difference between the two.
canmi21 commentedon Dec 26, 2025
I've tried opening a repository to investigate. Currently, it has been optimized to reproduce ICE with over 200 lines of code. Let's see if we can continue to reduce it. I think this ICE is related to a certain warpper level code
https://github.com/canmi21/future-sync-ice/blob/main/src/main.rs
canmi21 commentedon Dec 26, 2025
And I also noticed that this situation triggered on macOS seems to be related to the mod layer. When I try to remove the mod hierarchy, it seems to disappear.
canmi21 commentedon Dec 26, 2025
@moxian I successfully extracted an ICE minimum problem reproduction code of approximately 70 lines (x
Some of the conditions and backtraces that I discovered can be found in the README.md file.
canmi21 commentedon Dec 26, 2025
You can check at Playground, this version will 100% casue ICE on macOS, We can compare these two versions. Maybe we still need to add a platform tag to this issue, or it might be two ICE issues?
Regarding the reproduction code you provide above, I guess it might be related to the recent Nightly version. It seems that the plugins in vscode are updated Nightly, while the Stable version on my mac only crashes with my ~70 line version and there are some very strange conditions that can trigger it, u can check it in my repo README
feishiheng commentedon Dec 28, 2025
I’ve put together an MRE that reliably reproduces the ICE on my machine.
However, my bisection led to a different result than previously reported; specifically, the crash started occurring with this commit. It’s possible we are looking at multiple related ICEs here.
Before the commit
With the commit
fish@ubuntu ~/p/i/future-sync-ice (main)>
As this is my first post on GitHub, I’d appreciate any feedback on the process or if I missed any conventions.
canmi21 commentedon Dec 28, 2025
Yes,This is what I said before
But there's still one problem. What you said on your machine refers to the linux platform, right? However, the one we discovered before does not trigger on macOS, and the other one I mentioned can be triggered on both macOS and the playground(linux),So before we have a clear understanding of that conditional trigger on macOS, we cannot merge these two minimum reproduction codes
feishiheng commentedon Dec 31, 2025
Yes.
Indeed, this area needs further looking into.
Sorry for the wait, I've been narrowing down the issue over the past few days. I found that the compiler does recognize the async block as non-Sync while evaluating obligations:
Log details
ice-150378.log
However, I’m still struggling to find where this error gets swallowed, leading to the late-stage panic in MIR opts. I'll ask for some help on zulip and keep at it. Best wishes for the New Year!
Fix ICE in MIR validation when coroutine has stalled trait predicates
Fix ICE in MIR validation when coroutine has stalled trait predicates
cyrgani commentedon Jun 28, 2026
Fixed by #152327.