1 # Maximal-Causality-Reduction (MCR) Java version
3 MCR is a stateless model checker powered by an efficient reduction algorithm. It systematically explores the state-space of the program by collecting runtime traces of the program executions and constructing ordering constraints over the traces to generate other possible schedules. It captures the values of the writes and reads to prune redundant explorations. By enforcing at least one read to return a different value, it generates a new schedule which drives the program to reach a new state.
9 * Follow https://github.com/Z3Prover/z3
10 * Add `z3` to your PATH
11 * Eclipse (Neon 4.6) & Java 8
12 * The JDK version tested is 8u101. Higher versions should also be OK. JDK 8u65 was also tested, but it reported an exception related to the lamdba feature. We suggest the users to use JDK 8u101 or higher versions.
16 The tool can be easily used in Eclipse. Create an Eclispe workspace and import all the projects cloned from the Git repository (A build path error may happen. It may need to manually change the JDK version if the error happens). We put all the benchmarks under the folder `mcr-test/`. Users can choose a benchmark and then run it as a junit test. We use java agent for the bytecode instrumentation with the ASM framework. Users need to specify the following VM parameters (click the Run Configurations and choose the JUnit):
19 -Xmx1g -javaagent:lib/iagent.jar
24 We also support building the project in the terminal (or in Eclipse) using `ant`.
26 To compile mcr, run `ant ` under `mcr-controller/`, it will generates two jar files into `dist` directory.
28 To run the tests under `mcr-test/`, run `ant ` and then the bash script `mcr_cmd`.
29 The usage of `mcr_cmd`:
32 usage: ./mcr_cmd [options] test_class [parameters]
33 e.g., ./mcr_cmd [options] edu.tamu.aser.rvtest_simple_tests.Example
36 --debug -D print debug information
37 --static -S using static analysis (see the ECOOP'17 paper)
38 --class_path absolute_dir -c absolute_dir
39 if this is not specified, default the current bin/ as the class path
40 --memmory-model MM -m MM selecting the memory model SC/TSO/PSO (see the OOPLSA'16 paper)
44 If `-S` is specified, the tool will first run static analysis to generate the system dependencies graph into `SDGs` and then explore the program. The number of the reads and constraitns as well as the constraints solving times are save to the file under `stats/`.
46 `-m` selects the executed memory model. We currently support SC/TSO/PSO, and use SC.
48 ### to run the users' own tests
50 MCR works with JUnit 4. Given a JUnit 4 test class, it will explore
51 each of the tests in the test class. To use MCR, you need to add the
52 following annotation "@RunWith(JUnit4MCRRunner.class)" to the
53 test class. Users can refer to the benchmarks we put under 'mcr-test/src'
54 for more ideas about how to write the tests.
58 The following shows a simple example (See `Example.java` under `mcr-test/src/edu.tamu.aser.rvtest_simple_tests/`).
62 package edu.tamu.aser.rvtest;
63 import static org.junit.Assert.*;
64 import org.junit.Test;
65 import org.junit.runner.RunWith;
66 import edu.tamu.aser.exploration.JUnit4MCRRunner;
68 @RunWith(JUnit4MCRRunner.class)
69 public class Example {
71 private static int x, y;
72 public static void main(String[] args) {
73 Thread t1 = new Thread(new Runnable() {
96 After running MCR on the program above, we can generate the following output:
99 EXPLORING: edu.tamu.aser.rvtest_collection.Example.test: 09:12:12
102 =============== EXPLORATION STATS ===============
103 NUMBER OF SCHEDULES: 3
104 EXPLORATION TIME: 0:00:00
105 =================================================
109 ### Explanation of the output
112 `=============== EXPLORATION STATS ===============`
114 shows the number of the executions explored for this progam and the time taken.
116 When an exception is triggered by the program, the tool will print how this error is triggered and how to reproduce it. Take `TestDeadlock.java` under `mcr-test/src/edu.tamu.aser.rvtest_simple_tests/` as an example. Our tool prints out
120 !!! FAILURE DETECTED DURING EXPLORATION OF SCHEDULE #2: Deadlock detected in schedule
121 The following trace triggered this error:
122 Thread-1_TestDeadlock.java:67:start
123 Thread-1_TestDeadlock.java:68:start
124 Thread-6_TestDeadlock.java:63:read
125 Thread-6_TestDeadlock.java:29:read
126 Thread-6_TestDeadlock.java:29:Lock
127 Thread-6_TestDeadlock.java:35:read
128 Thread-5_TestDeadlock.java:55:read
129 Thread-5_TestDeadlock.java:19:read
130 Thread-5_TestDeadlock.java:19:Lock
131 Thread-5_TestDeadlock.java:20:write
132 Thread-5_TestDeadlock.java:21:read
133 Thread-6_TestDeadlock.java:36:read
139 * [ECOOP'17] [Speeding Up Maximal Causality Reduction with Static Dependency Analysis](https://huangshiyou.github.io/files/Huang-ECOOP-2017-16.pdf)
141 * [OOPSLA'16] [Maximal Causality Reduction for TSO and PSO](https://huangshiyou.github.io/files/mcr_relax-huang.pdf)
143 * [PLDI'15] [Stateless Model Checking Concurrent Programs with Maximal Causality Reduction](https://parasol.tamu.edu/~jeff/academic/mcr.pdf)
145 * [PLDI'14] [Maximal Sound Predictive Race Detection
146 with Control Flow Abstraction](http://fsl.cs.illinois.edu/FSL/papers/2014/huang-meredith-rosu-2014-pldi/huang-meredith-rosu-2014-pldi-public.pdf)