diff options
| author | bjorn3 <17426603+bjorn3@users.noreply.github.com> | 2022-07-22 18:03:24 +0000 |
|---|---|---|
| committer | bjorn3 <17426603+bjorn3@users.noreply.github.com> | 2022-07-22 18:03:24 +0000 |
| commit | cd96988436c2ad6ca6654af073170df5e12e077a (patch) | |
| tree | 1c0db56c477bdb5d79171201c51b1a64f6b570c6 | |
| parent | 5fcedf62df66c9b197d5a1d2bc8694e35cef1772 (diff) | |
| download | rust-cd96988436c2ad6ca6654af073170df5e12e077a.tar.gz rust-cd96988436c2ad6ca6654af073170df5e12e077a.zip | |
Don't crash when local variables are too big to store on the stack
| -rw-r--r-- | src/value_and_place.rs | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/value_and_place.rs b/src/value_and_place.rs index 8ff35d2f76d..d82de1d3d8d 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 |
