[ConstProp] Avoid OOM crashes by not evaluating large Places
Fixes #66397
This commit is contained in:
parent
d389f64cdb
commit
3732b7acf1
@ -458,6 +458,11 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
|
||||
) -> Option<()> {
|
||||
let span = source_info.span;
|
||||
|
||||
// #66397: Don't try to eval into large places as that can cause an OOM
|
||||
if place_layout.size >= Size::from_bytes(MAX_ALLOC_LIMIT) {
|
||||
return None;
|
||||
}
|
||||
|
||||
let overflow_check = self.tcx.sess.overflow_checks();
|
||||
|
||||
// Perform any special handling for specific Rvalue types.
|
||||
|
5
src/test/ui/consts/issue-66397.rs
Normal file
5
src/test/ui/consts/issue-66397.rs
Normal file
@ -0,0 +1,5 @@
|
||||
// build-pass
|
||||
|
||||
fn main() {
|
||||
[0; 4 * 1024 * 1024 * 1024 * 1024];
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user