-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Large allocations in const eval can OOM crash the compiler #79601
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
Comments
IIRC the plan of the allocator WG was to have a form of EDIT: seems like such a method actually already exists. |
even if we use |
Note that this breaks Miri. Closes rust-lang#79601
…i-obk Support allocation failures when interpreting MIR This closes rust-lang#79601 by handling the case where memory allocation fails during MIR interpretation, and translates that failure into an `InterpError`. The error message is "tried to allocate more memory than available to compiler" to make it clear that the memory shortage is happening at compile-time by the compiler itself, and that it is not a runtime issue. Now that memory allocation can fail, it would be neat if Miri could simulate low-memory devices to make it easy to see how much memory a Rust program needs. Note that this breaks Miri because it assumes that allocation can never fail.
Note that this breaks Miri. Closes rust-lang#79601
I tried this code:
I expected to see this happen: An error about the constant evaluation using more memory than the compiler having available
Instead, this happened: The compiler triggered an
abort
Meta
rustc --version --verbose
:Backtrace
Vec
machinery...rust/compiler/rustc_middle/src/mir/interpret/allocation.rs
Line 110 in 0fa9d31
rust/compiler/rustc_mir/src/interpret/memory.rs
Line 197 in 0fa9d31
I think we'll need to stop using
Vec
and move to manually usingAllocRef::alloc
(and maybeBox<[u8]>
? in order to allow bubbling up allocation errors during const eval back to the user via error messages.cc @rust-lang/wg-const-eval
related: #23600
The text was updated successfully, but these errors were encountered: