Skip to content

Commit 01d9329

Browse files
committed
canonicalize alloc ID before calling tag_static_base_pointer
1 parent 5da3939 commit 01d9329

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

src/librustc_mir/interpret/machine.rs

+2
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,8 @@ pub trait Machine<'mir, 'tcx>: Sized {
253253
/// Return the "base" tag for the given *static* allocation: the one that is used for direct
254254
/// accesses to this static/const/fn allocation. If `id` is not a static allocation,
255255
/// this will return an unusable tag (i.e., accesses will be UB)!
256+
///
257+
/// Expects `id` to be already canonical, if needed.
256258
fn tag_static_base_pointer(memory_extra: &Self::MemoryExtra, id: AllocId) -> Self::PointerTag;
257259

258260
/// Executes a retagging operation

src/librustc_mir/interpret/memory.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,8 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
150150
/// through a pointer that was created by the program.
151151
#[inline]
152152
pub fn tag_static_base_pointer(&self, ptr: Pointer) -> Pointer<M::PointerTag> {
153-
ptr.with_tag(M::tag_static_base_pointer(&self.extra, ptr.alloc_id))
153+
let id = M::canonical_alloc_id(self, ptr.alloc_id);
154+
ptr.with_tag(M::tag_static_base_pointer(&self.extra, id))
154155
}
155156

156157
pub fn create_fn_alloc(

0 commit comments

Comments
 (0)