Verification of Parameterized Concurrent Programs By Modular - - PowerPoint PPT Presentation

verification of parameterized concurrent programs by
SMART_READER_LITE
LIVE PREVIEW

Verification of Parameterized Concurrent Programs By Modular - - PowerPoint PPT Presentation

Verification of Parameterized Concurrent Programs By Modular Reasoning about Data and Control Zachary Kincaid Azadeh Farzan University of Toronto January 18, 2013 Z. Kincaid (U. Toronto) Modular Reasoning about Data and Control January 18,


slide-1
SLIDE 1

Verification of Parameterized Concurrent Programs By Modular Reasoning about Data and Control

Zachary Kincaid Azadeh Farzan

University of Toronto

January 18, 2013

  • Z. Kincaid (U. Toronto)

Modular Reasoning about Data and Control January 18, 2013 1 / 22

slide-2
SLIDE 2

Parameterized concurrent programs

Goal Compute numerical invariants (e.g. intervals, octagons, polyhedra) for parameterized concurrent programs. Solution: annotation ι such that if some thread T’s program counter is at v, then ι(v) holds over the globals & locals of T.

  • Z. Kincaid (U. Toronto)

Modular Reasoning about Data and Control January 18, 2013 2 / 22

slide-3
SLIDE 3

Parameterized concurrent programs

Goal Compute numerical invariants (e.g. intervals, octagons, polyhedra) for parameterized concurrent programs. Solution: annotation ι such that if some thread T’s program counter is at v, then ι(v) holds over the globals & locals of T. Our program model has:

  • Unbounded concurrency: program is the parallel composition of n

copies of some thread T, where n is a parameter

  • Invariants must be sound for all n
  • Z. Kincaid (U. Toronto)

Modular Reasoning about Data and Control January 18, 2013 2 / 22

slide-4
SLIDE 4

Parameterized concurrent programs

Goal Compute numerical invariants (e.g. intervals, octagons, polyhedra) for parameterized concurrent programs. Solution: annotation ι such that if some thread T’s program counter is at v, then ι(v) holds over the globals & locals of T. Our program model has:

  • Unbounded concurrency: program is the parallel composition of n

copies of some thread T, where n is a parameter

  • Invariants must be sound for all n
  • Unbounded data domains
  • Z. Kincaid (U. Toronto)

Modular Reasoning about Data and Control January 18, 2013 2 / 22

slide-5
SLIDE 5

Parameterized concurrent programs

Goal Compute numerical invariants (e.g. intervals, octagons, polyhedra) for parameterized concurrent programs. Solution: annotation ι such that if some thread T’s program counter is at v, then ι(v) holds over the globals & locals of T. Our program model has:

  • Unbounded concurrency: program is the parallel composition of n

copies of some thread T, where n is a parameter

  • Invariants must be sound for all n
  • Unbounded data domains

Natural model for device drivers, file systems, client/server-type programs, ...

  • Z. Kincaid (U. Toronto)

Modular Reasoning about Data and Control January 18, 2013 2 / 22

slide-6
SLIDE 6

Contributions

1 We develop an attack on the parameterized verification problem based

  • n separating it into a data module and a control module
  • Data module computes numerical invariants
  • Control module computes a program model

Data module Control module

  • Z. Kincaid (U. Toronto)

Modular Reasoning about Data and Control January 18, 2013 3 / 22

slide-7
SLIDE 7

Contributions

1 We develop an attack on the parameterized verification problem based

  • n separating it into a data module and a control module
  • Data module computes numerical invariants
  • Control module computes a program model

Data module Control module

2 We propose data flow graphs as a program representation for

(parameterized) concurrent programs

  • Z. Kincaid (U. Toronto)

Modular Reasoning about Data and Control January 18, 2013 3 / 22

slide-8
SLIDE 8

Contributions

1 We develop an attack on the parameterized verification problem based

  • n separating it into a data module and a control module
  • Data module computes numerical invariants
  • Control module computes a program model

Data module Control module

2 We propose data flow graphs as a program representation for

(parameterized) concurrent programs

3 We give a semicompositional algorithm for constructing data flow graphs

  • Z. Kincaid (U. Toronto)

Modular Reasoning about Data and Control January 18, 2013 3 / 22

slide-9
SLIDE 9

Contributions

1 We develop an attack on the parameterized verification problem based

  • n separating it into a data module and a control module
  • Data module computes numerical invariants
  • Control module computes a program model

Data module Control module

2 We propose data flow graphs as a program representation for

(parameterized) concurrent programs

