-
Notifications
You must be signed in to change notification settings - Fork 353
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
Improve error message: Unsupported operation vs. undefined behavior #417
Comments
We could probably also improve the rendering of the stack traces. |
A third category is panics. Maybe our error enum should just have these three variants with sub-enums for the concrete error? |
There's also resource exhaustion (out of memory, out of time). But I'd put them together with panics, both are just "normal execution behavior". |
Separating them from panics has advantages for rustc figuring out what to report which way. Reporting const eval resource exhaustion as "this will panic at runtime" seems bad |
Well sure the error message would still look into the inner variant. |
Related: rust-lang/const-eval#4 |
An example of this issue from Zulip chat; minified example from @shepmaster:
fn main() {
let a: u8 = 42;
let a_ref = &a;
let a_ptr = a_ref as *const u8;
let a_aligned = a_ptr as usize % 16;
unsafe { a_ptr.sub(a_aligned) };
}
And suggestion of the better supported alternative from @oli-obk:
|
@shepmaster points out that it would also be a good idea for Miri to indicate how "certain" some case of UB is -- like, dereferencing a dangling pointer is definitely UB, but a Stacked Borrows violation is more experimental. |
Blocked on rust-lang/const-eval#4: once the CTFE error enum contains the information we need, we can think about how to best present that to the user. |
Someone using miri and getting an error should learn immediately whether this is a problem in their code (UB, e.g. out-of-bounds memory access) or a problem in miri (unsupported operation, e.g. printing a pointer).
Any ideas how we could make that as clear as possible?
The text was updated successfully, but these errors were encountered: