-
Notifications
You must be signed in to change notification settings - Fork 390
Add minimal functionality for using GenMC mode #4506
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
Draft
Patrick-6
wants to merge
90
commits into
rust-lang:master
Choose a base branch
from
Patrick-6:miri-genmc-mvp
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+3,608
−481
Draft
Changes from 3 commits
Commits
Show all changes
90 commits
Select commit
Hold shift + click to select a range
3fc854d
WIP: Add initial support for running Miri flamegraph (no flamegraph o…
Patrick-6 7fcd173
WIP: Start working on Miri-GenMC interop.
Patrick-6 af9d846
Remove duplicate tests
Patrick-6 9d7e964
Clean up comments.
Patrick-6 1631c9d
Remove leak checks from tests where possible, fix leak check for bloc…
Patrick-6 d9a6629
Clean up exit handling.
Patrick-6 c968c94
Remove unused VerificationError enum.
Patrick-6 24e42d0
Simplify GenMC test includes.
Patrick-6 50afd6f
Inline test folders, move tests, remove extra test variants.
Patrick-6 e194cc8
Remove extra newline in program output
Patrick-6 c0f9987
Remove duplicate call to handleAlloc.
Patrick-6 cd5be0f
Improve comments
Patrick-6 8d49e29
Cleanup C++ code.
Patrick-6 1dba4cd
Use existing truncation function.
Patrick-6 69f7689
Clean up error handling and logs.
Patrick-6 92978f0
Clean up thread id mapping code.
Patrick-6 a9dbdf8
Extract address generator struct, clean up GenMC global allocator code.
Patrick-6 78208d8
Remove redundant test
Patrick-6 001d04d
Apply suggestions from code review to C++ code.
Patrick-6 5d4a027
Apply suggestions from code review to memory allocation code.
Patrick-6 5c486c4
Clean up code, tests, docs. Remove old debugging code. Add fixes for …
Patrick-6 1c3b639
Rebase GenMC onto config-move branch, cleanup, add documentation.
Patrick-6 5035978
Apply suggestions from code review, cleanup, improve error reporting,…
Patrick-6 17f2e83
Expand documentation and comments, clean up excution graph printing, …
Patrick-6 bb3db74
Add more doc comments, split off per-execution state, split off sched…
Patrick-6 f8cde2e
Clean up program exit and blocked execution handling.
Patrick-6 6925bb2
Remove loom tests, remove disabled tests.
Patrick-6 6336d30
Remove __VERIFIER_assume
Patrick-6 4b2708e
Remove Mutex handling, do cleanup.
Patrick-6 6425cd9
Remove code for warning about missing GenMC support
Patrick-6 29a24dd
Remove graph printing
Patrick-6 4ccc075
Remove estimation mode.
Patrick-6 df33e8e
Simplify scheduling and next instruction type determination, do cleanup
Patrick-6 8d20224
Remove atomic fence support.
Patrick-6 63754e4
Remove MIRI_LOG debug prints.
Patrick-6 c6a039c
Remove support for sending pointers to GenMC.
Patrick-6 645f7c9
More cleanup
Patrick-6 fc7fd3a
Remove CXX NonNullUniquePtr.
Patrick-6 19df2b3
Remove RMW / CAS support
Patrick-6 fcd889d
C++ code cleanup
Patrick-6 4081133
Remove mixed atomic-non-atomic and 'read from initial value' support.
Patrick-6 d80db1c
Disable genmc feature by default.
Patrick-6 9511e9b
Cleanup and formatting.
Patrick-6 91c804b
Update GenMC commit.
Patrick-6 b9973b1
fixup! Remove graph printing
Patrick-6 483544a
Fix rerun-if
Patrick-6 1c11a13
Remove accidentially included file.
Patrick-6 56a71b8
Set separate build directories for the two C++ build steps.
Patrick-6 dae6996
Update license to match GenMC dependency.
Patrick-6 52de0d8
Add newlines after every markdown header, add disclaimer about cargo …
Patrick-6 0310f07
Combine log level documentation into one bullet point
Patrick-6 f0df253
Use correct path for GenMC rebuild detection.
Patrick-6 e2ad56a
Remove unused operator implementation
Patrick-6 190f712
Remove helper macro, fix naming naming conventions.
Patrick-6 1b29fe4
Cleanup, fix naming conventions.
Patrick-6 9edc8f4
Define struct before it is used.
Patrick-6 8f3479d
Fix naming conventions
Patrick-6 b1813c4
Clean up C++ files
Patrick-6 545566e
Add clang-format file for C++ code in Miri. Format all C++ files.
Patrick-6 221f124
Make naming convention consistent for all C++ code.
Patrick-6 82d9a84
More naming convention fixes, add const where applicable.
Patrick-6 58f0757
Apply suggestions from code review.
Patrick-6 81d61af
Apply more suggestions from code review.
Patrick-6 43f481b
Upgrade CXX version, fix unused warning, minor cleanup.
Patrick-6 a46f795
Apply suggestions from code review
Patrick-6 a6d9bd0
Clean up tests, add extra checks, fix 2w2w test
Patrick-6 af6e8bd
Switch to InterpResult instead of panicking.
Patrick-6 6e1ce77
Make format command use relative paths
Patrick-6 eb9c697
Apply suggestions from code review, fix double type definitions betwe…
Patrick-6 cff2beb
Clean up test and add comments
Patrick-6 f232722
Inline DUMMY value, clean up non-atomic access handling, improve doc …
Patrick-6 b788844
Clean up execution end handling, upgrade CXX version and remove hack …
Patrick-6 12a2d05
Move constructor functions for Result types to C++
Patrick-6 541762a
Add safety comments, encapsulate possible data races due to GenMC log…
Patrick-6 bb1008c
Clean up tests
Patrick-6 fb1c43f
Apply suggestions from code review
Patrick-6 2168a0d
Clean up log level handling.
Patrick-6 7bc8044
Cleanup and add comments explaining tests, rename variants, add more …
Patrick-6 23863bd
Improve comment for next instruction kind detection.
Patrick-6 7ccf97f
downgrade GenMC logging from info to debug, minor cleanup
Patrick-6 9a12377
More test cleanup, fix naming and comment.
Patrick-6 b92c917
Fix safety comment formatting
Patrick-6 0b891a2
Update GenMC commit and do required changes on the Miri side.
Patrick-6 3654409
Switch more tests to use pthread closure API, add more correctness ch…
Patrick-6 a714643
Expand on comment about initial value getter.
Patrick-6 e456286
Switch GenMC repo
Patrick-6 01c05f2
Clean up remaining tests and add more correctness checks.
Patrick-6 04c4e38
Remove comment about GPL dependency
Patrick-6 6182abe
Improve comments, update default GenMC log level, fix Miri 'info' log
Patrick-6 b180a78
Apply suggestion for comment, add fixme for using std::process::abort.
Patrick-6 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,47 @@ | ||
//@compile-flags: -Zmiri-genmc -Zmiri-disable-stacked-borrows | ||
|
||
// Translated from GenMC's "litmus/LB" test. | ||
|
||
#![no_main] | ||
|
||
#[path = "../../../utils/genmc.rs"] | ||
mod genmc; | ||
|
||
use std::ffi::c_void; | ||
use std::sync::atomic::{AtomicU64, Ordering}; | ||
use std::sync::atomic::AtomicU64; | ||
use std::sync::atomic::Ordering::*; | ||
|
||
use crate::genmc::*; | ||
|
||
static X: AtomicU64 = AtomicU64::new(0); | ||
static Y: AtomicU64 = AtomicU64::new(0); | ||
|
||
use crate::genmc::*; | ||
|
||
#[unsafe(no_mangle)] | ||
fn miri_start(_argc: isize, _argv: *const *const u8) -> isize { | ||
let _ids = unsafe { create_pthreads_no_params([thread_1, thread_2]) }; | ||
|
||
0 | ||
} | ||
|
||
extern "C" fn thread_1(_value: *mut c_void) -> *mut c_void { | ||
Y.load(Ordering::Acquire); | ||
X.store(2, Ordering::Release); | ||
std::ptr::null_mut() | ||
} | ||
|
||
extern "C" fn thread_2(_value: *mut c_void) -> *mut c_void { | ||
X.load(Ordering::Acquire); | ||
Y.store(1, Ordering::Release); | ||
std::ptr::null_mut() | ||
// FIXME(genmc,HACK): remove these initializing writes once Miri-GenMC supports mixed atomic-non-atomic accesses. | ||
X.store(0, Relaxed); | ||
Y.store(0, Relaxed); | ||
|
||
unsafe { | ||
let mut a = 1234; | ||
let mut b = 1234; | ||
let ids = [ | ||
spawn_pthread_closure(|| { | ||
a = Y.load(Acquire); | ||
X.store(2, Release); | ||
}), | ||
spawn_pthread_closure(|| { | ||
b = X.load(Acquire); | ||
Y.store(1, Release); | ||
}), | ||
]; | ||
// Join so we can read the final values. | ||
join_pthreads(ids); | ||
|
||
// Check that we don't get any unexpected values: | ||
if !matches!((a, b), (0, 0) | (0, 2) | (1, 0)) { | ||
std::process::abort(); | ||
} | ||
|
||
0 | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,47 @@ | ||
//@compile-flags: -Zmiri-genmc -Zmiri-disable-stacked-borrows | ||
|
||
// Translated from GenMC's "litmus/MP" test. | ||
|
||
#![no_main] | ||
|
||
#[path = "../../../utils/genmc.rs"] | ||
mod genmc; | ||
|
||
use std::ffi::c_void; | ||
use std::sync::atomic::{AtomicU64, Ordering}; | ||
use std::sync::atomic::AtomicU64; | ||
use std::sync::atomic::Ordering::*; | ||
|
||
use crate::genmc::*; | ||
|
||
static X: AtomicU64 = AtomicU64::new(0); | ||
static Y: AtomicU64 = AtomicU64::new(0); | ||
|
||
use crate::genmc::*; | ||
|
||
#[unsafe(no_mangle)] | ||
fn miri_start(_argc: isize, _argv: *const *const u8) -> isize { | ||
let _ids = unsafe { create_pthreads_no_params([thread_1, thread_2]) }; | ||
|
||
0 | ||
} | ||
|
||
extern "C" fn thread_1(_value: *mut c_void) -> *mut c_void { | ||
X.store(1, Ordering::Release); | ||
Y.store(1, Ordering::Release); | ||
std::ptr::null_mut() | ||
} | ||
|
||
extern "C" fn thread_2(_value: *mut c_void) -> *mut c_void { | ||
Y.load(Ordering::Acquire); | ||
X.load(Ordering::Acquire); | ||
std::ptr::null_mut() | ||
// FIXME(genmc,HACK): remove these initializing writes once Miri-GenMC supports mixed atomic-non-atomic accesses. | ||
X.store(0, Relaxed); | ||
Y.store(0, Relaxed); | ||
|
||
unsafe { | ||
let mut a = 1234; | ||
let mut b = 1234; | ||
let ids = [ | ||
spawn_pthread_closure(|| { | ||
X.store(1, Release); | ||
Y.store(1, Release); | ||
}), | ||
spawn_pthread_closure(|| { | ||
a = Y.load(Acquire); | ||
b = X.load(Acquire); | ||
}), | ||
]; | ||
// Join so we can read the final values. | ||
join_pthreads(ids); | ||
|
||
// Check that we don't get any unexpected values: | ||
if !matches!((a, b), (0, 0) | (0, 1) | (1, 1)) { | ||
std::process::abort(); | ||
} | ||
|
||
0 | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,47 @@ | ||
//@compile-flags: -Zmiri-genmc -Zmiri-disable-stacked-borrows | ||
|
||
// Translated from GenMC's "litmus/SB" test. | ||
|
||
#![no_main] | ||
|
||
#[path = "../../../utils/genmc.rs"] | ||
mod genmc; | ||
|
||
use std::ffi::c_void; | ||
use std::sync::atomic::{AtomicU64, Ordering}; | ||
use std::sync::atomic::AtomicU64; | ||
use std::sync::atomic::Ordering::*; | ||
|
||
use crate::genmc::*; | ||
|
||
static X: AtomicU64 = AtomicU64::new(0); | ||
static Y: AtomicU64 = AtomicU64::new(0); | ||
|
||
use crate::genmc::*; | ||
|
||
#[unsafe(no_mangle)] | ||
fn miri_start(_argc: isize, _argv: *const *const u8) -> isize { | ||
let _ids = unsafe { create_pthreads_no_params([thread_1, thread_2]) }; | ||
|
||
0 | ||
} | ||
|
||
extern "C" fn thread_1(_value: *mut c_void) -> *mut c_void { | ||
X.store(1, Ordering::Release); | ||
Y.load(Ordering::Acquire); | ||
std::ptr::null_mut() | ||
} | ||
|
||
extern "C" fn thread_2(_value: *mut c_void) -> *mut c_void { | ||
Y.store(1, Ordering::Release); | ||
X.load(Ordering::Acquire); | ||
std::ptr::null_mut() | ||
// FIXME(genmc,HACK): remove these initializing writes once Miri-GenMC supports mixed atomic-non-atomic accesses. | ||
X.store(0, Relaxed); | ||
Y.store(0, Relaxed); | ||
|
||
unsafe { | ||
let mut a = 1234; | ||
let mut b = 1234; | ||
let ids = [ | ||
spawn_pthread_closure(|| { | ||
X.store(1, Release); | ||
a = Y.load(Acquire); | ||
}), | ||
spawn_pthread_closure(|| { | ||
Y.store(1, Release); | ||
b = X.load(Acquire); | ||
}), | ||
]; | ||
// Join so we can read the final values. | ||
join_pthreads(ids); | ||
|
||
// Check that we don't get any unexpected values: | ||
if !matches!((a, b), (0, 0) | (0, 1) | (1, 0) | (1, 1)) { | ||
std::process::abort(); | ||
} | ||
|
||
0 | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,47 @@ | ||
//@compile-flags: -Zmiri-genmc -Zmiri-disable-stacked-borrows | ||
|
||
// Translated from GenMC's "litmus/default" test. | ||
|
||
#![no_main] | ||
|
||
#[path = "../../../utils/genmc.rs"] | ||
mod genmc; | ||
|
||
use std::ffi::c_void; | ||
use std::sync::atomic::{AtomicU64, Ordering}; | ||
use std::sync::atomic::AtomicU64; | ||
use std::sync::atomic::Ordering::*; | ||
|
||
use crate::genmc::*; | ||
|
||
static X: AtomicU64 = AtomicU64::new(0); | ||
|
||
#[unsafe(no_mangle)] | ||
fn miri_start(_argc: isize, _argv: *const *const u8) -> isize { | ||
let _ids = unsafe { create_pthreads_no_params([thread_1, thread_2, thread_3]) }; | ||
|
||
0 | ||
} | ||
|
||
extern "C" fn thread_1(_value: *mut c_void) -> *mut c_void { | ||
X.load(Ordering::Acquire); | ||
X.load(Ordering::Acquire); | ||
std::ptr::null_mut() | ||
} | ||
|
||
extern "C" fn thread_2(_value: *mut c_void) -> *mut c_void { | ||
X.store(1, Ordering::Release); | ||
std::ptr::null_mut() | ||
} | ||
|
||
extern "C" fn thread_3(_value: *mut c_void) -> *mut c_void { | ||
X.store(2, Ordering::Release); | ||
std::ptr::null_mut() | ||
// FIXME(genmc,HACK): remove this initializing write once Miri-GenMC supports mixed atomic-non-atomic accesses. | ||
X.store(0, Relaxed); | ||
|
||
unsafe { | ||
let mut a = 1234; | ||
let mut b = 1234; | ||
let ids = [ | ||
spawn_pthread_closure(|| { | ||
a = X.load(Acquire); | ||
b = X.load(Acquire); | ||
}), | ||
spawn_pthread_closure(|| { | ||
X.store(1, Release); | ||
}), | ||
spawn_pthread_closure(|| { | ||
X.store(2, Release); | ||
}), | ||
]; | ||
// Join so we can read the final values. | ||
join_pthreads(ids); | ||
|
||
// Check that we don't get any unexpected values: | ||
if !matches!((a, b), (0, 0) | (0, 1) | (0, 2) | (1, 1) | (1, 2) | (2, 1) | (2, 2)) { | ||
std::process::abort(); | ||
} | ||
|
||
0 | ||
} | ||
} |
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
(GenMC) Verification complete. No errors were detected. | ||
Number of complete executions explored: 9 |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.