interpret: always enable write_immediate sanity checks
This commit is contained in:
parent
1d9162bced
commit
7caf2cdc2c
@ -118,6 +118,7 @@ impl<Prov: Provenance> Immediate<Prov> {
|
|||||||
(Immediate::Scalar(scalar), Abi::Scalar(s)) => {
|
(Immediate::Scalar(scalar), Abi::Scalar(s)) => {
|
||||||
assert_eq!(scalar.size(), s.size(cx));
|
assert_eq!(scalar.size(), s.size(cx));
|
||||||
if !matches!(s.primitive(), abi::Pointer(..)) {
|
if !matches!(s.primitive(), abi::Pointer(..)) {
|
||||||
|
// This is not a pointer, it should not carry provenance.
|
||||||
assert!(matches!(scalar, Scalar::Int(..)));
|
assert!(matches!(scalar, Scalar::Int(..)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -652,6 +652,8 @@ where
|
|||||||
M::after_local_write(self, local, /*storage_live*/ false)?;
|
M::after_local_write(self, local, /*storage_live*/ false)?;
|
||||||
}
|
}
|
||||||
// Double-check that the value we are storing and the local fit to each other.
|
// Double-check that the value we are storing and the local fit to each other.
|
||||||
|
// Things can ge wrong in quite weird ways when this is violated.
|
||||||
|
// Unfortunately this is too expensive to do in release builds.
|
||||||
if cfg!(debug_assertions) {
|
if cfg!(debug_assertions) {
|
||||||
src.assert_matches_abi(local_layout.abi, self);
|
src.assert_matches_abi(local_layout.abi, self);
|
||||||
}
|
}
|
||||||
@ -672,9 +674,9 @@ where
|
|||||||
layout: TyAndLayout<'tcx>,
|
layout: TyAndLayout<'tcx>,
|
||||||
dest: MemPlace<M::Provenance>,
|
dest: MemPlace<M::Provenance>,
|
||||||
) -> InterpResult<'tcx> {
|
) -> InterpResult<'tcx> {
|
||||||
if cfg!(debug_assertions) {
|
// We use the sizes from `value` below.
|
||||||
|
// Ensure that matches the type of the place it is written to.
|
||||||
value.assert_matches_abi(layout.abi, self);
|
value.assert_matches_abi(layout.abi, self);
|
||||||
}
|
|
||||||
// Note that it is really important that the type here is the right one, and matches the
|
// Note that it is really important that the type here is the right one, and matches the
|
||||||
// type things are read at. In case `value` is a `ScalarPair`, we don't do any magic here
|
// type things are read at. In case `value` is a `ScalarPair`, we don't do any magic here
|
||||||
// to handle padding properly, which is only correct if we never look at this data with the
|
// to handle padding properly, which is only correct if we never look at this data with the
|
||||||
|
Loading…
x
Reference in New Issue
Block a user