Dynamic Partial-Order Reduction for Model Checking Software Cormac - - PowerPoint PPT Presentation

dynamic partial order reduction for model checking
SMART_READER_LITE
LIVE PREVIEW

Dynamic Partial-Order Reduction for Model Checking Software Cormac - - PowerPoint PPT Presentation

Dynamic Partial-Order Reduction for Model Checking Software Cormac Flanagan Patrice Godefroid UC Santa Cruz Bell Labs Presented by: Ulrich Mller Model Checking Given a multithreaded program Wed like to check for deadlocks and


slide-1
SLIDE 1

Dynamic Partial-Order Reduction for Model Checking Software

Cormac Flanagan

UC Santa Cruz

Patrice Godefroid

Bell Labs Presented by:

Ulrich Müller

slide-2
SLIDE 2

Model Checking

  • Given a multithreaded program
  • We‘d like to check for deadlocks and safety property violations

– Proove it! – Ideally in a push-button fashion – Directly using source code (implementation vs abstraction)

  • Idea:

– Exhaustive state space exploration – Here:

  • Threads are subdivided into transitions
  • → All transition interleavings over all threads
slide-3
SLIDE 3

Naïve Algorithm

  • Let‘s do a depth-first search in the state space
  • Pros:

– Covers the whole state space, hence we have certainty of

  • ur software correctness
  • Cons:

– Requires a finite state-space – Requires an acyclic state-space – Can be immensely time-intensive due to the state-explosion problem

slide-4
SLIDE 4

(r0, s0, t0) (r1, s1, t1) (r0, s0, t1) (r0, s1, t1)

State-Explosion Problem

r1 r0 t1 t0 s1 s0

Given n=3 independent threads: This is how the global state space looks: Possible Interleavings:

(Distinct paths in state graph)

Number of states:

n n i

i n 2 = ⎟ ⎟ ⎠ ⎞ ⎜ ⎜ ⎝ ⎛

=

! n

slide-5
SLIDE 5

Partial-Order Reduction

  • The idea:

– Use independence between transitions to reduce the state space Two transitions are independent if both of the following hold:

  • They neither disable nor enable each other and
  • They commute

t2 t2 t1 t1

slide-6
SLIDE 6

Partial-Order Reduction

  • Since independent transitions

commute, we can swap two adjacent ones in a given trace

  • Leads to an equivalence class of

traces

  • We only need to check one of

those traces per equivalence class! Also called Model Checking using Representatives

slide-7
SLIDE 7

Partial-Order Reduction

  • Why the name?

– Natural representation of transitions in a concurrent system isn‘t a trace (linear order) ...

Watch out: These are transitions!

Linear order Partial order

... but a partial order By using linear orders, we‘re unnessecarily adding information to the relation!

slide-8
SLIDE 8

Partial-Order Reduction

  • In practice model checker only

has a local view of the state graph

  • In a given state, it has to

evaluate the minimal subset of enabled transitions to follow that still guarantees soundness

slide-9
SLIDE 9

Persistent Transitions

  • An enabled transition b in the state s

is a persistent transition, if it is independent with every transition ri reachable from s without executing b

  • If a transition b is persistent, it is

sound to only explore b

  • Persistent sets: generalization to many

threads

s

b r1 r2 ri independent Based on Flanagan‘s presentation of the paper

slide-10
SLIDE 10

Static POR

  • Use static source code analysis to determine the

persistent set of a state as soon as it is reached

  • Problem

– Static analysis is approximate and doesn‘t catch all independency – For example, whether two pointers refer to the same location is determined conservatively

  • This is where dynamic partial order reduction shines
slide-11
SLIDE 11

Dynamic POR

  • Using runtime information, resolving aliasing suddenly

becomes easy

  • Approach:

– Execute an arbitrary trace to completion – During this execution, take note of possible conflicts and mark them for later backtracking – Persistent set is built on-the-fly

slide-12
SLIDE 12

DPOR Algorithm

1,0,0 0,0,0 0,1,0 1,0,2 0,1,0 1,1,0 1,1,2 1,1,4 1,1,0 1,1,2

x=1 g+=2 y=1 g*=2

x,y,g

{S} {S}

r1 r2 s1 s2

R S

x=1 g+=2 y=1 g*=2 x=1 g+=2 y=1 g*=2 x=1 g+=2 y=1 g*=2

Summ Summary: ary:

  • Analyzed 3 of the 6 possible traces
  • Ideal POR would analyze 2
  • Persistent sets constructed dynamically!

{S,R}

slide-13
SLIDE 13

Summary

  • Pros

– No approximate/expensive/complicated static analysis – Supports pointer-rich data structures – Supports dynamic creation of threads/objects

  • Cons

– Finite state space – Acyclic state space

  • Can be extended to be stateful, but is memory expensive
  • Open questions

– Liveness properties and LTL?

slide-14
SLIDE 14

Questions?

slide-15
SLIDE 15

Implementations

Inspect: A Framework for Dynamic Verification of Multithreaded C Programs Sadly, very sparsely documented. http://www.cs.utah.edu/~yuyang/inspect/ Cute: A Concolic Unit Testing Engine for C and Java Uses a simplified version of DPOR to guide symbolic model checking. http://osl.cs.uiuc.edu/~ksen/cute/

slide-16
SLIDE 16

DPOR Algorithm

From a lecture of Theo Ruys on the subject

slide-17
SLIDE 17

Indexer Benchmark

From Flanagan‘s presentation of the paper

1 10 100 1000 10000 100000 1000000 10000000 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 Number of threads Number of transitions

Dynamic POR, stateless, sleep sets Dynamic POR, stateless, no sleep sets Static POR, stateless, sleep sets Static POR, stateless, no sleep sets Static POR, stateful, sleep sets Static POR, stateful, no sleep sets