Skip to content

Commit

Permalink
Pass Miri with -Zmiri-strict-provenance
Browse files Browse the repository at this point in the history
  • Loading branch information
saethlin committed Aug 27, 2022
1 parent 056cdf8 commit e3d98d8
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
9 changes: 8 additions & 1 deletion src/capture.rs
Expand Up @@ -2,6 +2,7 @@ use crate::PrintFmt;
use crate::{resolve, resolve_frame, trace, BacktraceFmt, Symbol, SymbolName};
use std::ffi::c_void;
use std::fmt;
use std::mem;
use std::path::{Path, PathBuf};
use std::prelude::v1::*;

Expand Down Expand Up @@ -334,7 +335,13 @@ impl BacktraceSymbol {
/// This function requires the `std` feature of the `backtrace` crate to be
/// enabled, and the `std` feature is enabled by default.
pub fn addr(&self) -> Option<*mut c_void> {
self.addr.map(|s| s as *mut c_void)
// To be compatible with strict provenance, we can't cast here.
// The most right thing to do is always store addr as a pointer,
// but that runs into problems with !Send + !Sync.
// In any case, we're never going to dereference this pointer, so
// a hand-written version of ptr::invalid_mut suffices.
self.addr
.map(|s| unsafe { mem::transmute::<usize, *mut c_void>(s) })
}

/// Same as `Symbol::filename`
Expand Down
1 change: 0 additions & 1 deletion tests/skip_inner_frames.rs
Expand Up @@ -23,7 +23,6 @@ fn backtrace_new_unresolved_should_start_with_call_site_trace() {
assert!(!b.frames().is_empty());

let this_ip = backtrace_new_unresolved_should_start_with_call_site_trace as usize;
println!("this_ip: {:?}", this_ip as *const usize);
let frame_ip = b.frames().first().unwrap().symbol_address() as usize;
assert_eq!(this_ip, frame_ip);
}
Expand Down
2 changes: 0 additions & 2 deletions tests/smoke.rs
Expand Up @@ -290,7 +290,6 @@ fn sp_smoke_test() {
});

let sp = frame.sp() as usize;
eprintln!("sp = {:p}", sp as *const u8);
if sp == 0 {
// If the SP is null, then we don't have an implementation for
// getting the SP on this target. Just keep walking the stack,
Expand All @@ -306,7 +305,6 @@ fn sp_smoke_test() {

if is_recursive_stack_references {
let r = refs.pop().unwrap();
eprintln!("ref = {:p}", r as *const u8);
if sp != 0 {
assert!(r > sp);
if let Some(child_ref) = child_ref {
Expand Down

0 comments on commit e3d98d8

Please sign in to comment.