From ad6dd60396d2a4e493e65ee5ba66562168d28cec Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Fri, 10 Feb 2023 22:01:43 +0100 Subject: [PATCH] fix Stacked Borrows interaction with dyn* --- src/tools/miri/src/helpers.rs | 4 ++++ src/tools/miri/tests/pass/dyn-star.rs | 2 -- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/tools/miri/src/helpers.rs b/src/tools/miri/src/helpers.rs index 5286023e0f6..ed3dd741a8b 100644 --- a/src/tools/miri/src/helpers.rs +++ b/src/tools/miri/src/helpers.rs @@ -478,6 +478,10 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> { } else if matches!(v.layout.fields, FieldsShape::Union(..)) { // A (non-frozen) union. We fall back to whatever the type says. (self.unsafe_cell_action)(v) + } else if matches!(v.layout.ty.kind(), ty::Dynamic(_, _, ty::DynStar)) { + // This needs to read the vtable pointer to proceed type-driven, but we don't + // want to reentrantly read from memory here. + (self.unsafe_cell_action)(v) } else { // We want to not actually read from memory for this visit. So, before // walking this value, we have to make sure it is not a diff --git a/src/tools/miri/tests/pass/dyn-star.rs b/src/tools/miri/tests/pass/dyn-star.rs index 4cac7048fdd..16a8cec6cda 100644 --- a/src/tools/miri/tests/pass/dyn-star.rs +++ b/src/tools/miri/tests/pass/dyn-star.rs @@ -1,5 +1,3 @@ -// Dyn* handling leads to some funky reentrancy in Stacked Borrows, for some reason -//@compile-flags: -Zmiri-disable-stacked-borrows #![feature(dyn_star)] #![allow(incomplete_features)]