Efficient Model Checking of Data Races with Automatically-extracted Distance- based Fitness...
-
Upload
robyn-brittle -
Category
Documents
-
view
214 -
download
0
Transcript of Efficient Model Checking of Data Races with Automatically-extracted Distance- based Fitness...
![Page 1: Efficient Model Checking of Data Races with Automatically-extracted Distance- based Fitness Functions João Paulo, Elton Alves, Marcelo Damorim, Fernando.](https://reader037.fdocuments.us/reader037/viewer/2022110319/56649c535503460f948fd730/html5/thumbnails/1.jpg)
Efficient Model Checking of Data Races withAutomatically-extracted Distance-based Fitness Functions
João Paulo, Elton Alves, Marcelo Damorim, Fernando Castor
![Page 2: Efficient Model Checking of Data Races with Automatically-extracted Distance- based Fitness Functions João Paulo, Elton Alves, Marcelo Damorim, Fernando.](https://reader037.fdocuments.us/reader037/viewer/2022110319/56649c535503460f948fd730/html5/thumbnails/2.jpg)
“The biggest sea change in software development since the OO revolution is knocking at the door, and its name is Concurrency”.
Herb Sutter
![Page 3: Efficient Model Checking of Data Races with Automatically-extracted Distance- based Fitness Functions João Paulo, Elton Alves, Marcelo Damorim, Fernando.](https://reader037.fdocuments.us/reader037/viewer/2022110319/56649c535503460f948fd730/html5/thumbnails/3.jpg)
Concurrent Programming
• Is too hard!– Error prone
• It’s difficult to debug and find errors• Most programmers thinks that know how to
do it, but they don’t • NonDeterminism, Deadlocks, Data Races…
![Page 4: Efficient Model Checking of Data Races with Automatically-extracted Distance- based Fitness Functions João Paulo, Elton Alves, Marcelo Damorim, Fernando.](https://reader037.fdocuments.us/reader037/viewer/2022110319/56649c535503460f948fd730/html5/thumbnails/4.jpg)
Race Conditionpublic class Ref { int i; void inc() { int t = i + 1; i = t; } public static void main(String args[]){ final Ref ref = new Ref(); new Thread(new Runnable(){ public void run(){ ref.inc(); } }).start(); new Thread(new Runnable(){ public void run(){ref.inc(); } }).start(); assert ref.i == 2; }}
A race condition occurs if
• two threads access a shared variable at the same time without synchronization
• at least one of those accesses is a write
![Page 5: Efficient Model Checking of Data Races with Automatically-extracted Distance- based Fitness Functions João Paulo, Elton Alves, Marcelo Damorim, Fernando.](https://reader037.fdocuments.us/reader037/viewer/2022110319/56649c535503460f948fd730/html5/thumbnails/5.jpg)
public class Ref {
int i;void inc() { synchronized (this) { int t = i + 1; i = t; }}public static void main(String args[]) {
final Ref ref = new Ref();new Thread(new Runnable() {
public void run() { ref.inc();}}).start();new Thread(new Runnable() {
public void run() { ref.inc();}}).start(); assert ref.i == 2; }}
• Field Guarded by Lock
• Lock acquired before the thread enter in block
• Ensure race freedom
Guarantees the mutual exclusion
![Page 6: Efficient Model Checking of Data Races with Automatically-extracted Distance- based Fitness Functions João Paulo, Elton Alves, Marcelo Damorim, Fernando.](https://reader037.fdocuments.us/reader037/viewer/2022110319/56649c535503460f948fd730/html5/thumbnails/6.jpg)
So, we need (an easy) way to discover these kind error
![Page 7: Efficient Model Checking of Data Races with Automatically-extracted Distance- based Fitness Functions João Paulo, Elton Alves, Marcelo Damorim, Fernando.](https://reader037.fdocuments.us/reader037/viewer/2022110319/56649c535503460f948fd730/html5/thumbnails/7.jpg)
And there’s some tools to help us…
![Page 8: Efficient Model Checking of Data Races with Automatically-extracted Distance- based Fitness Functions João Paulo, Elton Alves, Marcelo Damorim, Fernando.](https://reader037.fdocuments.us/reader037/viewer/2022110319/56649c535503460f948fd730/html5/thumbnails/8.jpg)
![Page 9: Efficient Model Checking of Data Races with Automatically-extracted Distance- based Fitness Functions João Paulo, Elton Alves, Marcelo Damorim, Fernando.](https://reader037.fdocuments.us/reader037/viewer/2022110319/56649c535503460f948fd730/html5/thumbnails/9.jpg)
Program Model Checking
• It performs model checking directly into the code
• Rigorous method that exhaustively explores all possible SUT behaviors
• Is it a test?
![Page 10: Efficient Model Checking of Data Races with Automatically-extracted Distance- based Fitness Functions João Paulo, Elton Alves, Marcelo Damorim, Fernando.](https://reader037.fdocuments.us/reader037/viewer/2022110319/56649c535503460f948fd730/html5/thumbnails/10.jpg)
Model Checking
Fonte: http://babelfish.arc.nasa.gov/trac/jpf/wiki/intro/testing_vs_model_checking
![Page 11: Efficient Model Checking of Data Races with Automatically-extracted Distance- based Fitness Functions João Paulo, Elton Alves, Marcelo Damorim, Fernando.](https://reader037.fdocuments.us/reader037/viewer/2022110319/56649c535503460f948fd730/html5/thumbnails/11.jpg)
Java PathFinder(JPF)
• An explicit state software model checker – Focus is on finding bugs in Java programs– Developed by NASA since 1999– Turned Open Source in 2005
• State Explosion problem
![Page 12: Efficient Model Checking of Data Races with Automatically-extracted Distance- based Fitness Functions João Paulo, Elton Alves, Marcelo Damorim, Fernando.](https://reader037.fdocuments.us/reader037/viewer/2022110319/56649c535503460f948fd730/html5/thumbnails/12.jpg)
State Explosion
# thread #Atomic Section
Scheduling
2 2 6
2 8 12.870
2 16 601.080.390
![Page 13: Efficient Model Checking of Data Races with Automatically-extracted Distance- based Fitness Functions João Paulo, Elton Alves, Marcelo Damorim, Fernando.](https://reader037.fdocuments.us/reader037/viewer/2022110319/56649c535503460f948fd730/html5/thumbnails/13.jpg)
How JPF Works
• Backtracking• State Matching• Partial Order Reduction• Listener
![Page 14: Efficient Model Checking of Data Races with Automatically-extracted Distance- based Fitness Functions João Paulo, Elton Alves, Marcelo Damorim, Fernando.](https://reader037.fdocuments.us/reader037/viewer/2022110319/56649c535503460f948fd730/html5/thumbnails/14.jpg)
How do we Detect Potencial Races?
• Using a customized JPF listener• For each PUTFIELD or GETFIELD– Get Object Reference• Get the accessed Field
– Get Current Thread» Get Current Instruction
• Get the set of Acquireds Locks
![Page 15: Efficient Model Checking of Data Races with Automatically-extracted Distance- based Fitness Functions João Paulo, Elton Alves, Marcelo Damorim, Fernando.](https://reader037.fdocuments.us/reader037/viewer/2022110319/56649c535503460f948fd730/html5/thumbnails/15.jpg)
How do we Detect Potencial Races?[2]
• So, we have a report like this:
Account-Listener-Result.txt
![Page 16: Efficient Model Checking of Data Races with Automatically-extracted Distance- based Fitness Functions João Paulo, Elton Alves, Marcelo Damorim, Fernando.](https://reader037.fdocuments.us/reader037/viewer/2022110319/56649c535503460f948fd730/html5/thumbnails/16.jpg)
How do we Detect Potencial Races?[3]
• which can be simplified for this
Account-compacted.txt
![Page 17: Efficient Model Checking of Data Races with Automatically-extracted Distance- based Fitness Functions João Paulo, Elton Alves, Marcelo Damorim, Fernando.](https://reader037.fdocuments.us/reader037/viewer/2022110319/56649c535503460f948fd730/html5/thumbnails/17.jpg)
How good is our solution?
• Running Subject account , input 6• JPF go through 27.670 states• The solution converges in just 67 states• = 0,002 < 1 % of search State
Account-6-output.txt
![Page 18: Efficient Model Checking of Data Races with Automatically-extracted Distance- based Fitness Functions João Paulo, Elton Alves, Marcelo Damorim, Fernando.](https://reader037.fdocuments.us/reader037/viewer/2022110319/56649c535503460f948fd730/html5/thumbnails/18.jpg)
But we have some false positives…
![Page 19: Efficient Model Checking of Data Races with Automatically-extracted Distance- based Fitness Functions João Paulo, Elton Alves, Marcelo Damorim, Fernando.](https://reader037.fdocuments.us/reader037/viewer/2022110319/56649c535503460f948fd730/html5/thumbnails/19.jpg)
And we don´t want them.
![Page 20: Efficient Model Checking of Data Races with Automatically-extracted Distance- based Fitness Functions João Paulo, Elton Alves, Marcelo Damorim, Fernando.](https://reader037.fdocuments.us/reader037/viewer/2022110319/56649c535503460f948fd730/html5/thumbnails/20.jpg)
Our Research Idea
• Guide Model Checking• Attempt to Avoid State explosion• Uses heuristics to classifies a given a state– Interesting State has value 0– Boring State has value Integer.Max
• Uses distance based fitness function
![Page 21: Efficient Model Checking of Data Races with Automatically-extracted Distance- based Fitness Functions João Paulo, Elton Alves, Marcelo Damorim, Fernando.](https://reader037.fdocuments.us/reader037/viewer/2022110319/56649c535503460f948fd730/html5/thumbnails/21.jpg)
Our work-in-progress
• Find a heuristic function to guide the Model Checking
• Evaluate the function• This is harder than we thought
![Page 22: Efficient Model Checking of Data Races with Automatically-extracted Distance- based Fitness Functions João Paulo, Elton Alves, Marcelo Damorim, Fernando.](https://reader037.fdocuments.us/reader037/viewer/2022110319/56649c535503460f948fd730/html5/thumbnails/22.jpg)
Our work-in-progress[2]CallTrace cg; /* computed on-the-fly */AccessPair[] goals; /* computed on-the-fly */MethodInfo driver; /* test driver */
int eval(State jpfState) { ThreadInfo[] tis = jpfState.threadInfos(); TraceInfo ti = cg.getTrace(); for(int i=0; i<tis.length; i++) {
MethodInfo ma = tis[j].getCurrentMethod(); foreach p:Pair in goals { int d = dist(ti, p.mx) * dist(ti, p.my); if (d < min) min = d; } } return min;}
int dist(TraceInfo tSource, MethodInfo mDest) { int result = shortestPath(cg, tSource, mDest); if (result == -1) { // mDest not reachable from mSource return shortestPathFromDriver(cg, driver, mSource, mDest); }}
![Page 23: Efficient Model Checking of Data Races with Automatically-extracted Distance- based Fitness Functions João Paulo, Elton Alves, Marcelo Damorim, Fernando.](https://reader037.fdocuments.us/reader037/viewer/2022110319/56649c535503460f948fd730/html5/thumbnails/23.jpg)
If we are not so good to do it…
• The research goal could moves to compare the ‘potencial data race’ finded with other approaches
![Page 24: Efficient Model Checking of Data Races with Automatically-extracted Distance- based Fitness Functions João Paulo, Elton Alves, Marcelo Damorim, Fernando.](https://reader037.fdocuments.us/reader037/viewer/2022110319/56649c535503460f948fd730/html5/thumbnails/24.jpg)
Thanks