Skip to content

Commit 4f46cd9

Browse files
committed
forgot to commit idk where this belongs it's all getting squashed and im tired
1 parent 89a6827 commit 4f46cd9

File tree

3 files changed

+28
-7
lines changed

3 files changed

+28
-7
lines changed

src/alloc_addresses/mod.rs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
483483
fn apply_events(&mut self, events: crate::shims::trace::MemEvents) -> InterpResult<'tcx> {
484484
let this = self.eval_context_mut();
485485
//let accesses = events.accesses;
486-
let handle = this.machine.alloc_addresses.borrow();
486+
/*let handle = this.machine.alloc_addresses.borrow();
487487
for id in &handle.exposed {
488488
let &base_addr = handle.base_addr.get(id).unwrap();
489489
let info = this.get_alloc_info(*id);
@@ -497,13 +497,22 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
497497
if info.mutbl.is_not() && acc_kind.did_write() {
498498
throw_ub_format!(""); // TODO: fill this in lol
499499
}
500-
501-
if acc_kind.did_write() {
502500
501+
if acc_kind.did_read() {
502+
let src = Pointer::from_addr_invalid(*acc_base);
503+
this.read_immediate_raw(&src);
504+
self.expose_provenance(provenance)
505+
}
506+
507+
if acc_kind.did_write() {
508+
//let alloc = self.alloc_id_from_addr(addr, size, only_exposed_allocations)
503509
}
504510
}
505511
}
506-
}
512+
}*/
513+
/*for (acc_base, acc_len, acc_kind) in &events.accesses {
514+
let alloc_id = self.alloc_id_from_addr(addr, size, only_exposed_allocations)
515+
}*/
507516

508517
interp_ok(())
509518
}

src/shims/native_lib.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,10 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
193193

194194
// Call the function and store output, depending on return type in the function signature.
195195
let ret = this.call_native_with_args(link_name, dest, code_ptr, libffi_args)?;
196+
if let Some(events) = super::trace::Supervisor::get_events() {
197+
eprintln!("accesses: {events:#018x?}");
198+
this.apply_events(events)?;
199+
}
196200
this.write_immediate(*ret, dest)?;
197201
interp_ok(true)
198202
}
@@ -208,8 +212,6 @@ unsafe fn do_native_call<T: libffi::high::CType>(ptr: CodePtr, args: &[ffi::Arg<
208212
Supervisor::end_ffi();
209213
ret
210214
};
211-
let accesses = Supervisor::get_events().unwrap();
212-
eprintln!("accesses: {accesses:#018x?}");
213215
ret
214216
}
215217

src/shims/trace.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,17 @@ impl Supervisor {
161161
pub fn get_events() -> Option<MemEvents> {
162162
let mut sv_guard = SUPERVISOR.lock().unwrap();
163163
let sv = sv_guard.take()?;
164-
let ret = sv.r_event.recv().ok();
164+
// On the off-chance something really weird happens, don't block forever
165+
let ret = sv.r_event.try_recv_timeout(std::time::Duration::from_secs(1)).map_err(|e| {
166+
match e {
167+
ipc::TryRecvError::IpcError(e) => ipc::TryRecvError::IpcError(e),
168+
ipc::TryRecvError::Empty => {
169+
// timed out!
170+
eprintln!("Waiting for accesses from supervisor timed out!");
171+
ipc::TryRecvError::Empty
172+
},
173+
}
174+
}).ok();
165175
*sv_guard = Some(sv);
166176
ret
167177
}

0 commit comments

Comments
 (0)