Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop ignoring miri leaks #82

Merged
merged 9 commits into from
May 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,7 @@ jobs:
- miri
- script: cargo miri setup
displayName: cargo miri setup
# ignore leaks due to
# https://github.com/crossbeam-rs/crossbeam/issues/464
# which is
# https://github.com/rust-lang/miri/issues/940
- script: cargo miri -Zmiri-ignore-leaks test
- script: cargo miri test -- -Zmiri-ignore-leaks
displayName: cargo miri test
- job: asan
dependsOn: deny
Expand Down
13 changes: 7 additions & 6 deletions src/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@ use std::error::Error;
use std::fmt::{self, Debug, Display, Formatter};
use std::hash::{BuildHasher, Hash, Hasher};
use std::iter::FromIterator;
use std::sync::{
atomic::{AtomicIsize, AtomicUsize, Ordering},
Once,
};
use std::sync::atomic::{AtomicIsize, Ordering};

const ISIZE_BITS: usize = core::mem::size_of::<isize>() * 8;

Expand Down Expand Up @@ -62,8 +59,10 @@ const MAX_RESIZERS: isize = (1 << (ISIZE_BITS - RESIZE_STAMP_BITS)) - 1;
/// The bit shift for recording size stamp in `size_ctl`.
const RESIZE_STAMP_SHIFT: usize = ISIZE_BITS - RESIZE_STAMP_BITS;

static NCPU_INITIALIZER: Once = Once::new();
static NCPU: AtomicUsize = AtomicUsize::new(0);
#[cfg(not(miri))]
static NCPU_INITIALIZER: std::sync::Once = std::sync::Once::new();
#[cfg(not(miri))]
static NCPU: std::sync::atomic::AtomicUsize = std::sync::atomic::AtomicUsize::new(0);

macro_rules! load_factor {
($n: expr) => {
Expand Down Expand Up @@ -3383,6 +3382,7 @@ mod tree_bins {
}

#[test]
#[cfg_attr(miri, ignore)]
fn concurrent_tree_bin() {
let map = HashMap::<usize, usize, _>::with_hasher(ZeroHashBuilder);
// first, ensure that we have a tree bin
Expand Down Expand Up @@ -3537,6 +3537,7 @@ mod tree_bins {
}
#[test]
#[should_panic]
#[cfg_attr(miri, ignore)]
fn disallow_evil() {
let map: HashMap<_, _> = HashMap::default();
map.insert(42, String::from("hello"), &crossbeam_epoch::pin());
Expand Down
4 changes: 4 additions & 0 deletions tests/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ fn compute_if_present_remove() {
}

#[test]
#[cfg_attr(miri, ignore)]
fn concurrent_insert() {
let map = Arc::new(HashMap::<usize, usize>::new());

Expand Down Expand Up @@ -236,6 +237,7 @@ fn concurrent_insert() {
}

#[test]
#[cfg_attr(miri, ignore)]
fn concurrent_remove() {
let map = Arc::new(HashMap::<usize, usize>::new());

Expand Down Expand Up @@ -276,6 +278,7 @@ fn concurrent_remove() {
}

#[test]
#[cfg_attr(miri, ignore)]
fn concurrent_compute_if_present() {
let map = Arc::new(HashMap::<usize, usize>::new());

Expand Down Expand Up @@ -314,6 +317,7 @@ fn concurrent_compute_if_present() {
}

#[test]
#[cfg_attr(miri, ignore)]
fn concurrent_resize_and_get() {
let map = Arc::new(HashMap::<usize, usize>::new());
{
Expand Down
3 changes: 3 additions & 0 deletions tests/basic_ref.rs
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,7 @@ fn retain_force_some() {
}

#[test]
#[cfg_attr(miri, ignore)]
fn concurrent_insert() {
let map = Arc::new(HashMap::<usize, usize>::new());

Expand Down Expand Up @@ -443,6 +444,7 @@ fn concurrent_insert() {
}

#[test]
#[cfg_attr(miri, ignore)]
fn concurrent_remove() {
let map = Arc::new(HashMap::<usize, usize>::new());

Expand Down Expand Up @@ -483,6 +485,7 @@ fn concurrent_remove() {
}

#[test]
#[cfg_attr(miri, ignore)]
fn concurrent_compute_if_present() {
let map = Arc::new(HashMap::<usize, usize>::new());

Expand Down
2 changes: 2 additions & 0 deletions tests/borrow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ fn update() {
}

#[test]
#[cfg_attr(miri, ignore)]
fn concurrent_insert() {
let map = Arc::new(HashMap::<String, usize>::new());
let keys = Arc::new((0..64).map(|i| i.to_string()).collect::<Vec<_>>());
Expand Down Expand Up @@ -97,6 +98,7 @@ fn concurrent_insert() {
}

#[test]
#[cfg_attr(miri, ignore)]
fn concurrent_remove() {
let map = Arc::new(HashMap::<String, usize>::new());
let keys = Arc::new((0..64).map(|i| i.to_string()).collect::<Vec<_>>());
Expand Down
1 change: 1 addition & 0 deletions tests/cuckoo/stress.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ fn stress_find_thread(env: Arc<Environment>) {
}

#[test]
#[cfg_attr(miri, ignore)]
fn stress_test() {
let root = Arc::new(Environment::new());
let mut threads = Vec::new();
Expand Down
2 changes: 1 addition & 1 deletion tests/hasher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ impl BuildHasher for ZeroHashBuilder {
}

fn check<S: BuildHasher + Default>() {
let range = 0..1000;
let range = if cfg!(miri) { 0..16 } else { 0..1000 };
let guard = epoch::pin();
let map = HashMap::<i32, i32, S>::default();
for i in range.clone() {
Expand Down
1 change: 1 addition & 0 deletions tests/jdk/concurrent_associate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ fn insert(map: Arc<HashMap<KeyVal, KeyVal>>, k: KeyVal) {
}

#[test]
#[cfg_attr(miri, ignore)]
fn test_concurrent_insert<'g>() {
test(insert);
}
Expand Down
1 change: 1 addition & 0 deletions tests/jdk/concurrent_contains.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const ITERATIONS: usize = 256;
const ROUNDS: usize = 32;

#[test]
#[cfg_attr(miri, ignore)]
fn test_concurrent_contains_key() {
let map = HashMap::new();
let mut content = [0; NUM_ENTRIES];
Expand Down
9 changes: 9 additions & 0 deletions tests/jdk/map_check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,17 @@ use flurry::*;
use rand::prelude::*;
use std::hash::Hash;

#[cfg(not(miri))]
const SIZE: usize = 50_000;
#[cfg(miri)]
const SIZE: usize = 12;

// there must be more things absent than present!
#[cfg(not(miri))]
const ABSENT_SIZE: usize = 1 << 17;
#[cfg(miri)]
const ABSENT_SIZE: usize = 1 << 5;

const ABSENT_MASK: usize = ABSENT_SIZE - 1;

fn t1<K, V>(map: &HashMap<K, V>, keys: &[K], expect: usize)
Expand Down
2 changes: 2 additions & 0 deletions tests/set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ fn update() {
}

#[test]
#[cfg_attr(miri, ignore)]
fn concurrent_insert() {
let set = Arc::new(HashSet::<usize>::new());

Expand Down Expand Up @@ -128,6 +129,7 @@ fn concurrent_insert() {
}

#[test]
#[cfg_attr(miri, ignore)]
fn concurrent_remove() {
let set = Arc::new(HashSet::<usize>::new());

Expand Down