Skip to content

Commit 64bfe81

Browse files
committed
Auto merge of #1190 - RalfJung:canonical-alloc-id, r=RalfJung
Canonical AllocID This is the Miri side of rust-lang/rust#69408. This just ports the existing extern statics to the new system; no new shims are added. Cc @christianpoveda
2 parents 263eedc + 59bddba commit 64bfe81

File tree

8 files changed

+76
-46
lines changed

8 files changed

+76
-46
lines changed

bench-cargo-miri/mse/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ static EXPECTED: &[u8] = &[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
22
static PCM: &[i16] = &[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, -2, 0, -2, 0, -2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 1, 0, 1, 0, 0, -2, 0, -2, 0, -2, 0, -2, -2, -2, -3, -3, -3, -3, -4, -2, -5, -2, -5, -2, -4, 0, -4, 0, -4, 0, -4, 1, -4, 1, -4, 2, -4, 2, -4, 2, -4, 2, -4, 2, -3, 1, -4, 0, -4, 0, -5, 0, -5, 0, -5, 0, -4, 2, -4, 3, -4, 4, -3, 5, -2, 5, -3, 6, -3, 6, -3, 5, -3, 5, -2, 4, -2, 3, -5, 0, -6, 0, -3, -2, -4, -4, -9, -5, -9, -4, -4, -2, -4, -2, -4, 0, -2, 1, 1, 1, 4, 2, 8, 2, 12, 1, 13, 0, 12, 0, 11, 0, 8, -2, 7, 0, 7, -3, 11, -8, 15, -9, 17, -6, 17, -5, 13, -3, 7, 0, 3, 0, -2, 0, -4, 0, -4, -2, -6, 0, -14, -2, -17, -4, -8, 0, -7, 5, -17, 7, -18, 10, -7, 18, -2, 25, -3, 27, 0, 31, 4, 34, 4, 34, 8, 36, 8, 37, 2, 36, 4, 34, 8, 28, 3, 15, 0, 11, 0, 12, -5, 8, -4, 10, 0, 23, -4, 31, -8, 30, -2, 30, 0, 26, -6, 22, -6, 20, -12, 15, -19, 10, -10, 13, -14, 6, -43, -13, -43, -16, -9, -12, -10, -29, -42, -40, -37, -28, -5, -21, 1, -24, -8, -20, 4, -18, 26, -24, 44, -26, 66, -30, 86, -37, 88, -41, 72, -46, 50, -31, 28, 23, 14, 64, 16, 51, 26, 32, 34, 39, 42, 48, 35, 58, 0, 72, -36, 69, -59, 58, -98, 54, -124, 36, -103, 12, -110, 5, -173, -19, -146, -59, -4, -42, 51, 1, -23, -6, -30, -6, 45, 46, 47, 70, 6, 55, 19, 60, 38, 62, 42, 47, 61, 46, 40, 42, -19, 22, -34, 6, -35, -50, -61, -141, -37, -171, 17, -163, 26, -180, 46, -154, 80, -63, 48, -4, 18, 20, 50, 47, 58, 53, 44, 61, 57, 85, 37, 80, 0, 86, -8, 106, -95, 49, -213, -8, -131, 47, 49, 63, 40, -39, -69, -74, -37, -20, 63, -12, 58, -14, -12, 25, -31, 41, 11, 45, 76, 47, 167, 5, 261, -37, 277, -83, 183, -172, 35, -122, -79, 138, -70, 266, 69, 124, 228, 0, 391, -29, 594, -84, 702, -78, 627, -8, 551, -13, 509, 13, 372, 120, 352, 125, 622, 127, 691, 223, 362, 126, 386, -33, 915, 198, 958, 457, 456, 298, 500, 233, 1027, 469, 1096, 426, 918, 160, 1067, 141, 1220, 189, 1245, 164, 1375, 297, 1378, 503, 1299, 702, 1550, 929, 1799, 855, 1752, 547, 1830, 602, 1928, 832, 1736, 796, 1735, 933, 1961, 1385, 1935, 1562, 2105, 1485, 2716, 1449, 2948, 1305, 2768, 1205, 2716, 1346, 2531, 1450, 2470, 1653, 3117, 2111, 3370, 2176, 2696, 1947, 2925, 2305, 3846, 2658, 2425, 2184, -877, 1981, -2261, 2623, -1645, 2908, -1876, 2732, -2704, 2953, -2484, 3116, -2120, 2954, -2442, 3216, -2466, 3499, -2192, 3234, -2392, 3361, -2497, 3869, -2078, 3772, -1858, 3915, -2066, 4438, -2285, 2934, -2294, -280, -2066, -1762, -1992, -1412, -2298, -1535, -2399, -1789, -2223, -1419, -2244, -1334, -2092, -1476, -1777, -1396, -2014, -1571, -2199, -1574, -1843, -1167, -1910, -1446, -2007, -1818];
33

44
fn main() {
5-
for i in 0..5 {
5+
for _ in 0..2 {
66
mse(PCM.len(), PCM, EXPECTED);
77
}
88
}

rust-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
d9051341a1c142542a3f7dab509266606c775382
1+
e86c9e6ef8be7ddec0360f20aae7d86c69c59a83

src/eval.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ pub fn create_ecx<'mir, 'tcx: 'mir>(
5858
),
5959
);
6060
// Complete initialization.
61+
MemoryExtra::init_extern_statics(&mut ecx)?;
6162
EnvVars::init(&mut ecx, config.excluded_env_vars);
6263

