Handle missing allocations in Memory::dump.

This commit is contained in:
Scott Olson 2016-04-07 03:07:57 -06:00
parent 1f6583fe06
commit 6be14eab15
2 changed files with 14 additions and 1 deletions

View File

@ -176,11 +176,18 @@ impl Memory {
while let Some(id) = allocs_to_print.pop_front() {
allocs_seen.insert(id.0);
let alloc = self.get(id).unwrap();
let prefix = format!("Alloc {:<5} ", format!("{}:", id.0));
print!("{}", prefix);
let mut relocations = vec![];
let alloc = match self.alloc_map.get(&id.0) {
Some(a) => a,
None => {
println!("(deallocated)");
continue;
}
};
for i in 0..alloc.bytes.len() {
if let Some(&target_id) = alloc.relocations.get(&i) {
if !allocs_seen.contains(&target_id.0) {

View File

@ -51,3 +51,9 @@ fn match_ref_mut() -> i8 {
}
t.0
}
#[miri_run]
fn dangling_pointer() -> *const i32 {
let b = Box::new(42);
&*b as *const i32
}