Symbolic Heap Abstraction with Demand-Driven Axiomatization of - - PowerPoint PPT Presentation

symbolic heap abstraction with demand driven
SMART_READER_LITE
LIVE PREVIEW

Symbolic Heap Abstraction with Demand-Driven Axiomatization of - - PowerPoint PPT Presentation

Symbolic Heap Abstraction with Demand-Driven Axiomatization of Memory Invariants Isil Dillig Thomas Dillig Alex Aiken Stanford University Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization


slide-1
SLIDE 1

Symbolic Heap Abstraction with Demand-Driven Axiomatization of Memory Invariants

Isil Dillig Thomas Dillig Alex Aiken Stanford University

Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

slide-2
SLIDE 2

Relational vs. Non-Relational Heap analysis

Goal of heap analysis: Statically describe all possible points-to relations in the heap for any execution of the program.

Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

slide-3
SLIDE 3

Relational vs. Non-Relational Heap analysis

Goal of heap analysis: Statically describe all possible points-to relations in the heap for any execution of the program. Heap analyses can be characterized as relational or non-relational:

Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

slide-4
SLIDE 4

Relational vs. Non-Relational Heap analysis

Goal of heap analysis: Statically describe all possible points-to relations in the heap for any execution of the program. Heap analyses can be characterized as relational or non-relational:

A relational analysis tracks correlations between points-to targets of two memory locations

Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

slide-5
SLIDE 5

Relational vs. Non-Relational Heap analysis

Goal of heap analysis: Statically describe all possible points-to relations in the heap for any execution of the program. Heap analyses can be characterized as relational or non-relational:

A relational analysis tracks correlations between points-to targets of two memory locations A non-relational heap analysis does not.

Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

slide-6
SLIDE 6

Relational vs. Non-Relational Heap analysis

Goal of heap analysis: Statically describe all possible points-to relations in the heap for any execution of the program. Heap analyses can be characterized as relational or non-relational:

A relational analysis tracks correlations between points-to targets of two memory locations A non-relational heap analysis does not.

Relational heap analyses are more precise, but also more expensive.

Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

slide-7
SLIDE 7

An Example

Consider the code snippet:

if(*) *x = a; else *x = b; y = x; assert(*x == *y);

Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

slide-8
SLIDE 8

An Example

Consider the code snippet:

if(*) *x = a; else *x = b; y = x; assert(*x == *y);

Non-relational:

x y a b

Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

slide-9
SLIDE 9

An Example

Consider the code snippet:

if(*) *x = a; else *x = b; y = x; assert(*x == *y);

Non-relational:

x y a b

Does not encode x and y must point to same location

Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

slide-10
SLIDE 10

An Example

Consider the code snippet:

if(*) *x = a; else *x = b; y = x; assert(*x == *y);

Non-relational:

x y a b

Does not encode x and y must point to same location Cannot prove the assertion

Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

slide-11
SLIDE 11

An Example

Consider the code snippet:

if(*) *x = a; else *x = b; y = x; assert(*x == *y);

Relational:

x y a x y b

Heap 1 Heap 2

Perform case split on possible heaps.

Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

slide-12
SLIDE 12

An Example

Consider the code snippet:

if(*) *x = a; else *x = b; y = x; assert(*x == *y);

Relational:

x y a x y b

Heap 1 Heap 2

Perform case split on possible heaps. Can prove assertion because in both heaps x and y point to same location.

Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

slide-13
SLIDE 13

Relational Analysis via Heap Splitting

Advantages:

Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

slide-14
SLIDE 14

Relational Analysis via Heap Splitting

Advantages:

Each abstract location points to exactly one target location per heap

x y a x y b

Heap 1 Heap 2

Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

slide-15
SLIDE 15

Relational Analysis via Heap Splitting

Advantages:

Each abstract location points to exactly one target location per heap ⇒ precise relational reasoning

x y a x y b

Heap 1 Heap 2

Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

slide-16
SLIDE 16

Relational Analysis via Heap Splitting

Advantages:

Each abstract location points to exactly one target location per heap ⇒ precise relational reasoning

Disadvantages:

x y a x y b

Heap 1 Heap 2

Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

slide-17
SLIDE 17

Relational Analysis via Heap Splitting

Advantages:

Each abstract location points to exactly one target location per heap ⇒ precise relational reasoning

Disadvantages:

Generates exponential number of heaps

x y a x y b

Heap 1 Heap 2

Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

slide-18
SLIDE 18

Relational Analysis via Heap Splitting

Advantages:

Each abstract location points to exactly one target location per heap ⇒ precise relational reasoning

Disadvantages:

Generates exponential number of heaps Duplicates shared portion

  • f the heaps

x y a x y b

Heap 1 Heap 2

Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

slide-19
SLIDE 19

Relational Analysis via Heap Splitting

Advantages:

Each abstract location points to exactly one target location per heap ⇒ precise relational reasoning

Disadvantages:

Generates exponential number of heaps Duplicates shared portion

  • f the heaps

⇒ Very expensive and unscalable

x y a x y b

Heap 1 Heap 2

Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

slide-20
SLIDE 20

Relational Analysis via Heap Splitting

Advantages:

Each abstract location points to exactly one target location per heap ⇒ precise relational reasoning

Disadvantages:

Generates exponential number of heaps Duplicates shared portion

  • f the heaps

⇒ Very expensive and unscalable

This talk: Scalable and precise relational heap analysis without per- forming explicit case splits on the heap

Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

slide-21
SLIDE 21

Memory Invariants

Insight: We can achieve relational reasoning by enforcing two important memory invariants that real computer memories satisfy:

Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

slide-22
SLIDE 22

Memory Invariants

Insight: We can achieve relational reasoning by enforcing two important memory invariants that real computer memories satisfy: Existence: Every memory location has at least one value

Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

slide-23
SLIDE 23

Memory Invariants

Insight: We can achieve relational reasoning by enforcing two important memory invariants that real computer memories satisfy: Existence: Every memory location has at least one value Uniqueness: Every memory location has at most one value

Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

slide-24
SLIDE 24

Memory Invariants

Insight: We can achieve relational reasoning by enforcing two important memory invariants that real computer memories satisfy: Existence: Every memory location has at least one value Uniqueness: Every memory location has at most one value ⇒ Heap splitting is one way of enforcing these invariants.

Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

slide-25
SLIDE 25

Enforcing Memory Invariants

Idea Enforce memory invariants symbolically using constraints on a single heap abstraction.

Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

slide-26
SLIDE 26

Enforcing Memory Invariants

Idea Enforce memory invariants symbolically using constraints on a single heap abstraction. No explicit case splits on the heap, but solver may internally need to perform case analysis

Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

slide-27
SLIDE 27

Enforcing Memory Invariants

Idea Enforce memory invariants symbolically using constraints on a single heap abstraction. No explicit case splits on the heap, but solver may internally need to perform case analysis Still advantageous because:

Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

slide-28
SLIDE 28

Enforcing Memory Invariants

Idea Enforce memory invariants symbolically using constraints on a single heap abstraction. No explicit case splits on the heap, but solver may internally need to perform case analysis Still advantageous because:

Solver can often prove a constraint SAT or UNSAT without considering all cases: eager vs. lazy

Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

slide-29
SLIDE 29

Enforcing Memory Invariants

Idea Enforce memory invariants symbolically using constraints on a single heap abstraction. No explicit case splits on the heap, but solver may internally need to perform case analysis Still advantageous because:

Solver can often prove a constraint SAT or UNSAT without considering all cases: eager vs. lazy Don’t duplicate shared portions of the heap

Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

slide-30
SLIDE 30

Enforcing Memory Invariants

Idea Enforce memory invariants symbolically using constraints on a single heap abstraction. No explicit case splits on the heap, but solver may internally need to perform case analysis Still advantageous because:

Solver can often prove a constraint SAT or UNSAT without considering all cases: eager vs. lazy Don’t duplicate shared portions of the heap No heuristics for merging“similar”heaps

Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

slide-31
SLIDE 31

Enforcing Memory Invariants

