Skip to content

Commit

Permalink
Finish up Miri integration (#376)
Browse files Browse the repository at this point in the history
* Use `fn_ptr` from Miri

* Get tests passing under Miri

* Test Miri on CI
  • Loading branch information
Aaron1011 committed Oct 15, 2020
1 parent 893fbb2 commit a6dd47b
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 5 deletions.
11 changes: 11 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -192,3 +192,14 @@ jobs:
- name: Install Rust
run: rustup update 1.40.0 && rustup default 1.40.0
- run: cargo build

miri:
name: Miri
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
with:
submodules: true
- name: Install Rust
run: ./ci/miri-rustup.sh
- run: MIRIFLAGS="-Zmiri-disable-isolation" cargo miri test
7 changes: 7 additions & 0 deletions ci/miri-rustup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
set -ex

MIRI_NIGHTLY=nightly-$(curl -s https://rust-lang.github.io/rustup-components-history/x86_64-unknown-linux-gnu/miri)
echo "Installing latest nightly with Miri: $MIRI_NIGHTLY"
rustup set profile minimal
rustup default "$MIRI_NIGHTLY"
rustup component add miri
3 changes: 2 additions & 1 deletion src/backtrace/miri.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ pub struct MiriFrame {
pub filename: Box<[u8]>,
pub lineno: u32,
pub colno: u32,
pub fn_ptr: *mut c_void,
}

#[derive(Debug, Clone)]
Expand All @@ -36,7 +37,7 @@ impl Frame {
}

pub fn symbol_address(&self) -> *mut c_void {
self.addr
self.inner.fn_ptr
}

pub fn module_base_address(&self) -> Option<*mut c_void> {
Expand Down
2 changes: 2 additions & 0 deletions tests/accuracy/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ fn doit() {
!cfg!(target_env = "musl")
// Skip MinGW on libbacktrace which doesn't have support for DLLs.
&& !(cfg!(windows) && cfg!(target_env = "gnu") && cfg!(feature = "libbacktrace"))
// Skip Miri, since it doesn't support dynamic libraries.
&& !cfg!(miri)
{
// TODO(#238) this shouldn't have to happen first in this function, but
// currently it does.
Expand Down
3 changes: 2 additions & 1 deletion tests/concurrent-panics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ fn main() {
// These run in docker containers on CI where they can't re-exec the test,
// so just skip these for CI. No other reason this can't run on those
// platforms though.
if cfg!(unix) && (cfg!(target_arch = "arm") || cfg!(target_arch = "aarch64")) {
// Miri does not have support for re-execing a file
if cfg!(unix) && (cfg!(target_arch = "arm") || cfg!(target_arch = "aarch64")) || cfg!(miri) {
println!("test result: ok");
return;
}
Expand Down
7 changes: 4 additions & 3 deletions tests/smoke.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use backtrace::Frame;
use std::thread;

// Reflects the conditional compilation logic at end of src/symbolize/mod.rs
static NOOP: bool = cfg!(miri);
static NOOP: bool = false;
static DBGHELP: bool = !NOOP
&& cfg!(all(
windows,
Expand Down Expand Up @@ -31,6 +31,7 @@ static GIMLI_SYMBOLIZE: bool = !NOOP
not(target_vendor = "uwp"),
not(target_os = "emscripten"),
));
static MIRI_SYMBOLIZE: bool = cfg!(miri);

#[test]
// FIXME: shouldn't ignore this test on i686-msvc, unsure why it's failing
Expand Down Expand Up @@ -158,8 +159,8 @@ fn smoke_test_frames() {
}

let mut resolved = 0;
let can_resolve = LIBBACKTRACE || GIMLI_SYMBOLIZE;
let can_resolve_cols = GIMLI_SYMBOLIZE;
let can_resolve = LIBBACKTRACE || GIMLI_SYMBOLIZE || MIRI_SYMBOLIZE;
let can_resolve_cols = GIMLI_SYMBOLIZE || MIRI_SYMBOLIZE;

let mut name = None;
let mut addr = None;
Expand Down

0 comments on commit a6dd47b

Please sign in to comment.