-
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
Miri reports UB in the core
lib
#2839
Comments
What is the code to reproduce the problem? If your code calls unsafe |
@saethlin seems related to the failures we are seeing in miri-test-libstd. |
@RalfJung Here is a simplified example which reproduces the issue:
This test case causes the following
|
Interesting! Here's as far as I can minimize this: #![feature(core_intrinsics)]
fn main() {
unsafe {
core::intrinsics::const_eval_select((), ow_ct, ow_ct)
}
}
const fn ow_ct() -> ! {
panic!();
} And the bug is that we generate this MIR for
|
Packing the same code in a |
Probably related to rust-lang/rust#102906 then, Cc @nbdd0121 |
The -// MIR for `main` before AbortUnwindingCalls
+// MIR for `main` after AbortUnwindingCalls
fn main() -> () {
let mut _0: (); // return place in scope 0 at src/main.rs:3:11: 3:11
@@ -11,7 +11,7 @@ fn main() -> () {
StorageLive(_1); // scope 1 at src/main.rs:5:9: 5:62
StorageLive(_2); // scope 1 at src/main.rs:5:45: 5:47
_2 = (); // scope 1 at src/main.rs:5:45: 5:47
- _1 = const_eval_select::<(), fn() -> ! {ow_ct}, fn() -> ! {ow_ct}, !>(move _2, ow_ct, ow_ct); // scope 1 at src/main.rs:5:9: 5:62
+ _1 = const_eval_select::<(), fn() -> ! {ow_ct}, fn() -> ! {ow_ct}, !>(move _2, ow_ct, ow_ct) -> unwind unreachable; // scope 1 at src/main.rs:5:9: 5:62
// mir::Constant
// + span: src/main.rs:5:9: 5:44
// + literal: Const { ty: unsafe extern "rust-intrinsic" fn((), fn() -> ! {ow_ct}, fn() -> ! {ow_ct}) -> ! {const_eval_select::<(), fn() -> ! {ow_ct}, fn() -> ! {ow_ct}, !>}, val: Value(<ZST>) } |
This seems to be a longstanding bug that's exposed by rust-lang/rust#102906. |
Related: rust-lang/rust#104451 |
So is that issue now definitely a soundness issue? It seems very wrong to suggest to a codegen backend that unwinding is unreachable when it is reachable. |
Yeah sounds like a soundness issue to me, affecting not just Miri but also regular rustc. |
Make rust-intrinsic ABI unwindable Fix #104451, fix rust-lang/miri#2839 r? `@RalfJung`
Started getting this error with recent miri builds:
Is there a real UB in the
core
lib?The text was updated successfully, but these errors were encountered: