Skip to content

Commit 7d73854

Browse files
author
Ellen Arteca
committed
commenting out alignment check fixes the alignment failing tests -- needs to be fixed in rustc, but the issue is the alignment check isnt formulated correctly wrt real addrs
1 parent 89688bb commit 7d73854

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/intptrcast.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,13 +158,17 @@ impl<'mir, 'tcx> GlobalStateInner {
158158

159159
fn alloc_base_addr(ecx: &MiriEvalContext<'mir, 'tcx>, alloc_id: AllocId) -> u64 {
160160
// TODO avoid leaked address hack
161+
let mut is_global = false;
161162
let base_addr: u64 = match ecx.get_alloc_base_addr(alloc_id) {
162163
Ok(addr) => {
163164
assert!(addr.bytes() % 16 == 0);
164165
addr.bytes()
165166
}
166167
// Grabbing u128 for max alignment
167-
Err(_) => Box::leak(Box::new(0u128)) as *const u128 as u64,
168+
Err(_) => {
169+
is_global = true;
170+
Box::leak(Box::new(0u128)) as *const u128 as u64
171+
}
168172
};
169173
// With our hack, base_addr should always be fully aligned
170174
let mut global_state = ecx.machine.intptrcast.borrow_mut();
@@ -177,6 +181,12 @@ impl<'mir, 'tcx> GlobalStateInner {
177181
// it became dangling. Hence we allow dead allocations.
178182
let (size, align, _kind) = ecx.get_alloc_info(alloc_id);
179183

184+
// println!("REE: {:?}, {:?}, {:?}", align, base_addr % align.bytes(), is_global);
185+
let what = Self::align_addr(base_addr, align.bytes());
186+
if (what != base_addr) {
187+
// println!("REEE: {:?}, {:?}, {:?}", what, base_addr, alloc_id);
188+
}
189+
180190
// This allocation does not have a base address yet, assign its bytes base.
181191
entry.insert(base_addr);
182192
trace!(

src/machine.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -723,6 +723,7 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for Evaluator<'mir, 'tcx> {
723723
)
724724
});
725725
let buffer_alloc = ecx.machine.weak_memory.then(weak_memory::AllocExtra::new_allocation);
726+
// println!("yup -- {:?}", id);
726727
let alloc: Allocation<Provenance, Self::AllocExtra> = alloc.adjust_from_tcx(
727728
&ecx.tcx,
728729
AllocExtra {

0 commit comments

Comments
 (0)