x a b

To encode that x cannot point to a and b at the same time, we can use two constraints φ and ¬φ

Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

slide-32
SLIDE 32

Enforcing Memory Invariants

x a b

To encode that x cannot point to a and b at the same time, we can use two constraints φ and ¬φ

Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

slide-33
SLIDE 33

Enforcing Memory Invariants

x a b

To encode that x cannot point to a and b at the same time, we can use two constraints φ and ¬φ ⇒ Uniqueness

Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

slide-34
SLIDE 34

Enforcing Memory Invariants

x a b

To encode that x cannot point to a and b at the same time, we can use two constraints φ and ¬φ ⇒ Uniqueness Also encodes that x must point to either a or b

Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

slide-35
SLIDE 35

Enforcing Memory Invariants

x a b

To encode that x cannot point to a and b at the same time, we can use two constraints φ and ¬φ ⇒ Uniqueness Also encodes that x must point to either a or b ⇒ Existence

Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

slide-36
SLIDE 36

Enforcing Memory Invariants

x y a b

Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

slide-37
SLIDE 37

Enforcing Memory Invariants

x y a b

Correlation between x and y preserved x and y point to different locations under φ ∧ ¬φ ⇒ Can prove the assertion!

Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

slide-38
SLIDE 38

Memory Invariants on Unbounded Locations

Easy to enforce these invariants when each abstract location corresponds to one concrete location.

Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

slide-39
SLIDE 39

Memory Invariants on Unbounded Locations

Easy to enforce these invariants when each abstract location corresponds to one concrete location. But what about abstract locations that represent multiple concrete locations?

Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

slide-40
SLIDE 40

Memory Invariants on Summary Locations

x a b

Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

slide-41
SLIDE 41

Memory Invariants on Summary Locations

x a b

Most techniques represent the array with a summary node.

Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

slide-42
SLIDE 42

Memory Invariants on Summary Locations

x a b

Most techniques represent the array with a summary node. Graph encodes that any element in x may point to either a

  • r b.

Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

slide-43
SLIDE 43

Memory Invariants on Summary Locations

x a b

Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

slide-44
SLIDE 44

Memory Invariants on Summary Locations

x a b

Encodes that an element of x cannot point to both a and b

Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

slide-45
SLIDE 45

Memory Invariants on Summary Locations

x a b

Encodes that an element of x cannot point to both a and b . . . but erroneously encodes x[1] and x[2] must have same value!

Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

slide-46
SLIDE 46

Memory Invariants on Summary Locations

x a b

Conclusion To enforce memory invariants symbolically, we need a way to refer to individual elements in summary locations.

Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

slide-47
SLIDE 47

Symbolic Heap Abstraction

Use the symbolic heap from our previous work that allows distinguishing individual elements in a summary location.

Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

slide-48
SLIDE 48

Symbolic Heap Abstraction

Use the symbolic heap from our previous work that allows distinguishing individual elements in a summary location.

This basic symbolic heap does not enforce memory invariants

Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

slide-49
SLIDE 49

Symbolic Heap Abstraction

Use the symbolic heap from our previous work that allows distinguishing individual elements in a summary location.

This basic symbolic heap does not enforce memory invariants

Describe new technique to enforce memory invariants on the symbolic heap without explicit case splits

Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

slide-50
SLIDE 50

Symbolic Heap

a b

Abstract locations that represent more than one concrete location are qualified by index variables.

Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

slide-51
SLIDE 51

Symbolic Heap

a b

Abstract locations that represent more than one concrete location are qualified by index variables.

Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

slide-52
SLIDE 52

Symbolic Heap

a b

Abstract locations that represent more than one concrete location are qualified by index variables.

Index variables allow us to refer to individual elements inside the abstract location

Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

slide-53
SLIDE 53

Symbolic Heap

a b

Bracketing constraints on points-to edges qualify which elements in the source location may and must point to which elements in the target location.

Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

slide-54
SLIDE 54

Symbolic Heap

a b

Bracketing constraints on points-to edges qualify which elements in the source location may and must point to which elements in the target location.

Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

slide-55
SLIDE 55

