+ All Categories
Home > Documents > 1 Employing decision procedures for automatic analysis and verification of heap-manipulating...

1 Employing decision procedures for automatic analysis and verification of heap-manipulating...

Date post: 12-Jan-2016
Category:
Upload: damian-flynn
View: 213 times
Download: 1 times
Share this document with a friend
39
1 Employing decision procedures Employing decision procedures for automatic analysis and for automatic analysis and verification verification of heap-manipulating programs of heap-manipulating programs Greta Yorsh under the supervision of Mooly Sagiv and Alexander Rabinovich
Transcript
Page 1: 1 Employing decision procedures for automatic analysis and verification of heap-manipulating programs Greta Yorsh under the supervision of Mooly Sagiv.

1

Employing decision procedures for Employing decision procedures for automatic analysis and verification automatic analysis and verification

of heap-manipulating programsof heap-manipulating programs

Greta Yorsh

under the supervision of

Mooly Sagiv and Alexander Rabinovich

Page 2: 1 Employing decision procedures for automatic analysis and verification of heap-manipulating programs Greta Yorsh under the supervision of Mooly Sagiv.

2

class List { List n = null; List append(List a, List b) ...}

List test(List z) {List x, y, t = z;x = new List();y = new List();while (t != null) {

x.n = y;y = new List();t = t.n;

} t = append(x,y); x = append(t,z); return x;}

programmer

x is not null

x and y are disjoint lists

x is acyclic

while loop terminates

It’s not gonna crash

because..

Introduction

Page 3: 1 Employing decision procedures for automatic analysis and verification of heap-manipulating programs Greta Yorsh under the supervision of Mooly Sagiv.

3

class List { List n = null; List append(List a, List b) ...}

List test(List z) {List x, y, t = z;x = new List();y = new List();while (t != null) {

x.n = y;y = new List();t = t.n;

} t = append(x,y); x = append(t,z); return x;}

source code

source code

programmer

Page 4: 1 Employing decision procedures for automatic analysis and verification of heap-manipulating programs Greta Yorsh under the supervision of Mooly Sagiv.

4

source code

source code

compiler

programmer

tester

executable

test inputs

Page 5: 1 Employing decision procedures for automatic analysis and verification of heap-manipulating programs Greta Yorsh under the supervision of Mooly Sagiv.

5

source code

source code

compiler

programmer

executable

tester

test inputs

product

client

Page 6: 1 Employing decision procedures for automatic analysis and verification of heap-manipulating programs Greta Yorsh under the supervision of Mooly Sagiv.

6

source code

source code

compiler

programmer

executable

tester

test inputs

product 2.0

client

לשכת תעסוקהלשכת תעסוקה

Page 7: 1 Employing decision procedures for automatic analysis and verification of heap-manipulating programs Greta Yorsh under the supervision of Mooly Sagiv.

7

compiler

programmer

source code

source code

verifier

verifier

Let X be the set of all inputs…

Page 8: 1 Employing decision procedures for automatic analysis and verification of heap-manipulating programs Greta Yorsh under the supervision of Mooly Sagiv.

8

programmer

source code

source code

compiler

verifier

client

executable

product

Let X be the set of all inputs…

What is software verification? Why do we need software verification? Why is software verification difficult?• How can we verify software?

Page 9: 1 Employing decision procedures for automatic analysis and verification of heap-manipulating programs Greta Yorsh under the supervision of Mooly Sagiv.

9

• Deductive verification [Hoare’76]– ask the programmer– use specifications

– preconditions, postconditions, loop invariants

– use (automatic/interactive) theorem prover

• Abstract interpretation [Coutsot&Cousot’77]– automatically infers loop invariants– use abstraction to over-approximate program’s

behavior9

Software Verification TechniquesSoftware Verification Techniques

Page 10: 1 Employing decision procedures for automatic analysis and verification of heap-manipulating programs Greta Yorsh under the supervision of Mooly Sagiv.

1010

Abstraction

• Choose abstraction: an abstract value represent sets of program states

• Over-approximate all reachable program states

• Check property over abstract values– Proof– Potential error

• Most-precise abstract value• Trade-off precision and cost

Page 11: 1 Employing decision procedures for automatic analysis and verification of heap-manipulating programs Greta Yorsh under the supervision of Mooly Sagiv.

11

• @requires precondition • @ensures postcondition

Leverage Specifications

• Specifications provide insights from the programmer

programmer

source code

source code

verifier

specifications

Page 12: 1 Employing decision procedures for automatic analysis and verification of heap-manipulating programs Greta Yorsh under the supervision of Mooly Sagiv.

12

List test(List z)

{ List x, y, t = z; x = new List(); y = new List(); while (t != null) { x.n = y;

y = new List(); t = t.n; } t = append(x,y); x = append(t,z); return x;}

class List { List n = null;

... List append(List a, List b)

{ if (a == null) return b; List d = a; while (d.n != null)

d = d.n;d.n = b;

return a;}}

@requires acyclic(a) &

disjoint(a,b)@ensures acyclic(ret)

@requires acyclic(z) @ensures acyclic(ret)

Example

Page 13: 1 Employing decision procedures for automatic analysis and verification of heap-manipulating programs Greta Yorsh under the supervision of Mooly Sagiv.

13

Modular AnalysisModular Analysis

• Each procedure is analyzed only once, in isolation• Allows more precise analysis of each procedure

List test(List z)

{ ...

t = append(x,y);

...

return x;}

class List { List n = null;

... List append(List a, List b)

{ ...}}

assume acyclic(t)

@requires acyclic(a)

& disjoint(a,b)@ensures acyclic(ret)

@requires acyclic(z) @ensures acyclic(ret)

assert acyclic(x)& disjoint(x,y)

Page 14: 1 Employing decision procedures for automatic analysis and verification of heap-manipulating programs Greta Yorsh under the supervision of Mooly Sagiv.

14

Challenge

• Abstract interpretation is not designed to take specifications into account– operates on abstract values– does not support symbolic operations assert, assume…

• How to implement these operations ?

• Which specification language to use?

Page 15: 1 Employing decision procedures for automatic analysis and verification of heap-manipulating programs Greta Yorsh under the supervision of Mooly Sagiv.

15

ResultsResults

• Assist program analysis tools to employ formal specifications – algorithms for computing symbolic operations

[TACAS’04, VMCAI’04] – leverage testing to reduce cost of symbolic operations [ISSTA’06]– case-study on modular analysis [AIOOL’05]

• Develop specification language for recursive data-structures that can be incorporated in program analysis– Decidability and undecidability for transitive closure logics [CSL’04]– Verification via structure simulation [CAV’04]– LRP: decidable logic for reasoning about linked data-structures

[FoSSaCS’06, JLAP]

15

Page 16: 1 Employing decision procedures for automatic analysis and verification of heap-manipulating programs Greta Yorsh under the supervision of Mooly Sagiv.

16

Outline

• Two algorithms for computing assume

• Logic of Reachable Patterns

Page 17: 1 Employing decision procedures for automatic analysis and verification of heap-manipulating programs Greta Yorsh under the supervision of Mooly Sagiv.

17

Computing assume

• What is the result of assume ?The most-precise abstract value that represent all states that satisfy

• Why is assume difficult?Formal specification often more expressive than abstract values (describes more sets of concrete states)

Page 18: 1 Employing decision procedures for automatic analysis and verification of heap-manipulating programs Greta Yorsh under the supervision of Mooly Sagiv.

18

Naïve Algorithm for assume • Requires

– finite abstract domain A is a formula in L– for every abstract value a,

the set of states represented by a is expressed by the formula (a) in L

– theorem prover for L

• Choose the least abstract value a s.t. (a) is valid

• Number of calls |A|

Page 19: 1 Employing decision procedures for automatic analysis and verification of heap-manipulating programs Greta Yorsh under the supervision of Mooly Sagiv.

19

Better Algorithms

• Goal: number of calls << |A|

• Two algorithms and their tradeoffs– number of calls height(A) << |A|– usually, |A| is at least 2height(A)

Page 20: 1 Employing decision procedures for automatic analysis and verification of heap-manipulating programs Greta Yorsh under the supervision of Mooly Sagiv.

20

Computing Computing assume from below from below

Page 21: 1 Employing decision procedures for automatic analysis and verification of heap-manipulating programs Greta Yorsh under the supervision of Mooly Sagiv.

21

Computing Computing assume from below from below

[ VMCAI’04, ISSTA’06 ]• Finite-height domain A• Theorem prover for L • Model generator for L

• Extension to infinite-height domains – guarantee termination using widening– no guarantee of precision

• Leveraging concrete execution to reduce number of calls [ISSTA’06]

is (a) valid ?

Page 22: 1 Employing decision procedures for automatic analysis and verification of heap-manipulating programs Greta Yorsh under the supervision of Mooly Sagiv.

22

Computing Computing assume from below from below

[ VMCAI’04, ISSTA’06 ]• Finite-height domain A• Theorem prover for L • Model generator for L

• Extension to infinite-height domains – guarantee termination using widening– no guarantee of precision

• Leveraging concrete execution to reduce number of calls [ISSTA’06]

is (a) valid ? • Intermediate result is not sound

Page 23: 1 Employing decision procedures for automatic analysis and verification of heap-manipulating programs Greta Yorsh under the supervision of Mooly Sagiv.

23

Computing Computing assume from above from above

[TACAS’04]

• Specialized for Canonical Abstraction

• Theorem prover for FOTC

• Intermediate result is always sound

Page 24: 1 Employing decision procedures for automatic analysis and verification of heap-manipulating programs Greta Yorsh under the supervision of Mooly Sagiv.

24

Computing Computing assume

• From below [ VMCAI’04, ISSTA’06 ]• Finite-height domain A• Theorem prover for L • Model generator for L• Intermediate result is not sound

From above [TACAS’04]

• Specialized for Canonical Abstraction

• Theorem prover for FOTC

• Intermediate result is always sound

Page 25: 1 Employing decision procedures for automatic analysis and verification of heap-manipulating programs Greta Yorsh under the supervision of Mooly Sagiv.

25

Employing Theorem Provers

• Theorem prover or model generation might fail– no guarantee of precision

– we can guarantee soundness and termination

• Theorem prover should match the expressive power of the abstraction and the properties of interest

Page 26: 1 Employing decision procedures for automatic analysis and verification of heap-manipulating programs Greta Yorsh under the supervision of Mooly Sagiv.

26

Choosing Specification Language

• Expressive– specifications: assertions, postconditions...– characterization the abstraction (a)

– queries from the algorithms

• Support for automatic reasoning– theorem prover– model generator (for assume from below)

• Predictable– guarantee termination of the analysis– guarantee the most-precise result w.r.t. to the abstraction

Page 27: 1 Employing decision procedures for automatic analysis and verification of heap-manipulating programs Greta Yorsh under the supervision of Mooly Sagiv.

2727

Goal

• Specification language for reasoning about programs that manipulate dynamically allocated memory (heap) and recursive data-structures

– Expressive– Natural for writing specifications– Decidable

Page 28: 1 Employing decision procedures for automatic analysis and verification of heap-manipulating programs Greta Yorsh under the supervision of Mooly Sagiv.

28

Heap-Manipulating Programs

• Imperative programs (in C, C++, Java)– dynamic memory allocation– recursive data-structures– destructive updates of fields x.next = y

• Unbounded size of the heap • Arbitrary structure of the heap

– objects can be heap shared • Heap structure can be mutated

• Invariants involve unbounded objects and reachability between objects

• Temporary violations of data-structure invariants

Page 29: 1 Employing decision procedures for automatic analysis and verification of heap-manipulating programs Greta Yorsh under the supervision of Mooly Sagiv.

2929

MSO

FO+TC

FO

Decidability with ReachabilityDecidability with Reachability

• Allow regular properties of arbitrary heaps– disjointness – cyclicity – reversal– sharing

Page 30: 1 Employing decision procedures for automatic analysis and verification of heap-manipulating programs Greta Yorsh under the supervision of Mooly Sagiv.

3030

Logic of Reachable Patterns (LRP)

• Expressive– regular properties of arbitrary heaps– invariants involve reachability– temporary violations of data-structure invariants

• Decidable– validity, satisfiability, model generation– non-trivial proof of tree-like model property

• Useful for verification

Page 31: 1 Employing decision procedures for automatic analysis and verification of heap-manipulating programs Greta Yorsh under the supervision of Mooly Sagiv.

31

Interesting Heap Properties

• x *y– y is reachable from x

• x +x– x is cyclic

f

f

