Practical Verification of High-Level Dataraces in Transactional - - PowerPoint PPT Presentation

practical verification of high level dataraces in
SMART_READER_LITE
LIVE PREVIEW

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


slide-1
SLIDE 1

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

slide-2
SLIDE 2

Concurrent Programming

2

CONTEXT

And with TM...?

  • No DeadLocks
  • No Priority Inversion
slide-3
SLIDE 3

Dataraces

3

LOW-LEVEL DATARACES

@Atomic public void setX_1() { access x } // Not Atomic public void setX_2() { access x }

Low-level Dataraces...

slide-4
SLIDE 4

HIGH-LEVEL DATARACES

¡ Artho (2003)

§ Views § Maximal Views § Con Conflict ct ó views are subsets of a Maximal View and don’t form a chain

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

  • f t

the he M Maximal V View a and d don’t f form a a c cha hain

atomic { atomic { atomic {

slide-5
SLIDE 5

OUR APPROACH

¡ Extend Artho’s Algorithm for the detection of HLDR

§ 1. Differentiate Reads and Writes

5

Artho Extension

  • V(method)
  • M(thread)
  • Conflits between M

M and V

  • Vr

Vr(method), Vw Vw(method)

  • Mr

Mr(thread), Mw Mw(thread)

  • Conflits between:
  • Mr

Mr and V Vw

  • Mw

Mw and V Vr

  • Mw

Mw and V Vw

slide-6
SLIDE 6

OUR APPROACH

¡ Extend Artho’s Algorithm

§ 1. Differentiate Reads and Writes § 2. Complement it with the detections of stale-values

6

read(x) Є v1 Є Vr(t1) write(x) Є v3 Є Vw(t1) write(x) Є v2 Є Vw(t2)

Thread 1 Thread 2

Stale Value

Not o

  • verwritten!

Read(x) Write(x) Write(x)

Thread 1 Thread 2

Stale Value

Transaction1 Transaction2 Transaction3 Not r read b before!

slide-7
SLIDE 7

High-level Dataraces

7

HIGH-LEVEL DATARACES

T2

t2. t2.vi view1 1

T1

t1 t1.vi view1 1

@Atomic public int getSum{ return x+y; } @Atomic public int setPair(int v1, int v2){ x = v1; y = v2; }

Pair

X Y

slide-8
SLIDE 8

High-level Dataraces

8

HIGH-LEVEL DATARACES

@Atomic public int getY{ return y; }

T2

t2. t2.vi view1 1

T1

t1 t1.vi view1 1

@Atomic public int setPair(int v1, int v2){ x = v1; y = v2; }

Pair

X Y

slide-9
SLIDE 9

High-level Dataraces

9

HIGH-LEVEL DATARACES

T2

t2. t2.vi view2 2 t2. t2.vi view1 1

T1

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; }

Pair

X Y

slide-10
SLIDE 10

High-level Dataraces

10

HIGH-LEVEL DATARACES

T1

t1 t1.vi view1 1

T2

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; }

Pair

X Y

slide-11
SLIDE 11

¡ View safety (high-level datarace free)

11

HIGH-LEVEL DATARACES

Con Conflits ts be between: : Mr Mr and and Vw Vw Mw Mw and and Vr Vr Mw Mw and and Vw Vw

¡ View compatibility

slide-12
SLIDE 12

Stale-Value Errors

12

STALE-VALUES

public void incX(){ int tmp = getX(); tmp = tmp + 1; setX(tmp); } setX(2)

slide-13
SLIDE 13

Stale-Value Errors

13

STALE-VALUES

public void incX(){ int tmp = getX(); tmp = tmp + 1; setX(tmp); } setX(2)

Teixeira (2010) RwW pattern

//Read(x) //write(x) //write(x)

slide-14
SLIDE 14

Stale-Value Errors

STALE-VALUES

@Atomic public void incX(){ x = x + 1; }

Problem...?

//read(x) and write(x)

T2 T2 T1 T1

incX incX() () //r //r a and w w incX incX() () //r //r a and w w incX incX() () //r //r a and w w

slide-15
SLIDE 15

Stale-Value Errors

STALE-VALUES

@Atomic public void incX(){ x = x + 1; } //(r,x,t), (w,x,t)

read(x) write(x) (r,x,overwritten?) (w,x,readBefore?) RwW (r,x,f) (w,x,f) (w,x,?) RwW

slide-16
SLIDE 16

Stale-Value Errors

STALE-VALUES

public void specialSet(int v){ int old = getX(); System.out.println(old); setX(v); } setX(2)

Problem...?

//(r,x,f) //(w,x,f) //(w,x,f)

slide-17
SLIDE 17

24

MOTH

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

slide-18
SLIDE 18

PROBLEMS (1)

¡ Problems

§ Dynamic dispatch (interface methods)

25

private List list; public void initA() { list = new LinkedList(); } public void initB() { list = new ArrayList(); } main(){ if(?) initA(); else initB(); list.add(1); }

??? ???

slide-19
SLIDE 19

PROBLEMS (1)

¡ Problems

§ Dynamic dispatch (interface methods) § Native methods

§ e.g. socket.getOutputStream.write(..)

§ “Conflicts” versus “Real Conflicts”

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()) }

slide-20
SLIDE 20

PROBLEMS (2)

¡ Solutions

§ Dynamic dispatch (interface methods)

§ Analysis of the ne new expressions § Assume the worst cenario (r(obj), w(obj)) § Ask for user annotations

27

slide-21
SLIDE 21

PROBLEMS (2)

¡ Solutions

§ Dynamic dispatch (interface methods) § Native methods

§ Assume the worst cenario (r(obj), w(obj)) § Ask for user annotations

28

slide-22
SLIDE 22

PROBLEMS (2)

¡ Solutions

§ Dynamic dispatch (interface methods) § Native methods § “Conflicts” versus “Real Conflicts”

§ Dataflow and MHP analysis (future work) § Dataraces and Warnings

29

slide-23
SLIDE 23

30

RESULTS

Detected 87% of the dataraces All 6 false positives are caused by the Single Variable Sensor

slide-24
SLIDE 24

31

RESULTS

F a l s e N e g a t i v e s

Dynamic Dispatch still not working in some cases Problems with native methods of the Socket Class

slide-25
SLIDE 25

32

RESULTS

F a l s e P

  • s

i t i v e s

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)

slide-26
SLIDE 26

¡ Extension of Artho’s initial proposal

§ Distinction on R/W operations § Detection of stale values

¡ MoTH is a practical tool to use with

§ Experiments with medium sized Java programs (100’s

  • f lines) are very promisor

§ Plugin based architecture

¡ Ongoing work to include

§ Data-flow and control flow anaysis

38

CONCLUSIONS

slide-27
SLIDE 27

39

THE END

Thank ¡you ¡ ¡ Ques-ons? ¡