Skip to content

Commit ff8ae81

Browse files
committed
interpret: get_alloc_info: also return mutability
1 parent cfb9a90 commit ff8ae81

File tree

6 files changed

+7
-7
lines changed

6 files changed

+7
-7
lines changed

src/alloc_addresses/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
157157
) -> InterpResult<'tcx, u64> {
158158
let ecx = self.eval_context_ref();
159159
let mut rng = ecx.machine.rng.borrow_mut();
160-
let (size, align, kind) = ecx.get_alloc_info(alloc_id);
160+
let (size, align, kind, _mutbl) = ecx.get_alloc_info(alloc_id);
161161
// This is either called immediately after allocation (and then cached), or when
162162
// adjusting `tcx` pointers (which never get freed). So assert that we are looking
163163
// at a live allocation. This also ensures that we never re-assign an address to an

src/borrow_tracker/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
363363
// If it does exist, then we have the guarantee that the
364364
// pointer is readable, and the implicit read access inserted
365365
// will never cause UB on the pointer itself.
366-
let (_, _, kind) = this.get_alloc_info(*alloc_id);
366+
let (_, _, kind, _mutbl) = this.get_alloc_info(*alloc_id);
367367
if matches!(kind, AllocKind::LiveData) {
368368
let alloc_extra = this.get_alloc_extra(*alloc_id)?; // can still fail for `extern static`
369369
let alloc_borrow_tracker = &alloc_extra.borrow_tracker.as_ref().unwrap();

src/borrow_tracker/stacked_borrows/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -626,7 +626,7 @@ trait EvalContextPrivExt<'tcx, 'ecx>: crate::MiriInterpCxExt<'tcx> {
626626
return interp_ok(())
627627
};
628628

629-
let (_size, _align, alloc_kind) = this.get_alloc_info(alloc_id);
629+
let (_size, _align, alloc_kind, _mutbl) = this.get_alloc_info(alloc_id);
630630
match alloc_kind {
631631
AllocKind::LiveData => {
632632
// This should have alloc_extra data, but `get_alloc_extra` can still fail
@@ -1017,7 +1017,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
10171017
// Function pointers and dead objects don't have an alloc_extra so we ignore them.
10181018
// This is okay because accessing them is UB anyway, no need for any Stacked Borrows checks.
10191019
// NOT using `get_alloc_extra_mut` since this might be a read-only allocation!
1020-
let (_size, _align, kind) = this.get_alloc_info(alloc_id);
1020+
let (_size, _align, kind, _mutbl) = this.get_alloc_info(alloc_id);
10211021
match kind {
10221022
AllocKind::LiveData => {
10231023
// This should have alloc_extra data, but `get_alloc_extra` can still fail

src/borrow_tracker/tree_borrows/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -538,7 +538,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
538538
// Function pointers and dead objects don't have an alloc_extra so we ignore them.
539539
// This is okay because accessing them is UB anyway, no need for any Tree Borrows checks.
540540
// NOT using `get_alloc_extra_mut` since this might be a read-only allocation!
541-
let (_size, _align, kind) = this.get_alloc_info(alloc_id);
541+
let (_size, _align, kind, _mutbl) = this.get_alloc_info(alloc_id);
542542
match kind {
543543
AllocKind::LiveData => {
544544
// This should have alloc_extra data, but `get_alloc_extra` can still fail

src/machine.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1125,7 +1125,7 @@ impl<'tcx> Machine<'tcx> for MiriMachine<'tcx> {
11251125
let Provenance::Concrete { alloc_id, .. } = ptr.provenance else {
11261126
panic!("extern_statics cannot contain wildcards")
11271127
};
1128-
let (shim_size, shim_align, _kind) = ecx.get_alloc_info(alloc_id);
1128+
let (shim_size, shim_align, _kind, _mutbl) = ecx.get_alloc_info(alloc_id);
11291129
let def_ty = ecx.tcx.type_of(def_id).instantiate_identity();
11301130
let extern_decl_layout = ecx.tcx.layout_of(ty::ParamEnv::empty().and(def_ty)).unwrap();
11311131
if extern_decl_layout.size != shim_size || extern_decl_layout.align.abi != shim_align {

src/shims/foreign_items.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
409409
);
410410
}
411411
if let Ok((alloc_id, offset, ..)) = this.ptr_try_get_alloc_id(ptr, 0) {
412-
let (_size, alloc_align, _kind) = this.get_alloc_info(alloc_id);
412+
let (_size, alloc_align, _kind, _mutbl) = this.get_alloc_info(alloc_id);
413413
// If the newly promised alignment is bigger than the native alignment of this
414414
// allocation, and bigger than the previously promised alignment, then set it.
415415
if align > alloc_align

0 commit comments

Comments
 (0)