1 / 84

Peng Liu and Charles Zhang

Axis: Automatically Fixing Atomicity Violations through Solving Control Constraints. Peng Liu and Charles Zhang. Motivation. An Atomicity Violation (AV) in StringBuffer . The accesses, assumed to be atomic, are interleaved non- serializably by a remote access. Thread 1.

zareh
Download Presentation

Peng Liu and Charles Zhang

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Axis: Automatically Fixing Atomicity Violations through Solving Control Constraints Peng Liu and Charles Zhang

  2. Motivation An Atomicity Violation (AV) in StringBuffer. The accesses, assumed to be atomic, are interleaved non-serializably by a remote access. Thread 1 run(){ // s1.append(s2): synchronized(s1){ intlen = s2.length(); s2.getChars(0, len, s1…); } }

  3. Motivation An Atomicity Violation (AV) in StringBuffer. The accesses, assumed to be atomic, are interleaved non-serializably by a remote access. Thread 1 run(){ // s1.append(s2): synchronized(s1){ intlen = s2.length(); s2.getChars(0, len, s1…); } }

  4. Motivation An Atomicity Violation (AV) in StringBuffer. The accesses, assumed to be atomic, are interleaved non-serializably by a remote access. Thread 1 run(){ // s1.append(s2): synchronized(s1){ intlen = s2.length(); s2.getChars(0, len, s1…); } }

  5. Motivation An Atomicity Violation (AV) in StringBuffer. The accesses, assumed to be atomic, are interleaved non-serializably by a remote access. Thread 1 run(){ // s1.append(s2): synchronized(s1){ intlen = s2.length(); s2.getChars(0, len, s1…); } }

  6. Motivation An Atomicity Violation (AV) in StringBuffer. The accesses, assumed to be atomic, are interleaved non-serializably by a remote access. Thread 1 Thread 2 run(){ // s1.append(s2): synchronized(s1){ intlen = s2.length(); s2.getChars(0, len, s1…); } } run(){ s2.delete(0, s2.length()); }

  7. Motivation An Atomicity Violation (AV) in JDKStringBuffer. The accesses, assumed to be atomic, are interleaved non-serializably by a remote access. Thread 1 Thread 2 run(){ // s1.append(s2): synchronized(s1){ aintlen = s2.length(); b s2.getChars(0, len, s1…); } } run(){ r s2.delete(0, s2.length()); }

  8. Motivation Common approach of Fixing the Atomicity Violation Synchronize the atomicity sequence (from a to b) and the remote access (r) with locks. Thread 1 Thread 2 run(){ // s1.append(s2): synchronized(s1){ + lockM.lock(); aintlen = s2.length(); b s2.getChars(0, len, s1…); + lockM.unlock(); } } run(){ + lockM.lock(); r s2.delete(0, s2.length()); + lockM.unlock(); }

  9. Motivation Problems with Fixing the Violations Sacrifice the concurrency! Introduce New deadlocks!

  10. Motivation Problems with Fixing the Violations Sacrifice the concurrency! Introduce New deadlocks!

  11. Motivation Introduce New Deadlocks AV (a,b,r) and the original lock oL protecting some irrelevant vars. Thread 1 Thread 2 oL.lock(); a oL.lock(); … oL.unlock(); b ... r ... oL.unlock();

  12. Motivation Introduce New Deadlocks AV (a,b,r) and the original lock oL protecting some irrelevant vars. Thread 1 Thread 2 oL.lock(); a oL.lock(); … oL.unlock(); b ... r ... oL.unlock();

  13. Motivation Introduce New Deadlocks AV (a,b,r) and the original lock oL protecting some irrelevant vars. Thread 1 Thread 2 oL.lock(); a oL.lock(); … oL.unlock(); b ... r ... oL.unlock();

  14. Motivation Introduce New Deadlocks AV (a,b,r) and the original lock oL protecting some irrelevant vars. Thread 1 Thread 2 oL.lock(); + L.lock(); a oL.lock(); … oL.unlock(); b ... r ... + L.lock(); + L.unlock(); + L.unlock(); oL.unlock();

  15. Motivation Introduce New Deadlocks AV (a,b,r) and the original lock oL protecting some irrelevant vars. Thread 1 Thread 2 oL.lock(); + L.lock(); a oL.lock(); … oL.unlock(); b ... r ... + L.lock(); + L.unlock(); + L.unlock(); oL.unlock();

  16. Motivation Problems with Fixing the Violations Sacrifice the concurrency! Introduce New deadlocks!

  17. Motivation Sacrifice the Concurrency Greatly Two overlapping Avs: (a,b,r) and (a’b,r’). Thread 1 Thread 2 Thread 3 a’ … r … b’ r’ a b

  18. Motivation Sacrifice the Concurrency Greatly Two overlapping Avs: (a,b,r) and (a’b,r’). Thread 1 Thread 2 Thread 3 a’ … r … b’ r’ a b

  19. Motivation Sacrifice the Concurrency Greatly Two overlapping Avs: (a,b,r) and (a’b,r’). Thread 1 Thread 2 Thread 3 a’ … r … b’ r’ a b

  20. Motivation Sacrifice the Concurrency Greatly Two overlapping Avs: (a,b,r) and (a’b,r’). Thread 1 Thread 2 Thread 3 a’ … r … b’ r’ a b

  21. Motivation Sacrifice the Concurrency Greatly Two overlapping Avs: (a,b,r) and (a’b,r’). Thread 1 Thread 2 Thread 3 a’ … r … b’ r’ a b

  22. Motivation Sacrifice the Concurrency Greatly Two overlapping Avs: (a,b,r) and (a’b,r’). Thread 1 Thread 2 Thread 3 a’ … r … b’ r’ a b

  23. Motivation Sacrifice the Concurrency Greatly Two overlapping Avs: (a,b,r) and (a’b,r’). Thread 1 Thread 2 Thread 3 +L.lock(); a’ … r … b’ +L.unlock(); +L.lock(); r’ +L.unlock(); +L.lock(); a b +L.unlock();

  24. Motivation Our Guarantee Sacrifice the concurrency minimally! Introduce New deadlocks? No!

  25. Motivation Our Guarantee Sacrifice the concurrency minimally! Introduce New deadlocks? No!

  26. Motivation Our Approach Buggy Code CodeTo Petri Net Constraint Constructor Constraint Solver Repaired Code Petri Net To Code

  27. Motivation Our Approach Buggy Code CodeTo Petri Net Constraint Constructor Constraint Solver Repaired Code Petri Net To Code Bug report: <6@func1, 8@func1, 14@func2> <2@func3, 14@func3, 20@func4> ……

  28. Motivation Our Approach Buggy Code CodeTo Petri Net Constraint Constructor Constraint Solver Repaired Code Petri Net To Code

  29. Motivation Our Approach • Constraints: no two pandas on the single-plank bridge simultaneously. • Solver: control theory. Constraint Constructor Constraint Solver

  30. Motivation Rationale • Performance • Loose constraints • Concurrency-preserving solver. • Safety • Handle deadlocks with solver Constraint Constructor Constraint Solver

  31. CodeTo Petri Net thread1.start(); thread2.start(); Thread 1 Thread 2 run(){ s2.delete(0, s2.length()); } run(){ synchronized(s1){ intlen = s2.length(); s2.getChars(0, len, s1…); } } thread1.join(); thread2.join();

  32. CodeTo Petri Net • Abstract graphical and mathematical model. • Places (circles) • Transitions (horizontal bars) • Arcs between them

  33. CodeTo Petri Net • Abstract graphical and mathematical model. • Places (circles) • Transitions (horizontal bars) • Arcs between them

  34. CodeTo Petri Net • Abstract graphical and mathematical model. • Places (circles) • Transitions (horizontal bars) • Arcs between them

  35. CodeTo Petri Net • Abstract graphical and mathematical model. • Places (circles) • Transitions (horizontal bars) • Arcs between them

  36. CodeTo Petri Net • Abstract graphical and mathematical model. • Places contain tokens • Transitions, when triggered, move tokens • Arcs (the weights) determine how many to move. 1 by default.

  37. CodeTo Petri Net • Abstract graphical and mathematical model. • Places contain tokens • Transitions, when triggered, move tokens • Arcs (the weights) determine how many to move. 1 by default.

  38. CodeTo Petri Net • Abstract graphical and mathematical model. • Places contain tokens • Transitions, when triggered, move tokens • Arcs (the weights) instruct how many to remove or give. 1 by default.

  39. CodeTo Petri Net • Abstract graphical and mathematical model. • A transition can be triggered only if the input place contains enough tokens.

  40. CodeTo Petri Net Statements -> places. Control flows-> transitions Branch If(…) Branch 1 Branch 2

  41. CodeTo Petri Net Statements -> places. Control flows-> transitions Branch If(…) Branch 1 Branch 2

  42. CodeTo Petri Net Statements -> places. Control flows-> transitions Branch If(…) Branch 1 Branch 2

  43. CodeTo Petri Net Statements -> places. Control flows-> transitions Branch If(…) Branch 1 Branch 2

  44. CodeTo Petri Net Statements -> places. Control flows-> transitions Branch If(…) Branch 1 Branch 2

  45. CodeTo Petri Net Statements -> places. Control flows-> transitions Loop while(…) S1 S2

  46. CodeTo Petri Net Statements -> places. Control flows-> transitions Loop while(…) S1 S2

  47. CodeTo Petri Net Statements -> places. Control flows-> transitions Loop while(…) S1 S2

  48. CodeTo Petri Net Statements -> places. Start/Join/Control flows-> transitions Threading thread1.start(); thread2.start(); Thread 1: Thread 2: S1; S2; S3; S4; thread1.join(); thread2.join();

  49. CodeTo Petri Net Statements -> places. Start/Join/Control flows-> transitions Threading thread1.start(); thread2.start(); Thread 1: Thread 2: S1; S2; S3; S4; thread1.join(); thread2.join();

  50. CodeTo Petri Net Statements -> places. Start/Join/Control flows-> transitions Threading thread1.start(); thread2.start(); Thread 1: Thread 2: S1; S2; S3; S4; thread1.join(); thread2.join();

More Related