Practical Verification of High-Level Dataraces in Transactional Memory Programs
Vasco Pessanha (*) Ricardo J. Dias (*) João L Lourenço (*) (*) Eitan Farchi (+) Diogo Sousa (*)
(*) Universidade Nova de Lisboa (+) IBM Research Labs at Haifa
Practical Verification of High-Level Dataraces in Transactional - - PowerPoint PPT Presentation
Practical Verification of High-Level Dataraces in Transactional Memory Programs Vasco Pessanha (*) Ricardo J. Dias (*) Joo L Loureno (*) (*) Eitan Farchi (+) Diogo Sousa (*) (*) Universidade Nova de Lisboa (+) IBM Research Labs
Vasco Pessanha (*) Ricardo J. Dias (*) João L Lourenço (*) (*) Eitan Farchi (+) Diogo Sousa (*)
(*) Universidade Nova de Lisboa (+) IBM Research Labs at Haifa
2
3
@Atomic public void setX_1() { access x } // Not Atomic public void setX_2() { access x }
4
public void swap() { synchronized (lock) { read/write(coord.x) read/write(coord.y) } } public void reset() { synchronized (lock) { write(coord.x) } synchronized (lock) { write(coord.y) } }
V(swap) = = { {{x,y}} V(reset) = = { {{x},{y}} M = = V V(swap) = = { {{x,y}}
V(reset) a are s subsets o
the he M Maximal V View a and d don’t f form a a c cha hain
atomic { atomic { atomic {
5
Artho Extension
M and V
Vr(method), Vw Vw(method)
Mr(thread), Mw Mw(thread)
Mr and V Vw
Mw and V Vr
Mw and V Vw
6
read(x) Є v1 Є Vr(t1) write(x) Є v3 Є Vw(t1) write(x) Є v2 Є Vw(t2)
Thread 1 Thread 2
Stale Value
Not o
Read(x) Write(x) Write(x)
Thread 1 Thread 2
Stale Value
Transaction1 Transaction2 Transaction3 Not r read b before!
7
t2. t2.vi view1 1
t1 t1.vi view1 1
@Atomic public int getSum{ return x+y; } @Atomic public int setPair(int v1, int v2){ x = v1; y = v2; }
X Y
8
@Atomic public int getY{ return y; }
t2. t2.vi view1 1
t1 t1.vi view1 1
@Atomic public int setPair(int v1, int v2){ x = v1; y = v2; }
X Y
9
t2. t2.vi view2 2 t2. t2.vi view1 1
t1 t1.vi view1 1
@Atomic public int getY{ return y; } @Atomic public int getSum{ return x+y; } @Atomic public int setPair(int v1, int v2){ x = v1; y = v2; }
X Y
10
t1 t1.vi view1 1
t2. t2.vi view2 2 t2. t2.vi view1 1
public boolean equal{ int x = getX(); int y = getY(); return x == y; } @Atomic public int setPair(int v1, int v2){ x = v1; y = v2; }
X Y
11
Con Conflits ts be between: : Mr Mr and and Vw Vw Mw Mw and and Vr Vr Mw Mw and and Vw Vw
12
13
incX incX() () //r //r a and w w incX incX() () //r //r a and w w incX incX() () //r //r a and w w
read(x) write(x) (r,x,overwritten?) (w,x,readBefore?) RwW (r,x,f) (w,x,f) (w,x,?) RwW
24
TM-based Java ByteCode program Instance Type Analysis Views Analysis Method Analysis
Soot
Sensor Manager View Consistency Sensor Stale Value Sensor . . . . .
Collecting Information Datarace Detection
25
private List list; public void initA() { list = new LinkedList(); } public void initB() { list = new ArrayList(); } main(){ if(?) initA(); else initB(); list.add(1); }
??? ???
§ e.g. socket.getOutputStream.write(..)
26
writ write(soc socket)??? @Atomic public int get() {...} @Atomic public void add(int e) {...} public void inc(){ int x = get(); x++; add(x); } main(){ for(...) add(i); for(...) System.out.print(get()) }
§ Analysis of the ne new expressions § Assume the worst cenario (r(obj), w(obj)) § Ask for user annotations
27
§ Assume the worst cenario (r(obj), w(obj)) § Ask for user annotations
28
§ Dataflow and MHP analysis (future work) § Dataraces and Warnings
29
30
Detected 87% of the dataraces All 6 false positives are caused by the Single Variable Sensor
31
Dynamic Dispatch still not working in some cases Problems with native methods of the Socket Class
32
Conflict vs Real Conflict (DF) Variant of stale value pattern Conflict vs Real Conflict (DF) Conflict vs Real Conflict (MHP) Conflict vs Real Conflict (DF)
38
39