mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-31 21:47:15 +03:00
Auto merge of #2279 - RalfJung:adjacent-allocs, r=RalfJung
Allow non-ZST allocations to be adjacent Also `cargo update` in test-cargo-miri... no need to make a separate PR for that right?...
This commit is contained in:
+6
-5
@@ -1,4 +1,5 @@
|
||||
use std::cell::RefCell;
|
||||
use std::cmp::max;
|
||||
use std::collections::hash_map::Entry;
|
||||
|
||||
use log::trace;
|
||||
@@ -187,11 +188,11 @@ fn alloc_base_addr(ecx: &MiriEvalContext<'mir, 'tcx>, alloc_id: AllocId) -> u64
|
||||
slack,
|
||||
);
|
||||
|
||||
// Remember next base address. Leave a gap of at least 1 to avoid two zero-sized allocations
|
||||
// having the same base address, and to avoid ambiguous provenance for the address between two
|
||||
// allocations (also see https://github.com/rust-lang/unsafe-code-guidelines/issues/313).
|
||||
let size_plus_1 = size.bytes().checked_add(1).unwrap();
|
||||
global_state.next_base_addr = base_addr.checked_add(size_plus_1).unwrap();
|
||||
// Remember next base address. If this allocation is zero-sized, leave a gap
|
||||
// of at least 1 to avoid two allocations having the same base address.
|
||||
// (The logic in `alloc_id_from_addr` assumes unique addresses, and function
|
||||
// pointers to different functions need to be distinguishable!)
|
||||
global_state.next_base_addr = base_addr.checked_add(max(size.bytes(), 1)).unwrap();
|
||||
// Given that `next_base_addr` increases in each allocation, pushing the
|
||||
// corresponding tuple keeps `int_to_ptr_map` sorted
|
||||
global_state.int_to_ptr_map.push((base_addr, alloc_id));
|
||||
|
||||
Reference in New Issue
Block a user