From cd96988436c2ad6ca6654af073170df5e12e077a Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Fri, 22 Jul 2022 18:03:24 +0000 Subject: [PATCH] Don't crash when local variables are too big to store on the stack --- src/value_and_place.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/value_and_place.rs b/src/value_and_place.rs index 8ff35d2f76db..d82de1d3d8d3 100644 --- a/src/value_and_place.rs +++ b/src/value_and_place.rs @@ -324,6 +324,12 @@ impl<'tcx> CPlace<'tcx> { }; } + if layout.size.bytes() >= u64::from(u32::MAX - 16) { + fx.tcx + .sess + .fatal(&format!("values of type {} are too big to store on the stack", layout.ty)); + } + let stack_slot = fx.bcx.create_stack_slot(StackSlotData { kind: StackSlotKind::ExplicitSlot, // FIXME Don't force the size to a multiple of 16 bytes once Cranelift gets a way to