diff options
| author | Dylan DPC <99973273+Dylan-DPC@users.noreply.github.com> | 2022-06-11 12:59:26 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-06-11 12:59:26 +0200 |
| commit | 11d8ae2c7151b0b83f9c39594fdb47d8fa4d6ef2 (patch) | |
| tree | 83d418f85e8ad21541bb4f3553964521e239c553 /compiler/rustc_const_eval/src/interpret | |
| parent | 7092d42c04a56378d2e748f98169b728b1f1d5d1 (diff) | |
| parent | 67ec96955f4a08c1005bda843d48ca73ea171c9e (diff) | |
| download | rust-11d8ae2c7151b0b83f9c39594fdb47d8fa4d6ef2.tar.gz rust-11d8ae2c7151b0b83f9c39594fdb47d8fa4d6ef2.zip | |
Rollup merge of #97761 - RalfJung:vtable-validation, r=cjgillot
validating the vtable can lead to Stacked Borrows errors Fixes https://github.com/rust-lang/miri/issues/2123
Diffstat (limited to 'compiler/rustc_const_eval/src/interpret')
| -rw-r--r-- | compiler/rustc_const_eval/src/interpret/validity.rs | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/compiler/rustc_const_eval/src/interpret/validity.rs b/compiler/rustc_const_eval/src/interpret/validity.rs index b39a33aff09..630281bb092 100644 --- a/compiler/rustc_const_eval/src/interpret/validity.rs +++ b/compiler/rustc_const_eval/src/interpret/validity.rs @@ -338,6 +338,10 @@ impl<'rt, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> ValidityVisitor<'rt, 'mir, ' { "invalid drop function pointer in vtable (not pointing to a function)" }, err_ub!(InvalidVtableDropFn(..)) => { "invalid drop function pointer in vtable (function has incompatible signature)" }, + // Stacked Borrows errors can happen here, see https://github.com/rust-lang/miri/issues/2123. + // (We assume there are no other MachineStop errors possible here.) + InterpError::MachineStop(_) => + { "vtable pointer does not have permission to read drop function pointer" }, ); try_validation!( 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, ' err_ub!(InvalidVtableAlignment(msg)) => { "invalid vtable: alignment {}", msg }, err_unsup!(ReadPointerAsBytes) => { "invalid size or align in vtable" }, + // Stacked Borrows errors can happen here, see https://github.com/rust-lang/miri/issues/2123. + // (We assume there are no other MachineStop errors possible here.) + InterpError::MachineStop(_) => + { "vtable pointer does not have permission to read size and alignment" }, ); // FIXME: More checks for the vtable. } |