Symbolic Heap

a b

Bracketing constraints on points-to edges qualify which elements in the source location may and must point to which elements in the target location.

Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

slide-56
SLIDE 56

Symbolic Heap

a b

This heap does not enforce memory invariants

Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

slide-57
SLIDE 57

Symbolic Heap

a b

This heap does not enforce memory invariants Uniqueness violated because conjunction of may conditions is not unsatisfiable.

Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

slide-58
SLIDE 58

Symbolic Heap

a b

This heap does not enforce memory invariants Uniqueness violated because conjunction of may conditions is not unsatisfiable. Existence violated because disjunction of must conditions is not valid.

Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

slide-59
SLIDE 59

Making the Symbolic Heap Relational

Goal: Modify the basic symbolic heap such that:

Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

slide-60
SLIDE 60

Making the Symbolic Heap Relational

Goal: Modify the basic symbolic heap such that:

1 Enforces the existence and uniqueness of memory contents

Symbolically using constraints

Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

slide-61
SLIDE 61

Making the Symbolic Heap Relational

Goal: Modify the basic symbolic heap such that:

1 Enforces the existence and uniqueness of memory contents

Symbolically using constraints Replace original constraints with new constraints ∆ enforcing these invariants.

Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

slide-62
SLIDE 62

Making the Symbolic Heap Relational

Goal: Modify the basic symbolic heap such that:

1 Enforces the existence and uniqueness of memory contents

Symbolically using constraints Replace original constraints with new constraints ∆ enforcing these invariants.

2 Preserves all the partial information encoded in the original

symbolic heap

Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

slide-63
SLIDE 63

Making the Symbolic Heap Relational

Goal: Modify the basic symbolic heap such that:

1 Enforces the existence and uniqueness of memory contents

Symbolically using constraints Replace original constraints with new constraints ∆ enforcing these invariants.

2 Preserves all the partial information encoded in the original

symbolic heap

Restore existing information by adding quantified axioms relating ∆ to the original constraints

Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

slide-64
SLIDE 64

Enforcing Existence and Uniqueness on the Symbolic Heap

Consider any location A for which invariants are violated.

Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

slide-65
SLIDE 65

Enforcing Existence and Uniqueness on the Symbolic Heap

Consider any location A for which invariants are violated. Replace constraint on i’th edge from A with constraint ∆i enforcing memory invariants on each concrete element in A.

Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

slide-66
SLIDE 66

Enforcing Existence and Uniqueness on the Symbolic Heap

Consider any location A for which invariants are violated. Replace constraint on i’th edge from A with constraint ∆i enforcing memory invariants on each concrete element in A. These ∆i’s are of the form Γi ∧ Θi

Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

slide-67
SLIDE 67

Enforcing Existence and Uniqueness on the Symbolic Heap

Consider any location A for which invariants are violated. Replace constraint on i’th edge from A with constraint ∆i enforcing memory invariants on each concrete element in A. These ∆i’s are of the form Γi ∧ Θi

Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

slide-68
SLIDE 68

Enforcing Existence and Uniqueness on the Symbolic Heap

Consider any location A for which invariants are violated. Replace constraint on i’th edge from A with constraint ∆i enforcing memory invariants on each concrete element in A. These ∆i’s are of the form Γi ∧ Θi

Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

slide-69
SLIDE 69

Enforcing Existence and Uniqueness on the Symbolic Heap

Consider any location A for which invariants are violated. Replace constraint on i’th edge from A with constraint ∆i enforcing memory invariants on each concrete element in A. These ∆i’s are of the form Γi ∧ Θi

Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

slide-70
SLIDE 70

Enforcing Existence and Uniqueness on the Symbolic Heap

Consider any location A for which invariants are violated. Replace constraint on i’th edge from A with constraint ∆i enforcing memory invariants on each concrete element in A. These ∆i’s are of the form Γi ∧ Θi

Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

slide-71
SLIDE 71

Enforcing Existence and Uniqueness on the Symbolic Heap

Consider any location A for which invariants are violated. Replace constraint on i’th edge from A with constraint ∆i enforcing memory invariants on each concrete element in A. These ∆i’s are of the form Γi ∧ Θi

Γ: Each concrete element →

  • ne abstract target

Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

slide-72
SLIDE 72

Enforcing Existence and Uniqueness on the Symbolic Heap

Consider any location A for which invariants are violated. Replace constraint on i’th edge from A with constraint ∆i enforcing memory invariants on each concrete element in A. These ∆i’s are of the form Γi ∧ Θi

Γ: Each concrete element →

  • ne abstract target

Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

slide-73
SLIDE 73

Enforcing Existence and Uniqueness on the Symbolic Heap

Consider any location A for which invariants are violated. Replace constraint on i’th edge from A with constraint ∆i enforcing memory invariants on each concrete element in A. These ∆i’s are of the form Γi ∧ Θi

Γ: Each concrete element →

  • ne abstract target

Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

slide-74
SLIDE 74

Enforcing Existence and Uniqueness on the Symbolic Heap

Consider any location A for which invariants are violated. Replace constraint on i’th edge from A with constraint ∆i enforcing memory invariants on each concrete element in A. These ∆i’s are of the form Γi ∧ Θi

Γ: Each concrete element →

  • ne abstract target

Θ: In this abstract target, select

  • ne concrete element.

Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

slide-75
SLIDE 75

Constructing Γ’s

Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

slide-76
SLIDE 76

Constructing Γ’s

Want to ensure i’th element of A points to exactly one Bj .

Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

slide-77
SLIDE 77

Constructing Γ’s

Want to ensure i’th element of A points to exactly one Bj . Introduce an uninterpreted function δ(i) that selects an edge for the i’th element.

Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

slide-78
SLIDE 78

Constructing Γ’s

Want to ensure i’th element of A points to exactly one Bj . Introduce an uninterpreted function δ(i) that selects an edge for the i’th element.

Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

slide-79
SLIDE 79

Constructing Γ’s

Want to ensure i’th element of A points to exactly one Bj . Introduce an uninterpreted function δ(i) that selects an edge for the i’th element.

Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

slide-80
SLIDE 80

Constructing Γ’s

Want to ensure i’th element of A points to exactly one Bj . Introduce an uninterpreted function δ(i) that selects an edge for the i’th element.

Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

slide-81
SLIDE 81

Constructing Γ’s

Want to ensure i’th element of A points to exactly one Bj . Introduce an uninterpreted function δ(i) that selects an edge for the i’th element.

Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

slide-82
SLIDE 82

Constructing Γ’s

For any assignment v to i: Γj (v) ∧ Γm(v) is UNSAT.

  • j Γj (v) is VALID.

Want to ensure i’th element of A points to exactly one Bj . Introduce an uninterpreted function δ(i) that selects an edge for the i’th element.

Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

slide-83
SLIDE 83

Constructing Γ’s

For any assignment v to i: Γj (v) ∧ Γm(v) is UNSAT.

  • j Γj (v) is VALID.

Want to ensure i’th element of A points to exactly one Bj . Introduce an uninterpreted function δ(i) that selects an edge for the i’th element. ⇒ Each concrete element in A has exactly one abstract target.

Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

slide-84
SLIDE 84

Constructing Γ’s

For any assignment v to i: Γj (v) ∧ Γm(v) is UNSAT.

  • j Γj (v) is VALID.

Want to ensure i’th element of A points to exactly one Bj . Introduce an uninterpreted function δ(i) that selects an edge for the i’th element. ⇒ Each concrete element in A has exactly one abstract target. Correctly allows different indices to point to same target.

Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

slide-85
SLIDE 85

Example

a b

Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

slide-86
SLIDE 86

Example

a b

Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

slide-87
SLIDE 87

Example

a b

Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

slide-88
SLIDE 88

Example

a b

We can now prove the assertion!

Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

slide-89
SLIDE 89

Example

a b

We can now prove the assertion!

Because x[k] and y[k] point to different locations under δ(k) ≤ 0 ∧ δ(k) ≥ 1 ⇒ UNSAT

Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

slide-90
SLIDE 90