3 We give a semicompositional algorithm for constructing data flow graphs

  • Z. Kincaid (U. Toronto)

Modular Reasoning about Data and Control January 18, 2013 3 / 22

slide-10
SLIDE 10

Sequential program analysis

  • Flow analysis: solve a system of equations valued over some abstract

domain

  • For sequential programs, equations come from the control flow graph:

t u v w IN(t) = ⊤ OUT(t) = t(IN(t)) IN(v) = OUT(t) OUT(v) = v(IN(v)) IN(w) = OUT(u) ∨ OUT(v) OUT(w) = w(IN(w)) IN(u) = OUT(t) ∨ OUT(w) OUT(u) = u(IN(u))

  • Z. Kincaid (U. Toronto)

Modular Reasoning about Data and Control January 18, 2013 4 / 22

slide-11
SLIDE 11

Sequential program analysis

  • Flow analysis: solve a system of equations valued over some abstract

domain

  • For sequential programs, equations come from the control flow graph:

t u v w IN(t) = ⊤ OUT(t) = t(IN(t)) IN(v) = OUT(t) OUT(v) = v(IN(v)) IN(w) = OUT(u) ∨ OUT(v) OUT(w) = w(IN(w)) IN(u) = OUT(t) ∨ OUT(w) OUT(u) = u(IN(u))

  • How about parameterized programs?
  • Z. Kincaid (U. Toronto)

Modular Reasoning about Data and Control January 18, 2013 4 / 22

slide-12
SLIDE 12

Data flow

Represent data flow, not control flow:

ABC x := x + 1 y := 1 x := x + y x := -x

  • Z. Kincaid (U. Toronto)

Modular Reasoning about Data and Control January 18, 2013 5 / 22

slide-13
SLIDE 13

Data flow

Represent data flow, not control flow:

ABC x := x + 1 y := 1 x := x + y x := -x x y x

  • Z. Kincaid (U. Toronto)

Modular Reasoning about Data and Control January 18, 2013 5 / 22

slide-14
SLIDE 14

Data flow

Represent data flow, not control flow:

ABC x := x + 1 y := 1 x := x + y x := -x x y x y x uninit x y y

  • Z. Kincaid (U. Toronto)

Modular Reasoning about Data and Control January 18, 2013 5 / 22

slide-15
SLIDE 15

Why data flow?

Invariant: x = 0

y := 0 acquire(lock) assert(x = 0) release(lock) acquire(lock) x := 1 x := 0 release(lock) Break invariant Restore invariant x?

  • Z. Kincaid (U. Toronto)

Modular Reasoning about Data and Control January 18, 2013 6 / 22

slide-16
SLIDE 16

Data flow graphs

A DFG for a program P is a directed graph P ♯ = Loc, →, where

  • →⊆ Loc × V ars × Loc is a set of directed edges labeled by program

variables x := x + 1 x := x + y x

  • Loc contains a distinguished uninit vertex
  • Note: # of vertices does not depend on # of threads
  • Z. Kincaid (U. Toronto)

Modular Reasoning about Data and Control January 18, 2013 7 / 22

slide-17
SLIDE 17

Representing traces

  • A program is represented by a DFG P ♯ if all its feasible traces are

represented by P ♯.

  • Z. Kincaid (U. Toronto)

Modular Reasoning about Data and Control January 18, 2013 8 / 22

slide-18
SLIDE 18

Representing traces

  • A program is represented by a DFG P ♯ if all its feasible traces are

represented by P ♯.

  • A trace is represented by a DFG P ♯ if all data flow edges it witnesses

belong to P ♯

  • Z. Kincaid (U. Toronto)

Modular Reasoning about Data and Control January 18, 2013 8 / 22

slide-19
SLIDE 19

Representing traces

  • A program is represented by a DFG P ♯ if all its feasible traces are

represented by P ♯.

  • A trace is represented by a DFG P ♯ if all data flow edges it witnesses

belong to P ♯

  • A trace witnesses a data flow u →x v iff it is of the form:

Tn, u

Thread m at v Thread n executes u, u modifies x No modifications to x

(x local ⇒ requires n = m)

  • Z. Kincaid (U. Toronto)

Modular Reasoning about Data and Control January 18, 2013 8 / 22

slide-20
SLIDE 20

Representing traces

  • A program is represented by a DFG P ♯ if all its feasible traces are

represented by P ♯.

  • A trace is represented by a DFG P ♯ if all data flow edges it witnesses

belong to P ♯

  • A trace witnesses a data flow u →x v iff it is of the form:

Tn, u

Thread m at v Thread n executes u, u modifies x No modifications to x

