-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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: CTFE/miri crashes with overflow in built-in array index #130284
Comments
Hm. I'd prefer we have halted const eval at any of the UB that this example executes. If we refuse to create an invalid slice, I think the bounds check prevents reaching the assertion. Which I think is the reason the assertion exists. |
Does this example have UB before the index operation itself? I'm using a raw slice ( |
Ah! It's a raw slice. I missed that, thanks. |
Good catch, thanks! |
Rollup merge of rust-lang#130342 - RalfJung:slice-idx-overflow, r=saethlin interpret, miri: fix dealing with overflow during slice indexing and allocation This is mostly to fix rust-lang#130284. I then realized we're using somewhat sketchy arguments for a similar multiplication in `copy`/`copy_nonoverlapping`/`write_bytes`, so I made them all share the same function that checks exactly the right thing. (The intrinsics would previously fail on allocations larger than `1 << 47` bytes... which are theoretically possible maybe? Anyway it seems conceptually wrong to use any other bound than `isize::MAX` here.)
interpret, miri: fix dealing with overflow during slice indexing and allocation This is mostly to fix rust-lang/rust#130284. I then realized we're using somewhat sketchy arguments for a similar multiplication in `copy`/`copy_nonoverlapping`/`write_bytes`, so I made them all share the same function that checks exactly the right thing. (The intrinsics would previously fail on allocations larger than `1 << 47` bytes... which are theoretically possible maybe? Anyway it seems conceptually wrong to use any other bound than `isize::MAX` here.)
Code
playground
(EDIT: updated to remove unstable feature)
Meta
rustc --version --verbose
:Error output
Backtrace
@rustbot label A-const-eval
The text was updated successfully, but these errors were encountered: