Skip to content

Commit a6dd47b

Browse files
authored
Finish up Miri integration (#376)
* Use `fn_ptr` from Miri * Get tests passing under Miri * Test Miri on CI
1 parent 893fbb2 commit a6dd47b

File tree

6 files changed

+28
-5
lines changed

6 files changed

+28
-5
lines changed

.github/workflows/main.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,3 +192,14 @@ jobs:
192192
- name: Install Rust
193193
run: rustup update 1.40.0 && rustup default 1.40.0
194194
- run: cargo build
195+
196+
miri:
197+
name: Miri
198+
runs-on: ubuntu-latest
199+
steps:
200+
- uses: actions/checkout@v1
201+
with:
202+
submodules: true
203+
- name: Install Rust
204+
run: ./ci/miri-rustup.sh
205+
- run: MIRIFLAGS="-Zmiri-disable-isolation" cargo miri test

ci/miri-rustup.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
set -ex
2+
3+
MIRI_NIGHTLY=nightly-$(curl -s https://rust-lang.github.io/rustup-components-history/x86_64-unknown-linux-gnu/miri)
4+
echo "Installing latest nightly with Miri: $MIRI_NIGHTLY"
5+
rustup set profile minimal
6+
rustup default "$MIRI_NIGHTLY"
7+
rustup component add miri

src/backtrace/miri.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ pub struct MiriFrame {
1313
pub filename: Box<[u8]>,
1414
pub lineno: u32,
1515
pub colno: u32,
16+
pub fn_ptr: *mut c_void,
1617
}
1718

1819
#[derive(Debug, Clone)]
@@ -36,7 +37,7 @@ impl Frame {
3637
}
3738

3839
pub fn symbol_address(&self) -> *mut c_void {
39-
self.addr
40+
self.inner.fn_ptr
4041
}
4142

4243
pub fn module_base_address(&self) -> Option<*mut c_void> {

tests/accuracy/main.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ fn doit() {
2222
!cfg!(target_env = "musl")
2323
// Skip MinGW on libbacktrace which doesn't have support for DLLs.
2424
&& !(cfg!(windows) && cfg!(target_env = "gnu") && cfg!(feature = "libbacktrace"))
25+
// Skip Miri, since it doesn't support dynamic libraries.
26+
&& !cfg!(miri)
2527
{
2628
// TODO(#238) this shouldn't have to happen first in this function, but
2729
// currently it does.

tests/concurrent-panics.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ fn main() {
1313
// These run in docker containers on CI where they can't re-exec the test,
1414
// so just skip these for CI. No other reason this can't run on those
1515
// platforms though.
16-
if cfg!(unix) && (cfg!(target_arch = "arm") || cfg!(target_arch = "aarch64")) {
16+
// Miri does not have support for re-execing a file
17+
if cfg!(unix) && (cfg!(target_arch = "arm") || cfg!(target_arch = "aarch64")) || cfg!(miri) {
1718
println!("test result: ok");
1819
return;
1920
}

tests/smoke.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use backtrace::Frame;
22
use std::thread;
33

44
// Reflects the conditional compilation logic at end of src/symbolize/mod.rs
5-
static NOOP: bool = cfg!(miri);
5+
static NOOP: bool = false;
66
static DBGHELP: bool = !NOOP
77
&& cfg!(all(
88
windows,
@@ -31,6 +31,7 @@ static GIMLI_SYMBOLIZE: bool = !NOOP
3131
not(target_vendor = "uwp"),
3232
not(target_os = "emscripten"),
3333
));
34+
static MIRI_SYMBOLIZE: bool = cfg!(miri);
3435

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

160161
let mut resolved = 0;
161-
let can_resolve = LIBBACKTRACE || GIMLI_SYMBOLIZE;
162-
let can_resolve_cols = GIMLI_SYMBOLIZE;
162+
let can_resolve = LIBBACKTRACE || GIMLI_SYMBOLIZE || MIRI_SYMBOLIZE;
163+
let can_resolve_cols = GIMLI_SYMBOLIZE || MIRI_SYMBOLIZE;
163164

164165
let mut name = None;
165166
let mut addr = None;

0 commit comments

Comments
 (0)