From 3fdab9c44681247a94b8d09e4396b6058751ffcb Mon Sep 17 00:00:00 2001 From: Oliver Scherer Date: Fri, 8 May 2020 13:56:10 +0200 Subject: [PATCH 1/2] Update to rustc changes --- src/machine.rs | 4 ++-- src/thread.rs | 7 +++---- tests/compile-fail/validity/invalid_wide_raw.rs | 2 +- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/machine.rs b/src/machine.rs index 3853f65599..51aa7ae310 100644 --- a/src/machine.rs +++ b/src/machine.rs @@ -427,7 +427,7 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for Evaluator<'mir, 'tcx> { fn canonical_alloc_id(mem: &Memory<'mir, 'tcx, Self>, id: AllocId) -> AllocId { let tcx = mem.tcx; // Figure out if this is an extern static, and if yes, which one. - let def_id = match tcx.alloc_map.lock().get(id) { + let def_id = match tcx.get_global_alloc(id) { Some(GlobalAlloc::Static(def_id)) if tcx.is_foreign_item(def_id) => def_id, _ => { // No need to canonicalize anything. @@ -494,7 +494,7 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for Evaluator<'mir, 'tcx> { if Some(id) == memory_extra.tracked_alloc_id { register_diagnostic(NonHaltingDiagnostic::FreedAlloc(id)); } - + Ok(()) } diff --git a/src/thread.rs b/src/thread.rs index 2119175e12..d78beed28c 100644 --- a/src/thread.rs +++ b/src/thread.rs @@ -428,7 +428,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx match *val { mir::interpret::ConstValue::Scalar(Scalar::Ptr(ref mut ptr)) => { let alloc_id = ptr.alloc_id; - let alloc = this.tcx.alloc_map.lock().get(alloc_id); + let alloc = this.tcx.get_global_alloc(alloc_id); let tcx = this.tcx; let is_thread_local = |def_id| { tcx.codegen_fn_attrs(def_id).flags.contains(CodegenFnAttrFlags::THREAD_LOCAL) @@ -489,13 +489,12 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx })?; let id = raw_const.alloc_id; // Extract the allocation from the query result. - let mut alloc_map = tcx.alloc_map.lock(); - let allocation = alloc_map.unwrap_memory(id); + let allocation = tcx.global_alloc(id).unwrap_memory(); // Create a new allocation id for the same allocation in this hacky // way. Internally, `alloc_map` deduplicates allocations, but this // is fine because Miri will make a copy before a first mutable // access. - let new_alloc_id = alloc_map.create_memory_alloc(allocation); + let new_alloc_id = tcx.create_memory_alloc(allocation); this.machine.threads.set_thread_local_alloc_id(def_id, new_alloc_id); Ok(new_alloc_id) } diff --git a/tests/compile-fail/validity/invalid_wide_raw.rs b/tests/compile-fail/validity/invalid_wide_raw.rs index c232672132..6e0809b15c 100644 --- a/tests/compile-fail/validity/invalid_wide_raw.rs +++ b/tests/compile-fail/validity/invalid_wide_raw.rs @@ -6,5 +6,5 @@ fn main() { struct S { x: * mut dyn T } - dbg!(S { x: unsafe { std::mem::transmute((0usize, 0usize)) } }); //~ ERROR: encountered dangling vtable pointer + dbg!(S { x: unsafe { std::mem::transmute((0usize, 0usize)) } }); //~ ERROR: encountered dangling vtable pointer in wide pointer } From 4f06197aff96b84905d973ce5a46d43b9a3062f8 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sun, 10 May 2020 10:32:29 +0200 Subject: [PATCH 2/2] rustup --- rust-version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust-version b/rust-version index d53d4d68e4..aafee80cbe 100644 --- a/rust-version +++ b/rust-version @@ -1 +1 @@ -0f9088f9610618e724cfc0cf2ba3721918be5ec9 +6f5c7827b71d1e1e4831fa7522e49acaf2a9e44e