Skip to content

Commit 11d8ae2

Browse files
authored
Rollup merge of #97761 - RalfJung:vtable-validation, r=cjgillot
validating the vtable can lead to Stacked Borrows errors Fixes rust-lang/miri#2123
2 parents 7092d42 + 67ec969 commit 11d8ae2

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

compiler/rustc_const_eval/src/interpret/validity.rs

+8
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,10 @@ impl<'rt, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> ValidityVisitor<'rt, 'mir, '
338338
{ "invalid drop function pointer in vtable (not pointing to a function)" },
339339
err_ub!(InvalidVtableDropFn(..)) =>
340340
{ "invalid drop function pointer in vtable (function has incompatible signature)" },
341+
// Stacked Borrows errors can happen here, see https://github.com/rust-lang/miri/issues/2123.
342+
// (We assume there are no other MachineStop errors possible here.)
343+
InterpError::MachineStop(_) =>
344+
{ "vtable pointer does not have permission to read drop function pointer" },
341345
);
342346
try_validation!(
343347
self.ecx.read_size_and_align_from_vtable(vtable),
@@ -347,6 +351,10 @@ impl<'rt, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> ValidityVisitor<'rt, 'mir, '
347351
err_ub!(InvalidVtableAlignment(msg)) =>
348352
{ "invalid vtable: alignment {}", msg },
349353
err_unsup!(ReadPointerAsBytes) => { "invalid size or align in vtable" },
354+
// Stacked Borrows errors can happen here, see https://github.com/rust-lang/miri/issues/2123.
355+
// (We assume there are no other MachineStop errors possible here.)
356+
InterpError::MachineStop(_) =>
357+
{ "vtable pointer does not have permission to read size and alignment" },
350358
);
351359
// FIXME: More checks for the vtable.
352360
}

0 commit comments

Comments
 (0)