-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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 on extremely large arrays #49230
Comments
That slice is bigger than the 32 bit address space so this isn't going to compile, but we shouldn't panic. |
@sfackler However it actually compiles and panic(s) at runtime |
The error you posted is of the compiler panicking, not your program panicking. |
@sfackler thanks |
Oddly enough, if you increase the value significantly and only allocate the slice, there's a non-ICE error that you would expect to see:
but with the provided size, the compilation succeeds but panics on execution:
|
This doesn't seem to ICE anymore? |
@Centril I played a bit with this and it does not seem to ICE anymore. But depending on the actual size, it compiles and then crashes. Here is what @lthls, @codename68 and myself found when we investigated (mostly them TBH). Let me know if you'd rather have this in a separate issue. Using this program: pub const INC: usize = 14;
pub const SIZE: usize = 1 << 32 + INC;
fn main() {
let big_array: [u8; SIZE] = [0; SIZE];
for n in 0..SIZE {
println!("{}", big_array[n])
}
} You can compile and crash with
When
If I just declare I seems that, if you only declare the array, you can run code with an erroneous stack pointer, and thus pretty much do anything you want. We will see if we can come up with a small working example, I think @codename68 manages to write in a |
Looking over the assembly generated by I can reproduce this behavior independently of Rust with LLVM 9, but not with LLVM 10. So I believe this is an LLVM bug that has been fixed already, and we can either cherry-pick the fix if we can find it, or get this bug fixed automatically when we update to LLVM 10. |
Note: this explains the reports of runtime crashes, which all appear to assume a 64 bit target. The ICE that was originally reported must have a different cause. Since it occurred on |
OP's program does not compile on a 32-bit target since Rust 1.26: https://godbolt.org/z/1E7MM8sK1 |
Closing this as it's an hard error now as demonstrated in the above link. |
When I test this program with
cargo test
:I got this:
The text was updated successfully, but these errors were encountered: