Skip to content

Add miri CI test #37

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

Merged
merged 3 commits into from
Jan 30, 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
8 changes: 7 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,16 @@ azure-devops = { project = "jonhoo/jonhoo", pipeline = "flurry", build = "15" }
codecov = { repository = "jonhoo/flurry", branch = "master", service = "github" }
maintenance = { status = "experimental" }

[features]
sanitize = ['crossbeam-epoch/sanitize']

[dependencies]
crossbeam-epoch = "0.8"
crossbeam-epoch = "0.9"
parking_lot = "0.10"
num_cpus = "1.12.0"

[dev-dependencies]
rand = "0.7"

[patch.crates-io]
crossbeam-epoch = { git = "https://github.com/cynecx/crossbeam.git", branch = "fix-unsoundness" }
51 changes: 51 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,57 @@ jobs:
condition: ne(variables.CACHE_RESTORED, 'true')
- script: cargo deny check
displayName: cargo deny
- job: miri
displayName: "Run miri on test suite"
dependsOn: deny
continueOnError: true # since miri sometimes isn't on nightly
pool:
vmImage: ubuntu-16.04
steps:
- template: install-rust.yml@templates
parameters:
rust: nightly
components:
- miri
# ignore leaks due to https://github.com/crossbeam-rs/crossbeam/issues/464
- bash: yes | cargo miri -Zmiri-ignore-leaks test
displayName: cargo miri test
- job: asan
dependsOn: deny
displayName: "Run address sanitizer on test suite"
pool:
vmImage: ubuntu-16.04
steps:
- template: install-rust.yml@templates
parameters:
rust: nightly
- bash: |
sudo ln -s /usr/bin/llvm-symbolizer-6.0 /usr/bin/llvm-symbolizer
sed -i '/\[features\]/i [profile.dev]' Cargo.toml
sed -i '/profile.dev/a opt-level = 1' Cargo.toml
cat Cargo.toml
displayName: Enable debug symbols
- script: |
env ASAN_OPTIONS="detect_odr_violation=0" RUSTFLAGS="-Z sanitizer=address" cargo test --features sanitize --target x86_64-unknown-linux-gnu
displayName: cargo -Z sanitizer=address test
- job: lsan
dependsOn: deny
displayName: "Run leak sanitizer on test suite"
pool:
vmImage: ubuntu-16.04
steps:
- template: install-rust.yml@templates
parameters:
rust: nightly
- bash: |
sudo ln -s /usr/bin/llvm-symbolizer-6.0 /usr/bin/llvm-symbolizer
sed -i '/\[features\]/i [profile.dev]' Cargo.toml
sed -i '/profile.dev/a opt-level = 1' Cargo.toml
cat Cargo.toml
displayName: Enable debug symbols
- script: |
env RUSTFLAGS="-Z sanitizer=leak" cargo test --features sanitize --target x86_64-unknown-linux-gnu
displayName: cargo -Z sanitizer=leak test

resources:
repositories:
Expand Down
16 changes: 12 additions & 4 deletions src/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1176,15 +1176,16 @@ where

// just remove the node if the value is the one we expected at method call
if observed_value.map(|ov| ov == ev).unwrap_or(true) {
// we remember the old value so that we can return it and mark it for deletion below
old_val = Some(ev);

// found the node but we have a new value to replace the old one
if let Some(nv) = new_value {
n.value.store(Owned::new(nv), Ordering::SeqCst);
// we are just replacing entry value and we do not want to remove the node
// so we stop iterating here
break;
}
// we remember the old value so that we can return it and mark it for deletion below
old_val = Some(ev);
// remove the BinEntry containing the removed key value pair from the bucket
if !pred.is_null() {
// either by changing the pointer of the previous BinEntry, if present
Expand Down Expand Up @@ -1512,6 +1513,7 @@ where
}
}

#[cfg(not(miri))]
#[inline]
/// Returns the number of physical CPUs in the machine (_O(1)_).
fn num_cpus() -> usize {
Expand All @@ -1520,6 +1522,12 @@ fn num_cpus() -> usize {
NCPU.load(Ordering::Relaxed)
}

#[cfg(miri)]
#[inline]
const fn num_cpus() -> usize {
1
}

#[test]
fn capacity() {
let map = HashMap::<usize, usize>::new();
Expand Down Expand Up @@ -1694,7 +1702,7 @@ fn replace_existing() {
let guard = epoch::pin();
map.insert(42, 42, &guard);
let old = map.replace_node(&42, Some(10), None, &guard);
assert!(old.is_none());
assert_eq!(old, Some(&42));
assert_eq!(*map.get(&42, &guard).unwrap(), 10);
}
}
Expand All @@ -1707,7 +1715,7 @@ fn replace_existing_observed_value_matching() {
map.insert(42, 42, &guard);
let observed_value = Shared::from(map.get(&42, &guard).unwrap() as *const _);
let old = map.replace_node(&42, Some(10), Some(observed_value), &guard);
assert!(old.is_none());
assert_eq!(old, Some(&42));
assert_eq!(*map.get(&42, &guard).unwrap(), 10);
}
}
Expand Down