-
-
Notifications
You must be signed in to change notification settings - Fork 14.3k
Open
Labels
A-ABIArea: Concerning the application binary interface (ABI)Area: Concerning the application binary interface (ABI)C-bugCategory: This is a bug.Category: This is a bug.F-async_drop`#![feature(async_drop)]``#![feature(async_drop)]`F-gen_blocks`gen {}` expressions that produce `Iterator`s`gen {}` expressions that produce `Iterator`sT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
I tried this code:
#![feature(async_drop)]
#![feature(gen_blocks)]
fn main() {
let mut gn = gen {
yield 1;
};
let _ = std::pin::pin!(unsafe { std::future::async_drop_in_place(&mut gn) })
.poll(&mut std::task::Context::from_waker(std::task::Waker::noop()));
}compiled with cg_clif.
I expected to see this happen: It compiles fine.
Instead, this happened: cg_clif crashes because of a mismatch between the FnSig and MIR args.
At the MIR level there is only a single argument:
fn std::future::async_drop_in_place::{closure#0}(_1: std::pin::Pin<&mut {async fn body of std::future::async_drop_in_place<{gen block@foo.rs:5:18: 5:21}>()}>) -> std::task::Poll<()>while the FnAbi also has a Context argument:
FnAbi {
args: [
ArgAbi {
layout: TyAndLayout {
ty: Pin<&mut {async fn body of async_drop_in_place<{gen block@foo.rs:5:18: 5:21}>()}>,
layout: Layout { size: Size(8 bytes), align: AbiAlign { abi: Align(8 bytes) }, backend_repr: Scalar(Initialized { value: Pointer(AddressSpace(0)), valid_range: 1..=18446744073709551615 }), fields: Arbitrary { offsets: [Size(0 bytes)], memory_index: [0] }, largest_niche: Some(Niche { offset: Size(0 bytes), value: Pointer(AddressSpace(0)), valid_range: 1..=18446744073709551615 }), uninhabited: false, variants: Single { index: 0 }, max_repr_align: None, unadjusted_abi_align: Align(8 bytes), randomization_seed: 935286932771840309 }
},
mode: Direct(ArgAttributes { regular: NonNull | NoUndef, arg_ext: None, pointee_size: Size(0 bytes), pointee_align: Some(Align(8 bytes)) })
},
ArgAbi {
layout: TyAndLayout {
ty: &mut Context<'_>,
layout: Layout { size: Size(8 bytes), align: AbiAlign { abi: Align(8 bytes) }, backend_repr: Scalar(Initialized { value: Pointer(AddressSpace(0)), valid_range: 1..=18446744073709551615 }), fields: Primitive, largest_niche: Some(Niche { offset: Size(0 bytes), value: Pointer(AddressSpace(0)), valid_range: 1..=18446744073709551615 }), uninhabited: false, variants: Single { index: 0 }, max_repr_align: None, unadjusted_abi_align: Align(8 bytes), randomization_seed: 281492156579847 }
},
mode: Direct(ArgAttributes { regular: NonNull | NoUndef, arg_ext: None, pointee_size: Size(0 bytes), pointee_align: Some(Align(8 bytes)) })
}
],
ret: ArgAbi {
layout: TyAndLayout {
ty: Poll<()>,
layout: Layout { size: Size(1 bytes), align: AbiAlign { abi: Align(1 bytes) }, backend_repr: Scalar(Initialized { value: Int(I8, false), valid_range: 0..=1 }), fields: Arbitrary { offsets: [Size(0 bytes)], memory_index: [0] }, largest_niche: Some(Niche { offset: Size(0 bytes), value: Int(I8, false), valid_range: 0..=1 }), uninhabited: false, variants: Multiple { tag: Initialized { value: Int(I8, false), valid_range: 0..=1 }, tag_encoding: Direct, tag_field: 0, variants: [Layout { size: Size(1 bytes), align: AbiAlign { abi: Align(1 bytes) }, backend_repr: Scalar(Initialized { value: Int(I8, false), valid_range: 0..=1 }), fields: Arbitrary { offsets: [Size(1 bytes)], memory_index: [0] }, largest_niche: None, uninhabited: false, variants: Single { index: 0 }, max_repr_align: None, unadjusted_abi_align: Align(1 bytes), randomization_seed: 3966823494683985603 }, Layout { size: Size(1 bytes), align: AbiAlign { abi: Align(1 bytes) }, backend_repr: Memory { sized: true }, fields: Arbitrary { offsets: [], memory_index: [] }, largest_niche: None, uninhabited: false, variants: Single { index: 1 }, max_repr_align: None, unadjusted_abi_align: Align(1 bytes), randomization_seed: 3966823494683985603 }] }, max_repr_align: None, unadjusted_abi_align: Align(1 bytes), randomization_seed: 11900470484051956809 }
},
mode: Direct(ArgAttributes { regular: NoUndef, arg_ext: Zext, pointee_size: Size(0 bytes), pointee_align: None })
},
c_variadic: false,
fixed_count: 2,
conv: Rust,
can_unwind: false
}Meta
rustc --version --verbose:
rustc 1.92.0-nightly (f6092f224 2025-09-22)
binary: rustc
commit-hash: f6092f224d2b1774b31033f12d0bee626943b02f
commit-date: 2025-09-22
host: aarch64-unknown-linux-gnu
release: 1.92.0-nightly
LLVM version: 21.1.1
Backtrace
thread 'rustc' (1204438) panicked at src/abi/mod.rs:303:5:
assertion `left == right` failed: ArgAbi left behind for FnAbi { args: [ArgAbi { layout: TyAndLayout { ty: Pin<&mut {async fn body of async_drop_in_place<{gen [email protected]:5:18: 5:21}>()}>, layout: Layout { size: Size(8 bytes), align: AbiAlign { abi: Align(8 bytes) }, backend_repr: Scalar(Initialized { value: Pointer(AddressSpace(0)), valid_range: 1..=18446744073709551615 }), fields: Arbitrary { offsets: [Size(0 bytes)], memory_index: [0] }, largest_niche: Some(Niche { offset: Size(0 bytes), value: Pointer(AddressSpace(0)), valid_range: 1..=18446744073709551615 }), uninhabited: false, variants: Single { index: 0 }, max_repr_align: None, unadjusted_abi_align: Align(8 bytes), randomization_seed: 935286932771840309 } }, mode: Direct(ArgAttributes { regular: NonNull | NoUndef, arg_ext: None, pointee_size: Size(0 bytes), pointee_align: Some(Align(8 bytes)) }) }, ArgAbi { layout: TyAndLayout { ty: &mut Context<'_>, layout: Layout { size: Size(8 bytes), align: AbiAlign { abi: Align(8 bytes) }, backend_repr: Scalar(Initialized { value: Pointer(AddressSpace(0)), valid_range: 1..=18446744073709551615 }), fields: Primitive, largest_niche: Some(Niche { offset: Size(0 bytes), value: Pointer(AddressSpace(0)), valid_range: 1..=18446744073709551615 }), uninhabited: false, variants: Single { index: 0 }, max_repr_align: None, unadjusted_abi_align: Align(8 bytes), randomization_seed: 281492156579847 } }, mode: Direct(ArgAttributes { regular: NonNull | NoUndef, arg_ext: None, pointee_size: Size(0 bytes), pointee_align: Some(Align(8 bytes)) }) }], ret: ArgAbi { layout: TyAndLayout { ty: Poll<()>, layout: Layout { size: Size(1 bytes), align: AbiAlign { abi: Align(1 bytes) }, backend_repr: Scalar(Initialized { value: Int(I8, false), valid_range: 0..=1 }), fields: Arbitrary { offsets: [Size(0 bytes)], memory_index: [0] }, largest_niche: Some(Niche { offset: Size(0 bytes), value: Int(I8, false), valid_range: 0..=1 }), uninhabited: false, variants: Multiple { tag: Initialized { value: Int(I8, false), valid_range: 0..=1 }, tag_encoding: Direct, tag_field: 0, variants: [Layout { size: Size(1 bytes), align: AbiAlign { abi: Align(1 bytes) }, backend_repr: Scalar(Initialized { value: Int(I8, false), valid_range: 0..=1 }), fields: Arbitrary { offsets: [Size(1 bytes)], memory_index: [0] }, largest_niche: None, uninhabited: false, variants: Single { index: 0 }, max_repr_align: None, unadjusted_abi_align: Align(1 bytes), randomization_seed: 3966823494683985603 }, Layout { size: Size(1 bytes), align: AbiAlign { abi: Align(1 bytes) }, backend_repr: Memory { sized: true }, fields: Arbitrary { offsets: [], memory_index: [] }, largest_niche: None, uninhabited: false, variants: Single { index: 1 }, max_repr_align: None, unadjusted_abi_align: Align(1 bytes), randomization_seed: 3966823494683985603 }] }, max_repr_align: None, unadjusted_abi_align: Align(1 bytes), randomization_seed: 11900470484051956809 } }, mode: Direct(ArgAttributes { regular: NoUndef, arg_ext: Zext, pointee_size: Size(0 bytes), pointee_align: None }) }, c_variadic: false, fixed_count: 2, conv: Rust, can_unwind: false }
left: Some(ArgAbi { layout: TyAndLayout { ty: &mut Context<'_>, layout: Layout { size: Size(8 bytes), align: AbiAlign { abi: Align(8 bytes) }, backend_repr: Scalar(Initialized { value: Pointer(AddressSpace(0)), valid_range: 1..=18446744073709551615 }), fields: Primitive, largest_niche: Some(Niche { offset: Size(0 bytes), value: Pointer(AddressSpace(0)), valid_range: 1..=18446744073709551615 }), uninhabited: false, variants: Single { index: 0 }, max_repr_align: None, unadjusted_abi_align: Align(8 bytes), randomization_seed: 281492156579847 } }, mode: Direct(ArgAttributes { regular: NonNull | NoUndef, arg_ext: None, pointee_size: Size(0 bytes), pointee_align: Some(Align(8 bytes)) }) })
right: None
stack backtrace:
0: 0xf69008881b0c - std::backtrace_rs::backtrace::libunwind::trace::h2f2f926b667272f8
at /rustc/f6092f224d2b1774b31033f12d0bee626943b02f/library/std/src/../../backtrace/src/backtrace/libunwind.rs:117:9
1: 0xf69008881b0c - std::backtrace_rs::backtrace::trace_unsynchronized::hb01d61b995d2cc69
at /rustc/f6092f224d2b1774b31033f12d0bee626943b02f/library/std/src/../../backtrace/src/backtrace/mod.rs:66:14
2: 0xf69008881b0c - std::sys::backtrace::_print_fmt::h62818a9f307ae2bf
at /rustc/f6092f224d2b1774b31033f12d0bee626943b02f/library/std/src/sys/backtrace.rs:66:9
3: 0xf69008881b0c - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::hd346c757c1662093
at /rustc/f6092f224d2b1774b31033f12d0bee626943b02f/library/std/src/sys/backtrace.rs:39:26
4: 0xf690058743d8 - core::fmt::rt::Argument::fmt::h2b247c43ca0714de
at /rustc/f6092f224d2b1774b31033f12d0bee626943b02f/library/core/src/fmt/rt.rs:173:76
5: 0xf690058743d8 - core::fmt::write::h51b026662a93de1f
at /rustc/f6092f224d2b1774b31033f12d0bee626943b02f/library/core/src/fmt/mod.rs:1468:25
6: 0xf6900883d578 - std::io::default_write_fmt::h09a8b4bdb54ca020
at /rustc/f6092f224d2b1774b31033f12d0bee626943b02f/library/std/src/io/mod.rs:639:11
7: 0xf6900883d578 - std::io::Write::write_fmt::h74f1f0c16bb99f89
at /rustc/f6092f224d2b1774b31033f12d0bee626943b02f/library/std/src/io/mod.rs:1954:13
8: 0xf6900884dd1c - std::sys::backtrace::BacktraceLock::print::h57f382fc03b5a3eb
at /rustc/f6092f224d2b1774b31033f12d0bee626943b02f/library/std/src/sys/backtrace.rs:42:9
9: 0xf69008853720 - std::panicking::default_hook::{{closure}}::h50059f126dc23252
at /rustc/f6092f224d2b1774b31033f12d0bee626943b02f/library/std/src/panicking.rs:301:27
10: 0xf69008853400 - std::panicking::default_hook::heb40416e8bb9c313
at /rustc/f6092f224d2b1774b31033f12d0bee626943b02f/library/std/src/panicking.rs:328:9
11: 0xf69007a472e0 - std[f4a32d624ceb3bc2]::panicking::update_hook::<alloc[401dce7287ffe88]::boxed::Box<rustc_driver_impl[d36ffa1c96661361]::install_ice_hook::{closure#1}>>::{closure#0}
12: 0xf69008853b94 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h1eaa9407206e5257
at /rustc/f6092f224d2b1774b31033f12d0bee626943b02f/library/alloc/src/boxed.rs:1987:9
13: 0xf69008853b94 - std::panicking::panic_with_hook::hbb763cc0c20718d9
at /rustc/f6092f224d2b1774b31033f12d0bee626943b02f/library/std/src/panicking.rs:842:13
14: 0xf690088538dc - std::panicking::panic_handler::{{closure}}::h5a7ff1657ea88dc4
at /rustc/f6092f224d2b1774b31033f12d0bee626943b02f/library/std/src/panicking.rs:707:13
15: 0xf6900884de38 - std::sys::backtrace::__rust_end_short_backtrace::h2502973eb398866d
at /rustc/f6092f224d2b1774b31033f12d0bee626943b02f/library/std/src/sys/backtrace.rs:174:18
16: 0xf690088323ac - __rustc[51913b3c1857ac82]::rust_begin_unwind
at /rustc/f6092f224d2b1774b31033f12d0bee626943b02f/library/std/src/panicking.rs:698:5
17: 0xf69005ff9d30 - core::panicking::panic_fmt::h0f81d84fa1e45b16
at /rustc/f6092f224d2b1774b31033f12d0bee626943b02f/library/core/src/panicking.rs:75:14
18: 0xf690074cacc4 - core::panicking::assert_failed_inner::hb3d1c240ed9c902f
19: 0xf68ff95a55c8 - core::panicking::assert_failed::h56225154e2fb0599
20: 0xf68ff96ba89c - rustc_codegen_cranelift::abi::codegen_fn_prelude::h871627a96382607c
21: 0xf68ff96017a0 - rustc_codegen_cranelift::base::codegen_fn_body::ha0f93b6179c89307
22: 0xf68ff95ff4a8 - rustc_codegen_cranelift::base::codegen_fn::h71cb46d48a88d27f
23: 0xf68ff968b0bc - rustc_codegen_cranelift::driver::aot::module_codegen::hc195934c10ed1573
24: 0xf68ff95c9950 - rustc_codegen_cranelift::driver::aot::run_aot::{{closure}}::{{closure}}::h4a6efabd14371579
25: 0xf68ff95c9b9c - core::ops::function::impls::<impl core::ops::function::FnMut<A> for &mut F>::call_mut::h353f007328fcba48
26: 0xf68ff9650c10 - alloc::vec::in_place_collect::<impl alloc::vec::spec_from_iter::SpecFromIter<T,I> for alloc::vec::Vec<T>>::from_iter::hc761abc5678b66ba
27: 0xf68ff95c93c0 - rustc_data_structures::sync::parallel::par_map::hc05e59b6aa612f49
28: 0xf68ff966d104 - rustc_session::utils::<impl rustc_session::session::Session>::time::h5039a7bc51874387
29: 0xf68ff968c860 - rustc_codegen_cranelift::driver::aot::run_aot::hbadc5cf3f85dbaeb
30: 0xf68ff965d514 - <rustc_codegen_cranelift::CraneliftCodegenBackend as rustc_codegen_ssa::traits::backend::CodegenBackend>::codegen_crate::ha1fbdd5feb46d4ae
31: 0xf690070f3744 - <rustc_interface[dd2ffa7c3a0af512]::queries::Linker>::codegen_and_build_linker
32: 0xf690070eb93c - rustc_interface[dd2ffa7c3a0af512]::passes::create_and_enter_global_ctxt::<core[575a262b9e16ceca]::option::Option<rustc_interface[dd2ffa7c3a0af512]::queries::Linker>, rustc_driver_impl[d36ffa1c96661361]::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
33: 0xf69006fadb3c - rustc_interface[dd2ffa7c3a0af512]::interface::run_compiler::<(), rustc_driver_impl[d36ffa1c96661361]::run_compiler::{closure#0}>::{closure#1}
34: 0xf69006fabb94 - std[f4a32d624ceb3bc2]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[dd2ffa7c3a0af512]::util::run_in_thread_with_globals<rustc_interface[dd2ffa7c3a0af512]::util::run_in_thread_pool_with_globals<rustc_interface[dd2ffa7c3a0af512]::interface::run_compiler<(), rustc_driver_impl[d36ffa1c96661361]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
35: 0xf69006fdae44 - <<std[f4a32d624ceb3bc2]::thread::Builder>::spawn_unchecked_<rustc_interface[dd2ffa7c3a0af512]::util::run_in_thread_with_globals<rustc_interface[dd2ffa7c3a0af512]::util::run_in_thread_pool_with_globals<rustc_interface[dd2ffa7c3a0af512]::interface::run_compiler<(), rustc_driver_impl[d36ffa1c96661361]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[575a262b9e16ceca]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
36: 0xf6900884ab70 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h9afddea380afe675
at /rustc/f6092f224d2b1774b31033f12d0bee626943b02f/library/alloc/src/boxed.rs:1973:9
37: 0xf6900884ab70 - std::sys::thread::unix::Thread::new::thread_start::he27825b1cbe8f2ed
at /rustc/f6092f224d2b1774b31033f12d0bee626943b02f/library/std/src/sys/thread/unix.rs:126:17
38: 0xf6900444595c - start_thread
at ./nptl/pthread_create.c:447:8
39: 0xf690044abb0c - thread_start
at ./misc/../sysdeps/unix/sysv/linux/aarch64/clone3.S:76:0
40: 0x0 - <unknown>
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: please attach the file at `/home/gh-bjorn3/cg_clif/rustc-ice-2025-09-26T14_15_45-1204404.txt` to your bug report
note: compiler flags: -C panic=abort -Z panic-abort-tests -Z codegen-backend=/home/gh-bjorn3/cg_clif/dist/lib/librustc_codegen_cranelift.so
query stack during panic:
end of query stack
fn std::future::async_drop_in_place::{closure#0}(_1: std::pin::Pin<&mut {async fn body of std::future::async_drop_in_place<{gen [email protected]:5:18: 5:21}>()}>) -> std::task::Poll<()> {
let mut _0: std::task::Poll<()>;
let mut _2: &mut {async fn body of std::future::async_drop_in_place<{gen [email protected]:5:18: 5:21}>()};
let mut _3: *mut {gen [email protected]:5:18: 5:21};
let mut _4: *const ();
let mut _5: usize;
let mut _6: usize;
let mut _7: usize;
let mut _8: usize;
let mut _9: bool;
let mut _10: *const ();
let mut _11: usize;
let mut _12: bool;
let mut _13: bool;
let mut _14: bool;
bb0: {
_2 = deref_copy (_1.0: &mut {async fn body of std::future::async_drop_in_place<{gen [email protected]:5:18: 5:21}>()});
_3 = deref_copy ((*_2).0: *mut {gen [email protected]:5:18: 5:21});
_4 = copy _3 as *const () (PtrToPtr);
_5 = copy _4 as usize (Transmute);
_6 = AlignOf({gen [email protected]:5:18: 5:21});
_7 = Sub(copy _6, const 1_usize);
_8 = BitAnd(copy _5, copy _7);
_9 = Eq(copy _8, const 0_usize);
assert(copy _9, "misaligned pointer dereference: address must be a multiple of {} but is {}", copy _6, copy _5) -> [success: bb1, unwind unreachable];
}
bb1: {
_10 = copy _3 as *const () (PtrToPtr);
_11 = copy _10 as usize (Transmute);
_12 = Eq(copy _11, const 0_usize);
_13 = BitAnd(copy _12, const true);
_14 = Not(copy _13);
assert(copy _14, "null pointer dereference occurred") -> [success: bb2, unwind unreachable];
}
bb2: {
_0 = std::task::Poll::<()>::Ready(const ());
return;
}
}
Originally reported by @matthiaskrgr at rust-lang/rustc_codegen_cranelift#1591.
matthiaskrgr
Metadata
Metadata
Assignees
Labels
A-ABIArea: Concerning the application binary interface (ABI)Area: Concerning the application binary interface (ABI)C-bugCategory: This is a bug.Category: This is a bug.F-async_drop`#![feature(async_drop)]``#![feature(async_drop)]`F-gen_blocks`gen {}` expressions that produce `Iterator`s`gen {}` expressions that produce `Iterator`sT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.