From b06731355205f0a4ffa1464137b1d55992f08b48 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sun, 30 Jun 2019 16:56:16 +0200 Subject: [PATCH 1/3] use intptrcast for heap_allocator test; then it should work on Windows --- tests/run-pass/heap_allocator.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/run-pass/heap_allocator.rs b/tests/run-pass/heap_allocator.rs index b201f24e25..457734cb60 100644 --- a/tests/run-pass/heap_allocator.rs +++ b/tests/run-pass/heap_allocator.rs @@ -1,3 +1,4 @@ +// compile-flag: -Zmiri-seed= #![feature(allocator_api)] use std::ptr::NonNull; @@ -75,7 +76,6 @@ fn box_to_global() { fn main() { check_alloc(System); check_alloc(Global); - #[cfg(not(target_os = "windows"))] // TODO: Inspects allocation base address on Windows; needs intptrcast model check_overalign_requests(System); check_overalign_requests(Global); global_to_box(); From 0ea4b50025ea71e11aa8b326508b4d40e998727a Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sun, 30 Jun 2019 17:02:20 +0200 Subject: [PATCH 2/3] Miri is not deterministic any more --- tests/run-pass/heap_allocator.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/run-pass/heap_allocator.rs b/tests/run-pass/heap_allocator.rs index 457734cb60..3eb0f70fd6 100644 --- a/tests/run-pass/heap_allocator.rs +++ b/tests/run-pass/heap_allocator.rs @@ -33,8 +33,8 @@ fn check_overalign_requests(mut allocator: T) { let size = 8; // Greater than `size`. let align = 16; - // Miri is deterministic; no need to try many times. - let iterations = 1; + + let iterations = 5; unsafe { let pointers: Vec<_> = (0..iterations).map(|_| { allocator.alloc(Layout::from_size_align(size, align).unwrap()).unwrap() From 1f945cc2df629abd916ddfbb66274e73be13c3be Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sun, 30 Jun 2019 17:52:28 +0200 Subject: [PATCH 3/3] debug on AppVeyor --- .appveyor.yml | 1 + tests/run-pass/heap_allocator.rs | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.appveyor.yml b/.appveyor.yml index f7d3f990ac..225c2a38bc 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -31,6 +31,7 @@ install: build_script: - set RUST_TEST_NOCAPTURE=1 - set RUST_BACKTRACE=1 + - set MIRI_BACKTRACE=1 - set RUSTFLAGS=-C debug-assertions # Build and install miri - cargo build --release --all-features --all-targets diff --git a/tests/run-pass/heap_allocator.rs b/tests/run-pass/heap_allocator.rs index 3eb0f70fd6..d5d1652352 100644 --- a/tests/run-pass/heap_allocator.rs +++ b/tests/run-pass/heap_allocator.rs @@ -40,7 +40,8 @@ fn check_overalign_requests(mut allocator: T) { allocator.alloc(Layout::from_size_align(size, align).unwrap()).unwrap() }).collect(); for &ptr in &pointers { - assert_eq!((ptr.as_ptr() as usize) % align, 0, + let ptr = ptr.as_ptr() as usize; + assert_eq!(ptr % align, 0, "Got a pointer less aligned than requested") }