Why do we need Θ?

Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

slide-91
SLIDE 91

Why do we need Θ?

Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

slide-92
SLIDE 92

Why do we need Θ?

Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

slide-93
SLIDE 93

Why do we need Θ?

Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

slide-94
SLIDE 94

Why do we need Θ?

Encodes x[i] cannot point to a and b at the same time.

Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

slide-95
SLIDE 95

Why do we need Θ?

Encodes x[i] cannot point to a and b at the same time. But x[i] can still point to two different elements in a

Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

slide-96
SLIDE 96

Constructing Θ

Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

slide-97
SLIDE 97

Constructing Θ

Want the heap abstraction to encode that i’th element of A must point to exactly one element in B.

Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

slide-98
SLIDE 98

Constructing Θ

Want the heap abstraction to encode that i’th element of A must point to exactly one element in B.

Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

slide-99
SLIDE 99

Constructing Θ

Want the heap abstraction to encode that i’th element of A must point to exactly one element in B. Since τ is a function, each element in A is mapped to exactly

  • ne element in B.

Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

slide-100
SLIDE 100

Constructing Θ

Want the heap abstraction to encode that i’th element of A must point to exactly one element in B. Since τ is a function, each element in A is mapped to exactly

  • ne element in B.

Since τ is uninterpreted, each element in A is mapped to an unknown element in B.

Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

slide-101
SLIDE 101

Example

Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

slide-102
SLIDE 102

Example

Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

slide-103
SLIDE 103

Example

Now encodes that each element in x points to exactly one concrete element in a or b.

Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

slide-104
SLIDE 104

Example

Now encodes that each element in x points to exactly one concrete element in a or b. Can now prove assertion.

Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

slide-105
SLIDE 105

Preserving Existing Information

So far, we have enforced the memory invariants; but we did not preserve all the information in the original symbolic heap.

Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

slide-106
SLIDE 106

Preserving Existing Information

So far, we have enforced the memory invariants; but we did not preserve all the information in the original symbolic heap.

Using original heap, can prove x[2] cannot point to a[4].

Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

slide-107
SLIDE 107

Preserving Existing Information

So far, we have enforced the memory invariants; but we did not preserve all the information in the original symbolic heap.

Using original heap, can prove x[2] cannot point to a[4]. But using the modified heap, we can no longer prove this.

Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

slide-108
SLIDE 108

Preserving Existing Information

Solution: If edge in original heap is qualified by φmay, φmust, then introduce axioms of the form: ∀i. Γ ⇒ φmay ∀i. φmust ⇒ Γ

Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

slide-109
SLIDE 109

Preserving Existing Information

Solution: If edge in original heap is qualified by φmay, φmust, then introduce axioms of the form: ∀i. Γ ⇒ φmay ∀i. φmust ⇒ Γ Can prove everthing provable under original symbolic heap

Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

slide-110
SLIDE 110

Preserving Existing Information

Solution: If edge in original heap is qualified by φmay, φmust, then introduce axioms of the form: ∀i. Γ ⇒ φmay ∀i. φmust ⇒ Γ Can prove everthing provable under original symbolic heap

And much more because we have relational reasoning

Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

slide-111
SLIDE 111

Preserving Existing Information

Solution: If edge in original heap is qualified by φmay, φmust, then introduce axioms of the form: ∀i. Γ ⇒ φmay ∀i. φmust ⇒ Γ Can prove everthing provable under original symbolic heap

And much more because we have relational reasoning

Set of provable assertions is now monotonic with respect to the precision of the original heap abstraction

Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

slide-112
SLIDE 112

Preserving Existing Information

Solution: If edge in original heap is qualified by φmay, φmust, then introduce axioms of the form: ∀i. Γ ⇒ φmay ∀i. φmust ⇒ Γ Can prove everthing provable under original symbolic heap

And much more because we have relational reasoning

Set of provable assertions is now monotonic with respect to the precision of the original heap abstraction

This does not hold without enforcing memory invariants!

Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

slide-113
SLIDE 113

Experiments

We implemented this technique as part of

  • ur Compass program analysis system

Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

