Skip to content

Commit 12ba87b

Browse files
Rollup merge of rust-lang#97395 - RalfJung:call-abi, r=oli-obk
Miri call ABI check: ensure type size+align stay the same We should almost certainly not accept calls where caller and callee disagree on the size or alignment of the type. The checks we do *almost* imply that, except that `ScalarPair` types can have `repr(align)` and thus differ in size/align even when they are pairs of the same primitive type. r? ``@oli-obk``
2 parents 22da719 + d7a2d9a commit 12ba87b

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

Diff for: compiler/rustc_const_eval/src/interpret/terminator.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,14 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
185185
// No question
186186
return true;
187187
}
188-
// Compare layout
188+
if caller_abi.layout.size != callee_abi.layout.size
189+
|| caller_abi.layout.align.abi != callee_abi.layout.align.abi
190+
{
191+
// This cannot go well...
192+
// FIXME: What about unsized types?
193+
return false;
194+
}
195+
// The rest *should* be okay, but we are extra conservative.
189196
match (caller_abi.layout.abi, callee_abi.layout.abi) {
190197
// Different valid ranges are okay (once we enforce validity,
191198
// that will take care to make it UB to leave the range, just

0 commit comments

Comments
 (0)