[ConstProp] Avoid OOM crashes by not evaluating large Places

Fixes #66397
This commit is contained in:
Wesley Wiser 2019-11-13 20:37:33 -05:00
parent d389f64cdb
commit 3732b7acf1
2 changed files with 10 additions and 0 deletions

View File

@ -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.

View File

@ -0,0 +1,5 @@
// build-pass
fn main() {
[0; 4 * 1024 * 1024 * 1024 * 1024];
}