Skip to content

Commit

Permalink
miri_print_borrow_state: show error when AllocId is invalid
Browse files Browse the repository at this point in the history
  • Loading branch information
RalfJung committed Aug 9, 2024
1 parent 549e90b commit aee5e91
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/tools/miri/src/shims/foreign_items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -289,8 +289,12 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
let [id, show_unnamed] = this.check_shim(abi, Abi::Rust, link_name, args)?;
let id = this.read_scalar(id)?.to_u64()?;
let show_unnamed = this.read_scalar(show_unnamed)?.to_bool()?;
if let Some(id) = std::num::NonZero::new(id) {
this.print_borrow_state(AllocId(id), show_unnamed)?;
if let Some(id) = std::num::NonZero::new(id).map(AllocId)
&& this.get_alloc_info(id).2 == AllocKind::LiveData
{
this.print_borrow_state(id, show_unnamed)?;
} else {
eprintln!("{id} is not the ID of a live data allocation");
}
}
"miri_pointer_name" => {
Expand Down

0 comments on commit aee5e91

Please sign in to comment.