slide-114
SLIDE 114

Experiments

We implemented this technique as part of

  • ur Compass program analysis system

Verified memory safety properties (absence

  • f buffer overruns, null derefereces, and

casting errors) in a number of Unix Coreutils applications and on OpenSSH.

Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

slide-115
SLIDE 115

Results on OpenSSH

Relational Non-relational Time (s)

261 788

Max memory used (MB)

208 763

# reported buffer errors

2 77

# reported null errors

3 53

# reported cast errors

28

Total # of errors

5 158

Total # of false positives

1 154

Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

slide-116
SLIDE 116

Results on OpenSSH

Relational Non-relational Time (s)

261 788

Max memory used (MB)

208 763

# reported buffer errors

2 77

# reported null errors

3 53

# reported cast errors

28

Total # of errors

5 158

Total # of false positives

1 154 Compared relational symbolic heap with basic non-relational symbolic heap for verifying memory safety in OpenSSH.

Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

slide-117
SLIDE 117

Results on OpenSSH

Relational Non-relational Time (s)

261 788

Max memory used (MB)

208 763

# reported buffer errors

2 77

# reported null errors

3 53

# reported cast errors

28

Total # of errors

5 158

Total # of false positives

1 154 Compared relational symbolic heap with basic non-relational symbolic heap for verifying memory safety in OpenSSH. Relational analysis symbolically enforces memory invariants.

Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

slide-118
SLIDE 118

Results on OpenSSH

Relational Non-relational Time (s)

261 788

Max memory used (MB)

208 763

# reported buffer errors

2 77

# reported null errors

3 53

# reported cast errors

28

Total # of errors

5 158

Total # of false positives

1 154 Relational technique is very precise.

Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

slide-119
SLIDE 119

Results on OpenSSH

Relational Non-relational Time (s)

261 788

Max memory used (MB)

208 763

# reported buffer errors

2 77

# reported null errors

3 53

# reported cast errors

28

Total # of errors

5 158

Total # of false positives

1 154 Relational technique is very precise. Technique without memory invariants reports many false positives.

Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

slide-120
SLIDE 120

Results on OpenSSH

Relational Non-relational Time (s)

261 788

Max memory used (MB)

208 763

# reported buffer errors

2 77

# reported null errors

3 53

# reported cast errors

28

Total # of errors

5 158

Total # of false positives

1 154 Relational technique is very precise. Technique without memory invariants reports many false positives.

Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

slide-121
SLIDE 121

Results on OpenSSH

Relational Non-relational Time (s)

261 788

Max memory used (MB)

208 763

# reported buffer errors

2 77

# reported null errors

3 53

# reported cast errors

28

Total # of errors

5 158

Total # of false positives

1 154 Relational technique is very precise. Technique without memory invariants reports many false positives. Surprisingly, more precise is also more efficient.

Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

slide-122
SLIDE 122

Results on OpenSSH

Relational Non-relational Time (s)

261 788

Max memory used (MB)

208 763

# reported buffer errors

2 77

# reported null errors

3 53

# reported cast errors

28

Total # of errors

5 158

Total # of false positives

1 154 Relational technique is very precise. Technique without memory invariants reports many false positives. Surprisingly, more precise is also more efficient. Memory invariant alone is sufficient to discharge many facts.

Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

slide-123
SLIDE 123

Thank You!

Dillig, I., Dillig, T., Aiken, A.: Fluid updates: Beyond strong vs. weak updates. In: ESOP (2010) 246–266 Reps, T.W., Sagiv, S., Wilhelm, R.: Static program analysis via 3-valued logic. In: CAV (2004) 15–30 Gopan, D., Reps, T., Sagiv, M.: A framework for numeric analysis of array operations. In: POPL (2005) 338–350 Bogudlov, I., Lev-Ami, T., Reps, T., Sagiv, M.: Revamping TVLA: Making parametric shape analysis competitive. Lecture Notes in Computer Science 4590 (2007) 221 Manevich, R.: Partially Disjunctive Shape Analysis. PhD thesis, Tel Aviv University (2009)

Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization