practical verification of high level dataraces in
play

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


  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

  2. CONTEXT Concurrent Programming And with TM...? • No DeadLocks • No Priority Inversion 2

  3. LOW-LEVEL DATARACES Dataraces Low-level Dataraces... @Atomic // Not Atomic public void setX_1() { public void setX_2() { access x access x } } 3

  4. HIGH-LEVEL DATARACES ¡ Artho (2003) § Views V(swap) = = { {{x,y}} public void swap() { synchronized (lock) { atomic { V(reset) = = { {{x},{y}} read/write(coord.x) read/write(coord.y) } § Maximal Views } public void reset() { M = = V V(swap) = = { {{x,y}} synchronized (lock) { atomic { write(coord.x) § Con Conflict ct ó views are } synchronized (lock) { atomic { subsets of a Maximal View write(coord.y) } and don’t form a chain } V(reset) a are s subsets o of t the he M Maximal V View a and d don’t f form a a c cha hain 4

  5. OUR APPROACH ¡ Extend Artho’s Algorithm for the detection of HLDR § 1. Differentiate Reads and Writes Extension Artho • V(method) • Vr(method), Vw Vr Vw(method) • M(thread) • Mr Mr(thread), Mw Mw(thread) • Conflits between M M and V • Conflits between: • Mr and V Mr Vw • Mw Mw and V Vr • Mw Mw and V Vw 5

  6. OUR APPROACH ¡ Extend Artho’s Algorithm § 1. Differentiate Reads and Writes § 2. Complement it with the detections of stale-values Transaction1 Transaction3 Thread 1 Stale Read(x) Write(x) Value Thread 2 Write(x) Transaction2 Thread 1 read(x) Є v1 Є Vr(t1) write(x) Є v3 Є Vw(t1) Stale Value write(x) Є v2 Є Vw(t2) Thread 2 Not o overwritten! Not r read b before! 6

  7. HIGH-LEVEL DATARACES High-level Dataraces @Atomic public int setPair(int v1, Pair @Atomic int v2){ public int getSum{ x = v1; return x+y; y = v2; X Y } } t1.vi t1 view1 1 t2.vi t2. view1 1 T2 T1 7

  8. HIGH-LEVEL DATARACES High-level Dataraces @Atomic public int setPair(int v1, Pair @Atomic int v2){ public int getY{ x = v1; return y; y = v2; X Y } } t1.vi t1 view1 1 t2.vi t2. view1 1 T1 T2 8

  9. HIGH-LEVEL DATARACES High-level Dataraces @Atomic @Atomic public int getY{ public int setPair(int v1, return y; Pair int v2){ } x = v1; @Atomic y = v2; public int getSum{ X Y } return x+y; } t1.vi t1 view1 1 t2. t2.vi view2 2 t2.vi t2. view1 1 T1 T2 9

  10. HIGH-LEVEL DATARACES High-level Dataraces @Atomic public int setPair(int v1, public boolean equal{ Pair int v2){ int x = getX(); x = v1; int y = getY(); y = v2; return x == y; X Y } } t1 t1.vi view1 1 t2. t2.vi view2 2 t2.vi t2. view1 1 T1 T2 10

  11. HIGH-LEVEL DATARACES ¡ View compatibility Con Conflits ts be between: : Mr and Mr and Vw Vw Mw Mw and and Vr Vr Mw Mw and and Vw Vw ¡ View safety (high-level datarace free) 11

  12. STALE-VALUES Stale-Value Errors public void incX(){ int tmp = getX(); tmp = tmp + 1; setX(2) setX(tmp); } 12

  13. STALE-VALUES Stale-Value Errors Teixeira (2010) RwW pattern public void incX(){ //Read(x) int tmp = getX(); tmp = tmp + 1; setX(2) //write(x) //write(x) setX(tmp); } 13

  14. STALE-VALUES Stale-Value Errors Problem...? T2 T2 T1 T1 @Atomic incX() incX () //r //r a and w w public void incX(){ incX incX() () //r //r a and w w x = x + 1; //read(x) and write(x) incX incX() () //r //r a and w w }

  15. STALE-VALUES Stale-Value Errors read(x) (r,x,overwritten?) write(x) (w,x,readBefore?) (r,x,f) (w,x,f) RwW (w,x,?) @Atomic public void incX(){ //(r,x,t), (w,x,t) x = x + 1; } RwW

  16. STALE-VALUES Stale-Value Errors Problem...? public void specialSet(int v){ //(r,x,f) int old = getX(); System.out.println(old); setX(2) //(w,x,f) //(w,x,f) setX(v); }

  17. MOTH Instance Type View Consistency Analysis Sensor Sensor Manager TM-based Java Soot ByteCode program Views Stale Value Analysis Sensor Method Analysis . . . . . Collecting Information Datarace Detection 24

  18. PROBLEMS (1) ¡ Problems § Dynamic dispatch (interface methods) private List list; public void initA() { list = new LinkedList(); } public void initB() { list = new ArrayList(); } main(){ if (?) initA(); else initB(); ??? ??? list.add(1); } 25

  19. PROBLEMS (1) @Atomic ¡ Problems public int get() {...} § Dynamic dispatch (interface methods) @Atomic public void add( int e) {...} § Native methods public void inc(){ int x = get(); § e.g. socket.getOutputStream.write(..) x++; write(soc writ socket)??? add(x); } § “Conflicts” versus “Real Conflicts” main(){ for(...) add(i); for(...) System.out.print(get()) } 26

  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

  21. PROBLEMS (2) ¡ Solutions § Dynamic dispatch (interface methods) § Native methods § Assume the worst cenario (r(obj), w(obj)) § Ask for user annotations 28

  22. PROBLEMS (2) ¡ Solutions § Dynamic dispatch (interface methods) § Native methods § “Conflicts” versus “Real Conflicts” § Dataflow and MHP analysis (future work) § Dataraces and Warnings 29

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

  24. RESULTS s e v i t a g e N e s l a F Problems with native methods of the Socket Class Dynamic Dispatch still not working in some cases 31

  25. RESULTS s e v i t i s o P e s l a F Conflict vs Real Conflict (DF) Conflict vs Real Conflict (DF) Conflict vs Real Variant of stale Conflict (DF) value pattern Conflict vs Real Conflict (MHP) 32

  26. CONCLUSIONS ¡ 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 of lines) are very promisor § Plugin based architecture ¡ Ongoing work to include § Data-flow and control flow anaysis 38

  27. THE END Thank ¡you ¡ ¡ Ques-ons? ¡ 39

Recommend


More recommend