From fb0d3dca008ac32073798946ae601038556b7414 Mon Sep 17 00:00:00 2001 From: Aaron Hill Date: Sun, 11 Oct 2020 21:46:29 -0400 Subject: [PATCH 1/3] Use `fn_ptr` from Miri --- src/backtrace/miri.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/backtrace/miri.rs b/src/backtrace/miri.rs index 2e3f1d0dc..bcf435588 100644 --- a/src/backtrace/miri.rs +++ b/src/backtrace/miri.rs @@ -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)] @@ -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> { From 4b8715e5c64a929954c3702fa9285c9bcd96b75b Mon Sep 17 00:00:00 2001 From: Aaron Hill Date: Sat, 10 Oct 2020 13:18:44 -0400 Subject: [PATCH 2/3] Get tests passing under Miri --- tests/accuracy/main.rs | 2 ++ tests/concurrent-panics.rs | 3 ++- tests/smoke.rs | 7 ++++--- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/tests/accuracy/main.rs b/tests/accuracy/main.rs index b339d3161..a2aba071b 100644 --- a/tests/accuracy/main.rs +++ b/tests/accuracy/main.rs @@ -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. diff --git a/tests/concurrent-panics.rs b/tests/concurrent-panics.rs index ac1d61d65..0db0fdd57 100644 --- a/tests/concurrent-panics.rs +++ b/tests/concurrent-panics.rs @@ -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; } diff --git a/tests/smoke.rs b/tests/smoke.rs index ca04a8a6e..0c990e066 100644 --- a/tests/smoke.rs +++ b/tests/smoke.rs @@ -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, @@ -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 @@ -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; From 588ae82608e05c8687cb9a69dc9016c152235f91 Mon Sep 17 00:00:00 2001 From: Aaron Hill Date: Sun, 11 Oct 2020 21:55:16 -0400 Subject: [PATCH 3/3] Test Miri on CI --- .github/workflows/main.yml | 11 +++++++++++ ci/miri-rustup.sh | 7 +++++++ 2 files changed, 18 insertions(+) create mode 100755 ci/miri-rustup.sh diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 64abfdb19..948924c34 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -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 diff --git a/ci/miri-rustup.sh b/ci/miri-rustup.sh new file mode 100755 index 000000000..64b3efa14 --- /dev/null +++ b/ci/miri-rustup.sh @@ -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