Page 32: 1 Employing decision procedures for automatic analysis and verification of heap-manipulating programs Greta Yorsh under the supervision of Mooly Sagiv.

32

• List pointed-to by x is not shared

x[ * ]unsf

• where unsf is a pattern

unsf (v0) (v1 v0) (v2 v0) (v1 = v2)

Unshared Lists

v2

v1

v0

f

f

f

f f

Page 33: 1 Employing decision procedures for automatic analysis and verification of heap-manipulating programs Greta Yorsh under the supervision of Mooly Sagiv.

3333

• Doubly-linked list pointed-to by x

x[ * ]invf,b

• where invf,b is a pattern

invf,b (v0) (v0 v1) (v1 v0)

Doubly-linked Lists

f

f b

v0 v1

f

b

Page 34: 1 Employing decision procedures for automatic analysis and verification of heap-manipulating programs Greta Yorsh under the supervision of Mooly Sagiv.

3434

List with head pointers

• x[ * ]p

where p is a pattern

p (v0) (v1 v0) (v1 x)

x f f f f f f

gg g g g

f g

f

Page 35: 1 Employing decision procedures for automatic analysis and verification of heap-manipulating programs Greta Yorsh under the supervision of Mooly Sagiv.

35

x

y’

• precondition

x *null

• postcondition

y’ *null x [ * ] invn,n’

Reversal of Singly-linked List

n

n

n’

Page 36: 1 Employing decision procedures for automatic analysis and verification of heap-manipulating programs Greta Yorsh under the supervision of Mooly Sagiv.

3636

LRP: PrinciplesLRP: Principles

– Arbitrary structure of the heap– Allow arbitrary boolean combinations of

reachability constraints– Restrict quantification: no alternations– Use regular expressions to define reachability – Syntactically limit the patterns

Page 37: 1 Employing decision procedures for automatic analysis and verification of heap-manipulating programs Greta Yorsh under the supervision of Mooly Sagiv.

37

Summary• Approach to software verification

– Prove properties of programs using abstraction– Trade-off between precision and cost of abstraction– Modular program analysis

• Thesis results – Novel algorithms enable program analysis with

user-provided specifications– LRP: decidable logic for reasoning about recursive data-

structures

• Foundations of modular analysis of heap-manipulating programs

Page 38: 1 Employing decision procedures for automatic analysis and verification of heap-manipulating programs Greta Yorsh under the supervision of Mooly Sagiv.

38

Future DirectionsFuture Directions

• Reasoning about data-structures– develop specification languages – develop decision procedures

• Modular analysis of real programs– using user-provided specifications– specification inference

38

Page 39: 1 Employing decision procedures for automatic analysis and verification of heap-manipulating programs Greta Yorsh under the supervision of Mooly Sagiv.

39

Research Topics and CollaboratorsResearch Topics and CollaboratorsAdvisors • Mooly Sagiv• Alexander Rabinovich

Thesis Results• Symbolic implementation of abstract

operations for shape analysis [TACAS’04]– with Tom Reps and Mooly Sagiv

• Combining testing and abstraction [ISSTA’06]– with Tom Ball and Mooly Sagiv

• Logic of Reachable Patterns [FoSSaCS’06,JLAP]

– with Alexander Rabinovich, Mooly Sagiv, Antoine Meyer, Ahmed Bouajjani

Additional Results• Symbolic implementation of best transformer

[VMCAI’04]– with Tom Reps and Mooly Sagiv

• Case-study on assume-guarantee [AIOOL’05]– with Alexey Skidanov, Tom Reps, Mooly Sagiv

• Verificiation via Structure Simulation [CAV’04]– with Neil Immerman, Tom Reps, Mooly Sagiv

• Decidability and undecidability for transitive closure logics [CSL’04]

– with Neil Immerman, Tom Reps, Mooly Sagiv

• Abstraction for falsification [CAV’05]– with Tom Ball, Orna Kupferman

• Combination method for generating interpolants [CADE’05]

– with Madan Musuvathi

• Modular typestate verification [POPL’08]– with Eran Yahav, Satish Chandra

39

Ongoing work• Decision procedure for LRP, extensions

– with Mooly Sagiv, Alexander Rabinovich

• Decidability and model generation for fragments of separation logic

– with Josh Berdine, Byron Cook, Mooly Sagiv


Recommended