Skip to content

Commit 74f81e9

Browse files
committed
Auto merge of #1847 - RalfJung:more-tags, r=RalfJung
also treat CallerLocation and Machine memory as properly tagged Only heap allocations need an exception.
2 parents 15e81a9 + 447f23c commit 74f81e9

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

src/shims/foreign_items.rs

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

195195
let instance = instance_and_crate.map(|ic| ic.0);
196196
// Cache it and load its MIR, if found.
197-
this.machine.exported_symbols_cache.insert(link_name, instance);
197+
this.machine.exported_symbols_cache.try_insert(link_name, instance).unwrap();
198198
instance.map(|instance| this.load_mir(instance.def, None)).transpose()
199199
}
200200

src/stacked_borrows.rs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -504,17 +504,22 @@ impl Stacks {
504504
// `Global` memory can be referenced by global pointers from `tcx`.
505505
// Thus we call `global_base_ptr` such that the global pointers get the same tag
506506
// as what we use here.
507-
// `ExternStatic` is used for extern statics, and thus must also be listed here.
508-
// `Env` we list because we can get away with precise tracking there.
507+
// `ExternStatic` is used for extern statics, so the same reasoning applies.
508+
// The others are various forms of machine-managed special global memory, and we can get
509+
// away with precise tracking there.
509510
// The base pointer is not unique, so the base permission is `SharedReadWrite`.
510-
MemoryKind::Machine(
511+
MemoryKind::CallerLocation
512+
| MemoryKind::Machine(
511513
MiriMemoryKind::Global
512514
| MiriMemoryKind::ExternStatic
513515
| MiriMemoryKind::Tls
514-
| MiriMemoryKind::Env,
516+
| MiriMemoryKind::Env
517+
| MiriMemoryKind::Machine,
515518
) => (extra.global_base_ptr(id), Permission::SharedReadWrite),
516-
// Everything else we handle like raw pointers for now.
517-
_ => {
519+
// Heap allocations we only track precisely when raw pointers are tagged, for now.
520+
MemoryKind::Machine(
521+
MiriMemoryKind::Rust | MiriMemoryKind::C | MiriMemoryKind::WinHeap,
522+
) => {
518523
let tag =
519524
if extra.track_raw { Tag::Tagged(extra.new_ptr()) } else { Tag::Untagged };
520525
(tag, Permission::SharedReadWrite)

0 commit comments

Comments
 (0)