(x local ⇒ requires n = m)

ABC x := x + 1 y := 1 x := x + y x := -x x y x y x uninit x y y

  • Z. Kincaid (U. Toronto)

Modular Reasoning about Data and Control January 18, 2013 8 / 22

slide-21
SLIDE 21

Computing invariants with DFGs

  • DFGs induce a set of equations:

IN(v)x =

  • u→xv

∃(V ars \ {x}).OUT (u) IN(v) =

  • x∈V ar

IN(v)x OUT (v) = v(IN(v))

  • Define an inductive annotation to be a solution to these equations.
  • Z. Kincaid (U. Toronto)

Modular Reasoning about Data and Control January 18, 2013 9 / 22

slide-22
SLIDE 22

Computing invariants with DFGs

  • DFGs induce a set of equations:

IN(v)x =

  • u→xv

∃(V ars \ {x}).OUT (u) IN(v) =

  • x∈V ar

IN(v)x OUT (v) = v(IN(v))

  • Define an inductive annotation to be a solution to these equations.

Theorem (DFG soundness) If σ is a trace represented by a DFG P ♯, and ι is an inductive annotation for P ♯, then ι safely approximates the states reached by σ.

  • Z. Kincaid (U. Toronto)

Modular Reasoning about Data and Control January 18, 2013 9 / 22

slide-23
SLIDE 23

Overview

Data module Control module

  • Z. Kincaid (U. Toronto)

Modular Reasoning about Data and Control January 18, 2013 10 / 22

slide-24
SLIDE 24

Overview

Data module Control module

  • Z. Kincaid (U. Toronto)

Modular Reasoning about Data and Control January 18, 2013 10 / 22

slide-25
SLIDE 25

Constructing data flow graphs

Goal Compute the set of all u, x, v such that there is some feasible trace that witnesses u →x v

  • Strategy:
  • Overapproximate the set of feasible traces
  • Compute dataflow edges witnessed by one of these traces
  • Z. Kincaid (U. Toronto)

Modular Reasoning about Data and Control January 18, 2013 11 / 22

slide-26
SLIDE 26

Precise DFG construction needs data

(flag is initially 0) assume(flag) assert(x != null) x := null x := alloc(...) flag := 1 x?

  • Z. Kincaid (U. Toronto)

Modular Reasoning about Data and Control January 18, 2013 12 / 22

slide-27
SLIDE 27

Precise DFG construction needs data

(flag is initially 0) assume(flag) assert(x != null) x := null x := alloc(...) flag := 1 x? T1,x := null T2,assume(flag) T2,assert(x != null) x

  • Z. Kincaid (U. Toronto)

Modular Reasoning about Data and Control January 18, 2013 12 / 22

slide-28
SLIDE 28

Precise DFG construction needs data

(flag is initially 0) assume(flag) assert(x != null) x := null x := alloc(...) flag := 1 x? T1,x := null T2,assume(flag) T2,assert(x != null) x flag = 0 Cannot execute!

  • Z. Kincaid (U. Toronto)

Modular Reasoning about Data and Control January 18, 2013 12 / 22

slide-29
SLIDE 29

ι-feasible traces

Use an annotation ι to rule out infeasible traces: a trace σ is ι-infeasible if there is some subtrace σ′Tn, v, some thread m, and some location u such that

  • Thread m is at location u after executing σ′
  • Thread n may not execute v in any state satisfying ι(u).
  • Z. Kincaid (U. Toronto)

Modular Reasoning about Data and Control January 18, 2013 13 / 22

slide-30
SLIDE 30

ι-feasible traces: example

(flag is initially 0) assume(flag) assert(x != null) x := null x := alloc(...) flag := 1 x?

  • Z. Kincaid (U. Toronto)

Modular Reasoning about Data and Control January 18, 2013 14 / 22

slide-31
SLIDE 31

ι-feasible traces: example

(flag is initially 0) assume(flag) assert(x != null) x := null x := alloc(...) flag := 1 x? T1,x := null T2,assume(flag) T2,assert(x != null) x

  • Z. Kincaid (U. Toronto)

Modular Reasoning about Data and Control January 18, 2013 14 / 22

slide-32
SLIDE 32

ι-feasible traces: example

(flag is initially 0) assume(flag) assert(x != null) x := null x := alloc(...) flag := 1 x? T1,x := null T2,assume(flag) T2,assert(x != null) x guard: flag = 0 T1 at x := alloc(...) T2 at assume(flag) is ι(x := alloc(...)) ∧ flag = 0 satisfiable?

  • Z. Kincaid (U. Toronto)

Modular Reasoning about Data and Control January 18, 2013 14 / 22

slide-33
SLIDE 33

ι-feasible traces: example

(flag is initially 0) assume(flag) assert(x != null) x := null x := alloc(...) flag := 1 x? T1,x := null T2,assume(flag) T2,assert(x != null) x guard: flag = 0 T1 at x := alloc(...) T2 at assume(flag) is ι(x := alloc(...)) ∧ flag = 0 satisfiable?

  • ι(x := alloc(...)) : flag = 0 ⇒ infeasible
  • Z. Kincaid (U. Toronto)

Modular Reasoning about Data and Control January 18, 2013 14 / 22

slide-34
SLIDE 34

ι-feasible traces: example

(flag is initially 0) assume(flag) assert(x != null) x := null x := alloc(...) flag := 1 x? T1,x := null T2,assume(flag) T2,assert(x != null) x guard: flag = 0 T1 at x := alloc(...) T2 at assume(flag) is ι(x := alloc(...)) ∧ flag = 0 satisfiable?

  • ι(x := alloc(...)) : flag = 0 ⇒ infeasible
  • ι(x := alloc(...)) : true ⇒ feasible
  • Z. Kincaid (U. Toronto)

Modular Reasoning about Data and Control January 18, 2013 14 / 22

slide-35
SLIDE 35

Constructing data flow graphs

Goal Compute the set of all u, x, v such that there is some feasible trace that witnesses u →x v

  • Strategy:
  • Overapproximate the set of feasible traces
  • Compute dataflow edges witnessed by one of these traces
  • Z. Kincaid (U. Toronto)

Modular Reasoning about Data and Control January 18, 2013 15 / 22

slide-36
SLIDE 36

Constructing data flow graphs

Goal Compute the set of all u, x, v such that there is some feasible trace that witnesses u →x v

  • Strategy:

Overapproximate the set of feasible traces by ι-feasible traces

  • Compute dataflow edges witnessed by one of these traces
  • Z. Kincaid (U. Toronto)

Modular Reasoning about Data and Control January 18, 2013 15 / 22

slide-37
SLIDE 37

Constructing data flow graphs

Goal Compute the set of all u, x, v such that there is some feasible trace that witnesses u →x v

  • Strategy:

Overapproximate the set of feasible traces by ι-feasible traces

  • Compute dataflow edges witnessed by one of these traces
  • Parameterization is still an obstacle
  • Z. Kincaid (U. Toronto)

Modular Reasoning about Data and Control January 18, 2013 15 / 22

slide-38
SLIDE 38

Constructing data flow graphs

Goal Compute the set of all u, x, v such that there is some feasible trace that witnesses u →x v

  • Strategy:

Overapproximate the set of feasible traces by ι-feasible traces

  • Compute dataflow edges witnessed by one of these traces
  • Parameterization is still an obstacle
  • Data flow edges for 2-thread ι-feasible witnesses can be computed efficiently
  • Z. Kincaid (U. Toronto)

Modular Reasoning about Data and Control January 18, 2013 15 / 22

slide-39
SLIDE 39

Projection

Lemma (projection) Let ι be an annotation, let σ be an ι-feasible trace, and let N be a set of

  • threads. Then σ|N, the projection of σ onto N, is also ι-feasible.

Tn, u Thread m at v Thread n executes u, u modifies x No modifications to x

  • Z. Kincaid (U. Toronto)

Modular Reasoning about Data and Control January 18, 2013 16 / 22

slide-40
SLIDE 40

Projection

Lemma (projection) Let ι be an annotation, let σ be an ι-feasible trace, and let N be a set of

  • threads. Then σ|N, the projection of σ onto N, is also ι-feasible.

Tn, u Thread m at v Thread n executes u, u modifies x No modifications to x

  • Z. Kincaid (U. Toronto)

Modular Reasoning about Data and Control January 18, 2013 16 / 22

slide-41
SLIDE 41

Projection

Lemma (projection) Let ι be an annotation, let σ be an ι-feasible trace, and let N be a set of

  • threads. Then σ|N, the projection of σ onto N, is also ι-feasible.

Tn, u Thread m at v Thread n executes u, u modifies x No modifications to x

  • A data flow edge u →x v has an ι-feasible witness iff it has a 2-thread

ι-feasible witness

  • Z. Kincaid (U. Toronto)

Modular Reasoning about Data and Control January 18, 2013 16 / 22

slide-42
SLIDE 42

Feedback loop

  • Given a DFG, we know how to compute numerical invariants
  • Given numerical invariants, we know how to compute a DFG

Data analysis DFG construction Sequential reaching definitions Sequential DFG

  • Z. Kincaid (U. Toronto)

Modular Reasoning about Data and Control January 18, 2013 17 / 22

slide-43
SLIDE 43

Feedback loop

  • Given a DFG, we know how to compute numerical invariants
  • Given numerical invariants, we know how to compute a DFG

Data analysis DFG construction Annotation Sequential reaching definitions Sequential DFG

  • Z. Kincaid (U. Toronto)

Modular Reasoning about Data and Control January 18, 2013 17 / 22

slide-44
SLIDE 44

Feedback loop

  • Given a DFG, we know how to compute numerical invariants
  • Given numerical invariants, we know how to compute a DFG

Data analysis DFG construction Annotation Data flow edges Sequential reaching definitions Sequential DFG

  • Z. Kincaid (U. Toronto)

Modular Reasoning about Data and Control January 18, 2013 17 / 22

slide-45
SLIDE 45

Feedback loop

  • Given a DFG, we know how to compute numerical invariants
  • Given numerical invariants, we know how to compute a DFG

Data analysis DFG construction Data flow edges Annotation Sequential reaching definitions Sequential DFG

  • Z. Kincaid (U. Toronto)

Modular Reasoning about Data and Control January 18, 2013 17 / 22

slide-46
SLIDE 46

Feedback loop

  • Given a DFG, we know how to compute numerical invariants
  • Given numerical invariants, we know how to compute a DFG

Data analysis DFG construction Annotation Data flow edges Sequential reaching definitions Sequential DFG

  • Z. Kincaid (U. Toronto)

Modular Reasoning about Data and Control January 18, 2013 17 / 22

slide-47
SLIDE 47

Feedback loop

  • Given a DFG, we know how to compute numerical invariants
  • Given numerical invariants, we know how to compute a DFG

Data analysis DFG construction Annotation Data flow edges Sequential reaching definitions Sequential DFG

  • Z. Kincaid (U. Toronto)

Modular Reasoning about Data and Control January 18, 2013 17 / 22

slide-48
SLIDE 48

Experimental results

  • We implemented our algorithm in a tool, DUET
  • Integer overflow & array bounds checks for 15 Linux device drivers
  • DUET proves 1312/1597 (82%) assertions correct in 13m9s
  • Z. Kincaid (U. Toronto)

Modular Reasoning about Data and Control January 18, 2013 18 / 22

slide-49
SLIDE 49

Experimental results: Boolean programs

Boolean abstractions of Linux device drivers: Suite 1 DUET Linear interfaces1 Improvement Assertions proved 2503 1382 81% increase Average time 3.4s 16.9s 5x speedup Suite 2 DUET Dynamic cutoff detection2 Improvement Assertions proved 55 19 189% increase Average time 8.2s 24.9s 3x speedup

  • 1S. La Torre, P

. Madhusudan, and G. Parlato. Model-checking parameterized concurrent programs using linear interfaces. In CAV, pages 629–644. 2010.

  • 2A. Kaiser, D. Kroening, and T. Wahl. Dynamic cutoff detection in parameterized

concurrent programs. In CAV, pages 645–659. 2010.

  • Z. Kincaid (U. Toronto)

Modular Reasoning about Data and Control January 18, 2013 19 / 22

slide-50
SLIDE 50

Conclusion

  • Separate reasoning into a data module and a control module
  • Z. Kincaid (U. Toronto)

Modular Reasoning about Data and Control January 18, 2013 20 / 22

slide-51
SLIDE 51

Conclusion

  • Separate reasoning into a data module and a control module
  • Data flow graphs represent parameterized programs
  • Z. Kincaid (U. Toronto)

Modular Reasoning about Data and Control January 18, 2013 20 / 22

slide-52
SLIDE 52

Conclusion

  • Separate reasoning into a data module and a control module
  • Data flow graphs represent parameterized programs
  • Semi-compositional DFG construction algorithm
  • Z. Kincaid (U. Toronto)

Modular Reasoning about Data and Control January 18, 2013 20 / 22

slide-53
SLIDE 53

Questions?

Thank you for your attention.

  • Z. Kincaid (U. Toronto)

Modular Reasoning about Data and Control January 18, 2013 21 / 22

slide-54
SLIDE 54

Bonus slide: future work

  • Improved algorithms for inferring groups of related variables to improve

DFGs analyses over relational domains (e.g., octagons, polyhedra)

  • Extension to handle aliasing
  • Z. Kincaid (U. Toronto)

Modular Reasoning about Data and Control January 18, 2013 22 / 22