-
Notifications
You must be signed in to change notification settings - Fork 352
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: Layout != Layout #3400
Comments
bit smaller //@ edition:2021
// skip-filecheck
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
#![feature(async_closure, noop_waker, async_fn_traits)]
use std::future::Future;
use std::pin::pin;
use std::task::*;
pub fn block_on<T>(fut: impl Future<Output = T>) -> T {
let mut fut = pin!(fut);
let ctx = &mut Context::from_waker(Waker::noop());
loop {
match fut.as_mut().poll(ctx) {
Poll::Pending => {}
Poll::Ready(t) => break t,
}
}
}
async fn call_normal<F: Future<Output = ()>>(f: &impl Fn(i32) -> F) {
f(1).await;
}
pub fn main() {
block_on(async {
let async_closure = async move |a: i32| {};
call_normal(&async_closure).await;
});
} |
rust-lang/rust#120712 has a bug causing cg_clif to crash on tests/ui/async-await/async-closures/once.rs. This miri crash here may be related. I suspect fn_sig_for_fn_abi may need to be updated for async closures. |
Yeah this looks like the types in the function signatures are not coherent with the corresponding arguments in the |
Why doesn't the following hit the same ICE? Should be fine to call a function expecting a raw pointer via a fn pointer saying its type is a reference fn main() {
fn foo(_: *const u32) {}
let x: fn(*const u32) = foo;
let x: fn(&u32) = unsafe {std::mem::transmute(x)};
x(&43);
} |
Ah. That's the key part. We don't explicitly do type punning via fn ptrs, but literally calling a function expecting a raw pointer with a reference typed value. Yea, that's probably invalid MIR and we need to teach validation about it |
Yes, caller vs callee mismatches are fine and carefully handled. But the ICE arises due to a mismatch between two different ways of computing the caller-side type: by computing the caller-side fn sig, and by computing the type of the argument that the caller passes. |
I'll take a look! |
…rcvr, r=oli-obk In `ConstructCoroutineInClosureShim`, pass receiver by mut ref, not mut pointer The receivers were compatible at codegen time, but did not necessarily have the same layouts due to niches, which was caught by miri. Fixes rust-lang/miri#3400 r? oli-obk
Rollup merge of rust-lang#123049 - compiler-errors:coroutine-closure-rcvr, r=oli-obk In `ConstructCoroutineInClosureShim`, pass receiver by mut ref, not mut pointer The receivers were compatible at codegen time, but did not necessarily have the same layouts due to niches, which was caught by miri. Fixes rust-lang/miri#3400 r? oli-obk
…li-obk In `ConstructCoroutineInClosureShim`, pass receiver by mut ref, not mut pointer The receivers were compatible at codegen time, but did not necessarily have the same layouts due to niches, which was caught by miri. Fixes #3400 r? oli-obk
tests/mir-opt/async_closure_shims.rs
cargo miri run
=>miri 0.1.0 (e50ab29 2024-03-23)
The text was updated successfully, but these errors were encountered: