tractable refinement checking for concurrent objects
play

Tractable Refinement Checking for Concurrent Objects Constantin - PowerPoint PPT Presentation

Tractable Refinement Checking for Concurrent Objects Constantin Enea LIAFA, CNRS & University Paris Diderot - Paris 7 joint work with Ahmed Bouajjani, Michael Emmi, Jad Hamza Concurrent objects Concurrent Object call (push, pop, )


  1. Tractable Refinement Checking for Concurrent Objects Constantin Enea LIAFA, CNRS & University Paris Diderot - Paris 7 joint work with Ahmed Bouajjani, Michael Emmi, Jad Hamza

  2. Concurrent objects Concurrent Object call (push, pop, …) return value … | | | | Thread 1 Thread 2 • Abstracting shared data: concurrent collections (queue, stack,…) 
 • Synchronization objects (mutex, semaphore,…)

  3. Atomic objects Ensure an atomic view of the method calls pop ⇒ 2 push(1) Thread 1 pop ⇒ 1 push(2) Thread 2 • Obvious solution: global locks • Performance requirements => optimistic concurrency (fine-grain locking, CAS, …) pop ⇒ 2 push(1) Thread 1 pop ⇒ 1 push(2) Thread 2

  4. Refinement Efficient implementation Reference implementation class TreiberStack { class AtomicStack { cell* top; cell* top; minimize Lock l; void push ( int v) { contention cell* t; void push ( int v) { cell* x = malloc( sizeof *x); l.lock(); x->data = v; top->next = malloc( sizeof *x); do { top = top->next; t = top; top->data = v; x->next = top; l.unlock(); } while (! CAS(&top,t,x) ); } } int pop () { int pop () { checking ... ... interference } } } } For every Client, Client x Impl included in Client x Spec

  5. Violating Refinement ) 1 ( ) h ( s p 3 u o p p n n r r l l u u l l t t Thread1 a a e e preemption c c r r Thread2 pop => 1 push(2) push(3) pop => EMPTY preemption PROBLEM 1, 2 , 3 pushed: 1, 3, EMPTY popped: not admitted by atomic stack

  6. Insidious Errors HARD TO REPRODUCE 
 • memory management 
 • specific thread interleaving HARD TO DIAGNOSE 
 program assertions don’t suffice DEMANDS AUTOMATION

  7. Automating Refinement Checking For every Client, Client x Impl included in Client x Spec CHALLENGES 
 • enumeration of programs 
 • enumeration of executions 
 • checking inclusion

  8. Linearizability [Herlihy & Wing 1990] pop ⇒ 0 push(0) push(1) push(1) push(0) pop ⇒ 0 Execution admitted by the specification • Find “linearization points” within execution time intervals • The order defined by the linearization points is admitted by the specification • Impl is linearizable w.r.t. Spec iff Impl refines Spec (when Spec is atomic) [Filipovic et al. 2009, Bouajjani et al. 2015]

  9. Enumeration Exponentially-many linearizations ∉ pop ⇒ 3 push(1) pop ⇒ EMPTY push(1) pop ⇒ 3 pop ⇒ 1 push(2) push(3) pop ⇒ EMPTY ∉ pop ⇒ 1 push(2) push(3) push(1) pop ⇒ 1 pop ⇒ 3 push(2) push(3) pop ⇒ EMPTY AtomicStack ? ∉ push(1) pop ⇒ 1 push(2) pop ⇒ 3 push(3) pop ⇒ EMPTY ∉ push(1) pop ⇒ 1 push(2) push(3) pop ⇒ 3 pop ⇒ EMPTY

  10. Complexity Reachability Linearizability Single trace NL-complete NP-complete a n threads PSPACE-complete EXPSPACE-complete b ∞ threads EXPSPACE-complete Undecidable c • Demands approximation analyses • In this talk: focus on bug-finding a Testing Shared Memory. Gibbons et al. 1996 b Linearizability is EXPSPACE-complete Hamza 2015 c Verifying Concurrent Programs Against Sequential Specifications Bouajjani et al. 2013

  11. Parametrized under- approximations [Bouajjani, Emmi, E, Hamza, POPL’15] Characterization of refinement using histories (partial orders) • reduce refinement to a history-set inclusion • Parametrized under-approximation to solve the inclusion • histories are interval orders • parametrized by length • efficient representation using counters • efficient reduction to reachability (dynamic/static analysis) • Experiments • Scalability: Efficient in practice • Coverage: Small length needed to catch violations •

  12. Parametrized under- approximations [Bouajjani, Emmi, E, Hamza, POPL’15] Characterization of refinement using histories (partial orders) • reduce refinement to a history-set inclusion • Parametrized under-approximation to solve the inclusion • histories are interval orders • parametrized by length • efficient representation using counters • efficient reduction to reachability (dynamic/static analysis) • Experiments • Scalability: Efficient in practice • Coverage: Small length needed to catch violations •

  13. Histories push(1) pop ⇒ 3 pop ⇒ 1 push(2) push(3) pop ⇒ EMPTY happens-before pop ⇒ 3 partial order push(1) pop ⇒ EMPTY pop ⇒ 1 push(2) push(3)

  14. History Inclusion Hist(L) = the histories of all executions of L (arbitrary calls with arbitrary many threads) THEOREM 
 L refines S ⇔ Hist( L ) ⊆ Hist( S ) • (=>) Given h in Hist( L ), construct a client P h that imposes all the happen-before constraints of h . • (<=) Clients cannot distinguish executions with the same history.

  15. Parametrized under- approximations [Bouajjani, Emmi, E, Hamza, POPL’15] Characterization of refinement using histories (partial orders) • reduce refinement to a history-set inclusion • Parametrized under-approximation to solve the inclusion • histories are interval orders • parametrized by length • efficient representation using counters • efficient reduction to reachability (dynamic/static analysis) • Experiments • Scalability: Efficient in practice • Coverage: Small length needed to catch violations •

  16. Approximating GOAL 
 parameterized approximation A k 
 • complete as k → ∞ 
 • tractable for fixed k 
 • violations with small k HYPOTHESIS 
 violations surface in histories 
 with low-complexity orderings

  17. Ordering complexity execution histories are interval orders pop ⇒ 3 pop ⇒ 3 push(1) pop ⇒ EMPTY push(1) push(2) pop ⇒ EMPTY pop ⇒ 1 push(3) 4 0 1 2 3 pop ⇒ 1 push(2) push(3) INTERVAL LENGTH 
 smallest maximum integral interval bound

  18. History Abstraction all concurrent pop ⇒ EMPTY pop ⇒ 3 push(1) pop ⇒ EMPTY pop ⇒ 3 push(1) weaker order pop ⇒ 1 push(2) push(3) pop ⇒ 1 push(2) push(3) LENGTH 4 LENGTH 1 STILL A VIOLATION LEMMA 
 Libraries closed under weakening

  19. Interval-Length Bounding A k (h) = history of length k (keeping last k intervals precise • and merge the remaining ones) pop ⇒ 3 pop ⇒ 3 push(1) push(2) pop ⇒ EMPTY push(1) push(2) pop ⇒ EMPTY pop ⇒ 1 push(3) pop ⇒ 1 push(3) 4 1 0 1 2 3 0 Checking A k (Hist (L)) ⊆ Hist k (S) instead of Hist(L) ⊆ Hist (S) • construct a formula Ψ S representing Hist k (S) • check A k (h) |= Ψ S for every h ∈ Hist(L) • Counter-based representations of histories

  20. Using counter-based representations #(push(1), 0,0) = 1 pop ⇒ 3 #(pop ⇒ 1,0,0) = 1 push(1) push(2) pop ⇒ EMPTY pop ⇒ 1 push(3) #(push(2),0,0) = 1 … 1 0 Checking A k (Hist (L)) ⊆ Hist k (S) Generating A k (Hist (L)) = instrumenting the most general • client of L with counter increments/decrements adding the assertion Ψ S representing Hist k (S) • obtained manually for common objects (stack, queue, …) • automatically for context-free specifications •

  21. Parametrized under- approximations [Bouajjani, Emmi, E, Hamza, POPL’15] Characterization of refinement using histories (partial orders) • reduce refinement to a history-set inclusion • Parametrized under-approximation to solve the inclusion • histories are interval orders • parametrized by length • efficient representation using counters • efficient reduction to reachability (dynamic/static analysis) • Experiments • Scalability: Efficient in practice • Coverage: Small length needed to catch violations •

  22. Empirically (dynamic analysis) execution sample vs. violations covered execution size vs. monitoring overhead 1000 100000 ~1000x Histoires Linearization missed violations 
 Violations Operation Counting Approximation k=2 Covered w/ k=4 Covered w/ k=3 due to small sample 10000 Covered w/ k=2 Covered w/ k=1 100 1000 100 ~2x 10 10 1 1 1x10 3 executions — 2.4x10 6 executions 2 operations — 20 operations small bounds suffice exponentially-lower as sample-size increases monitoring overhead

  23. Empirically (static analysis) Static analysis for finding refinement violations • Reduction to existing tools • CSeq, with CBMC backend (bounded model checking) • Library P k Time Unrolling Rounds Michael-Scott Queue (Head) 2 , 2 2 2 24.76s 1 Michael-Scott Queue (Tail) 3 , 1 2 3 45.44s 1 Treiber Stack (ABA) 3 , 4 1 2 52.59s 1 Treiber Stack ( push ) 2 , 2 1 2 24.46s 1 Treiber Stack ( pop ) 2 , 2 1 2 15.16s 1 Elimination Stack 4 , 1 1 4 317.79s 0 Elimination Stack 3 , 1 1 1 4 222.04s Elimination Stack 3 , 4 1 2 434.84s 0 Lock-coupling Set 1 , 2 0 2 2 11.27s LFDS Queue 2 , 2 1 2 77.00s 1

  24. Conclusion equivalence between refinement and history inclusion • parametrized under-approximation schema to solve Hist(L) ⊆ • Hist(S) abstracting histories with low-complexity partial orders • (bounded interval length) Future work: Complete verification: Leverage insights on violations? • Compiler optimizations: Refinement checking without fixed • reference impls? Weaker abstractions : e.g., causal consistency in place of • atomicity?

  25. THE END

Recommend


More recommend