6364
// Setup first stack-frame
@@ -90,14 +91,14 @@ pub fn create_ecx<'mir, 'tcx: 'mir>(
9091
// Make space for `0` terminator.
9192
let size = arg.len() as u64 + 1;
9293
let arg_type = tcx.mk_array(tcx.types.u8, size);
93-
let arg_place = ecx.allocate(ecx.layout_of(arg_type)?, MiriMemoryKind::Env.into());
94+
let arg_place = ecx.allocate(ecx.layout_of(arg_type)?, MiriMemoryKind::Machine.into());
9495
ecx.write_os_str_to_c_str(OsStr::new(arg), arg_place.ptr, size)?;
9596
argvs.push(arg_place.ptr);
9697
}
9798
// Make an array with all these pointers, in the Miri memory.
9899
let argvs_layout =
99100
ecx.layout_of(tcx.mk_array(tcx.mk_imm_ptr(tcx.types.u8), argvs.len() as u64))?;
100-
let argvs_place = ecx.allocate(argvs_layout, MiriMemoryKind::Env.into());
101+
let argvs_place = ecx.allocate(argvs_layout, MiriMemoryKind::Machine.into());
101102
for (idx, arg) in argvs.into_iter().enumerate() {
102103
let place = ecx.mplace_field(argvs_place, idx as u64)?;
103104
ecx.write_scalar(arg, place.into())?;
@@ -108,13 +109,13 @@ pub fn create_ecx<'mir, 'tcx: 'mir>(
108109
// Store `argc` and `argv` for macOS `_NSGetArg{c,v}`.
109110
{
110111
let argc_place =
111-
ecx.allocate(ecx.layout_of(tcx.types.isize)?, MiriMemoryKind::Env.into());
112+
ecx.allocate(ecx.layout_of(tcx.types.isize)?, MiriMemoryKind::Machine.into());
112113
ecx.write_scalar(argc, argc_place.into())?;
113114
ecx.machine.argc = Some(argc_place.ptr);
114115

115116
let argv_place = ecx.allocate(
116117
ecx.layout_of(tcx.mk_imm_ptr(tcx.types.unit))?,
117-
MiriMemoryKind::Env.into(),
118+
MiriMemoryKind::Machine.into(),
118119
);
119120
ecx.write_scalar(argv, argv_place.into())?;
120121
ecx.machine.argv = Some(argv_place.ptr);
@@ -134,7 +135,7 @@ pub fn create_ecx<'mir, 'tcx: 'mir>(
134135

135136
let cmd_utf16: Vec<u16> = cmd.encode_utf16().collect();
136137
let cmd_type = tcx.mk_array(tcx.types.u16, cmd_utf16.len() as u64);
137-
let cmd_place = ecx.allocate(ecx.layout_of(cmd_type)?, MiriMemoryKind::Env.into());
138+
let cmd_place = ecx.allocate(ecx.layout_of(cmd_type)?, MiriMemoryKind::Machine.into());
138139
ecx.machine.cmd_line = Some(cmd_place.ptr);
139140
// Store the UTF-16 string. We just allocated so we know the bounds are fine.
140141
let char_size = Size::from_bytes(2);
@@ -147,7 +148,7 @@ pub fn create_ecx<'mir, 'tcx: 'mir>(
147148
};
148149

149150
// Return place (in static memory so that it does not count as leak).
150-
let ret_place = ecx.allocate(ecx.layout_of(tcx.types.isize)?, MiriMemoryKind::Env.into());
151+
let ret_place = ecx.allocate(ecx.layout_of(tcx.types.isize)?, MiriMemoryKind::Machine.into());
151152
// Call start function.
152153
ecx.call_function(
153154
start_instance,
@@ -158,7 +159,7 @@ pub fn create_ecx<'mir, 'tcx: 'mir>(
158159

159160
// Set the last_error to 0
160161
let errno_layout = ecx.layout_of(tcx.types.u32)?;
161-
let errno_place = ecx.allocate(errno_layout, MiriMemoryKind::Env.into());
162+
let errno_place = ecx.allocate(errno_layout, MiriMemoryKind::Machine.into());
162163
ecx.write_scalar(Scalar::from_u32(0), errno_place.into())?;
163164
ecx.machine.last_error = Some(errno_place);
164165

src/intptrcast.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use std::collections::{hash_map::Entry, HashMap};
55
use rand::Rng;
66

77
use rustc::ty::layout::HasDataLayout;
8-
use rustc_mir::interpret::{AllocCheck, AllocId, InterpResult, Memory, Pointer, PointerArithmetic};
8+
use rustc_mir::interpret::{AllocCheck, AllocId, InterpResult, Memory, Machine, Pointer, PointerArithmetic};
99
use rustc_target::abi::Size;
1010

1111
use crate::{Evaluator, Tag, STACK_ADDR};
@@ -80,12 +80,13 @@ impl<'mir, 'tcx> GlobalState {
8080
) -> InterpResult<'tcx, u64> {
8181
let mut global_state = memory.extra.intptrcast.borrow_mut();
8282
let global_state = &mut *global_state;
83+
let id = Evaluator::canonical_alloc_id(memory, ptr.alloc_id);
8384

8485
// There is nothing wrong with a raw pointer being cast to an integer only after
8586
// it became dangling. Hence `MaybeDead`.
86-
let (size, align) = memory.get_size_and_align(ptr.alloc_id, AllocCheck::MaybeDead)?;
87+
let (size, align) = memory.get_size_and_align(id, AllocCheck::MaybeDead)?;
8788

88-
let base_addr = match global_state.base_addr.entry(ptr.alloc_id) {
89+
let base_addr = match global_state.base_addr.entry(id) {
8990
Entry::Occupied(entry) => *entry.get(),
9091
Entry::Vacant(entry) => {
9192
// This allocation does not have a base address yet, pick one.
@@ -102,7 +103,7 @@ impl<'mir, 'tcx> GlobalState {
102103
trace!(
103104
"Assigning base address {:#x} to allocation {:?} (slack: {}, align: {})",
104105
base_addr,
105-
ptr.alloc_id,
106+
id,
106107
slack,
107108
align.bytes(),
108109
);
@@ -112,7 +113,7 @@ impl<'mir, 'tcx> GlobalState {
112113
global_state.next_base_addr = base_addr.checked_add(max(size.bytes(), 1)).unwrap();
113114
// Given that `next_base_addr` increases in each allocation, pushing the
114115
// corresponding tuple keeps `int_to_ptr_map` sorted
115-
global_state.int_to_ptr_map.push((base_addr, ptr.alloc_id));
116+
global_state.int_to_ptr_map.push((base_addr, id));
116117

117118
base_addr
118119
}

src/machine.rs

Lines changed: 55 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
44
use std::borrow::Cow;
55
use std::cell::RefCell;
6+
use std::collections::HashMap;
67
use std::num::NonZeroU64;
78
use std::rc::Rc;
89

@@ -12,10 +13,9 @@ use rustc::mir;
1213
use rustc::ty::{
1314
self,
1415
layout::{LayoutOf, Size},
15-
Ty, TyCtxt,
16+
Ty,
1617
};
1718
use rustc_ast::attr;
18-
use rustc_hir::def_id::DefId;
1919
use rustc_span::{source_map::Span, symbol::sym};
2020

2121
use crate::*;
@@ -48,8 +48,8 @@ pub enum MiriMemoryKind {
4848
C,
4949
/// Windows `HeapAlloc` memory.
5050
WinHeap,
51-
/// Memory for env vars and args, errno and other parts of the machine-managed environment.
52-
Env,
51+
/// Memory for env vars and args, errno, extern statics and other parts of the machine-managed environment.
52+
Machine,
5353
/// Rust statics.
5454
Static,
5555
}
@@ -74,7 +74,11 @@ pub struct MemoryExtra {
7474
pub stacked_borrows: Option<stacked_borrows::MemoryExtra>,
7575
pub intptrcast: intptrcast::MemoryExtra,
7676

77+
/// Mapping extern static names to their canonical allocation.
78+
pub(crate) extern_statics: HashMap<&'static str, AllocId>,
79+
7780
/// The random number generator used for resolving non-determinism.
81+
/// Needs to be queried by ptr_to_int, hence needs interior mutability.
7882
pub(crate) rng: RefCell<StdRng>,
7983
}
8084

@@ -85,7 +89,34 @@ impl MemoryExtra {
8589
} else {
8690
None
8791
};
88-
MemoryExtra { stacked_borrows, intptrcast: Default::default(), rng: RefCell::new(rng) }
92+
MemoryExtra {
93+
stacked_borrows,
94+
intptrcast: Default::default(),
95+
extern_statics: HashMap::default(),
96+
rng: RefCell::new(rng),
97+
}
98+
}
99+
100+
/// Sets up the "extern statics" for this machine.
101+
pub fn init_extern_statics<'mir, 'tcx>(
102+
this: &mut MiriEvalContext<'mir, 'tcx>,
103+
) -> InterpResult<'tcx> {
104+
match this.tcx.sess.target.target.target_os.as_str() {
105+
"linux" => {
106+
// "__cxa_thread_atexit_impl"
107+
// This should be all-zero, pointer-sized.
108+
let layout = this.layout_of(this.tcx.types.usize)?;
109+
let place = this.allocate(layout, MiriMemoryKind::Machine.into());
110+
this.write_scalar(Scalar::from_machine_usize(0, &*this.tcx), place.into())?;
111+
this.memory
112+
.extra
113+
.extern_statics
114+
.insert("__cxa_thread_atexit_impl", place.ptr.assert_ptr().alloc_id)
115+
.unwrap_none();
116+
}
117+
_ => {} // No "extern statics" supported on this platform
118+
}
119+
Ok(())
89120
}
90121
}
91122

@@ -267,32 +298,29 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for Evaluator<'tcx> {
267298
Ok(())
268299
}
269300

270-
fn find_foreign_static(
271-
tcx: TyCtxt<'tcx>,
272-
def_id: DefId,
273-
) -> InterpResult<'tcx, Cow<'tcx, Allocation>> {
301+
fn canonical_alloc_id(mem: &Memory<'mir, 'tcx, Self>, id: AllocId) -> AllocId {
302+
let tcx = mem.tcx;
303+
// Figure out if this is an extern static, and if yes, which one.
304+
let def_id = match tcx.alloc_map.lock().get(id) {
305+
Some(GlobalAlloc::Static(def_id)) if tcx.is_foreign_item(def_id) => def_id,
306+
_ => {
307+
// No need to canonicalize anything.
308+
return id;
309+
}
310+
};
274311
let attrs = tcx.get_attrs(def_id);
275312
let link_name = match attr::first_attr_value_str_by_name(&attrs, sym::link_name) {
276313
Some(name) => name.as_str(),
277314
None => tcx.item_name(def_id).as_str(),
278315
};
279-
280-
let alloc = match &*link_name {
281-
"__cxa_thread_atexit_impl" => {
282-
// This should be all-zero, pointer-sized.
283-
let size = tcx.data_layout.pointer_size;
284-
let data = vec![0; size.bytes() as usize];
285-
Allocation::from_bytes(&data, tcx.data_layout.pointer_align.abi)
286-
}
287-
_ => throw_unsup_format!("can't access foreign static: {}", link_name),
288-
};
289-
Ok(Cow::Owned(alloc))
290-
}
291-
292-
#[inline(always)]
293-
fn before_terminator(_ecx: &mut InterpCx<'mir, 'tcx, Self>) -> InterpResult<'tcx> {
294-
// We are not interested in detecting loops.
295-
Ok(())
316+
// Check if we know this one.
317+
if let Some(canonical_id) = mem.extra.extern_statics.get(&*link_name) {
318+
trace!("canonical_alloc_id: {:?} ({}) -> {:?}", id, link_name, canonical_id);
319+
*canonical_id
320+
} else {
321+
// Return original id; `Memory::get_static_alloc` will throw an error.
322+
id
323+
}
296324
}
297325

298326
fn init_allocation_extra<'b>(
@@ -433,7 +461,7 @@ impl MayLeak for MiriMemoryKind {
433461
use self::MiriMemoryKind::*;
434462
match self {
435463
Rust | C | WinHeap => false,
436-
Env | Static => true,
464+
Machine | Static => true,
437465
}
438466
}
439467
}

src/shims/env.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ fn alloc_env_var_as_c_str<'mir, 'tcx>(
4040
let mut name_osstring = name.to_os_string();
4141
name_osstring.push("=");
4242
name_osstring.push(value);
43-
ecx.alloc_os_str_as_c_str(name_osstring.as_os_str(), MiriMemoryKind::Env.into())
43+
ecx.alloc_os_str_as_c_str(name_osstring.as_os_str(), MiriMemoryKind::Machine.into())
4444
}
4545

4646
impl<'mir, 'tcx> EvalContextExt<'mir, 'tcx> for crate::MiriEvalContext<'mir, 'tcx> {}
@@ -80,7 +80,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
8080
let var_ptr = alloc_env_var_as_c_str(&name, &value, &mut this);
8181
if let Some(var) = this.machine.env_vars.map.insert(name.to_owned(), var_ptr) {
8282
this.memory
83-
.deallocate(var, None, MiriMemoryKind::Env.into())?;
83+
.deallocate(var, None, MiriMemoryKind::Machine.into())?;
8484
}
8585
Ok(0)
8686
} else {
@@ -102,7 +102,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
102102
if let Some(old) = success {
103103
if let Some(var) = old {
104104
this.memory
105-
.deallocate(var, None, MiriMemoryKind::Env.into())?;
105+
.deallocate(var, None, MiriMemoryKind::Machine.into())?;
106106
}
107107
Ok(0)
108108
} else {

src/shims/panic.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
187187

188188
// First arg: Message.
189189
let msg = msg.description();
190-
let msg = this.allocate_str(msg, MiriMemoryKind::Env.into());
190+
let msg = this.allocate_str(msg, MiriMemoryKind::Machine.into());
191191

192192
// Call the lang item.
193193
let panic = this.tcx.lang_items().panic_fn().unwrap();

src/stacked_borrows.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,7 @@ impl Stacks {
453453
// Thus we call `static_base_ptr` such that the global pointers get the same tag
454454
// as what we use here.
455455
// The base pointer is not unique, so the base permission is `SharedReadWrite`.
456-
MemoryKind::Machine(MiriMemoryKind::Static) =>
456+
MemoryKind::Machine(MiriMemoryKind::Static) | MemoryKind::Machine(MiriMemoryKind::Machine) =>
457457
(extra.borrow_mut().static_base_ptr(id), Permission::SharedReadWrite),
458458
// Everything else we handle entirely untagged for now.
459459
// FIXME: experiment with more precise tracking.

0 commit comments

Comments
 (0)