A posteriori soundness for nondeterministic abstract - - PowerPoint PPT Presentation

a posteriori soundness for nondeterministic abstract
SMART_READER_LITE
LIVE PREVIEW

A posteriori soundness for nondeterministic abstract - - PowerPoint PPT Presentation

A posteriori soundness for nondeterministic abstract interpretations Matthew Might (University of Utah) Panagiotis Manolios (Northeastern University) Questions you dont want at your defense Questions you dont want at your defense


slide-1
SLIDE 1

A posteriori soundness for nondeterministic abstract interpretations

Matthew Might (University of Utah) Panagiotis Manolios (Northeastern University)

slide-2
SLIDE 2

Questions you don’t want at your defense

slide-3
SLIDE 3

Questions you don’t want at your defense

  • “But, why did you prove it that way?”
slide-4
SLIDE 4

Questions you don’t want at your defense

  • “But, why did you prove it that way?”
  • “But, why is that necessary?”
slide-5
SLIDE 5

Questions you don’t want at your defense

  • “But, why did you prove it that way?”
  • “But, why is that necessary?”
  • “So, why did the Cousots do it that way?”
slide-6
SLIDE 6
  • Where did it come from?
  • How do you prove it sound?
  • Why would you want to use it?

Nondeterministic Abstract Interpretation

slide-7
SLIDE 7
  • Where did it come from?
  • How do you prove it sound?
  • Why would you want to use it?

Nondeterministic Abstract Interpretation

  • Frustration with the standard recipe.
slide-8
SLIDE 8
  • Where did it come from?
  • How do you prove it sound?
  • Why would you want to use it?

Nondeterministic Abstract Interpretation

  • Frustration with the standard recipe.
  • A posteriori proof technique.
slide-9
SLIDE 9
  • Where did it come from?
  • How do you prove it sound?
  • Why would you want to use it?

Nondeterministic Abstract Interpretation

  • Frustration with the standard recipe.
  • A posteriori proof technique.
  • Better speed, better precision.
slide-10
SLIDE 10

Outline

  • Review standard recipe.
  • Find annoyances.
  • Get rid of them.
slide-11
SLIDE 11

Define abstraction map: α : L → ˆ L Prove simulates under . α f ˆ f

The Standard Recipe

Define concrete state-space: L Define abstract state-space: ˆ L Define concrete semantics: f : L → L Define abstract semantics: ˆ f : ˆ L → ˆ L

slide-12
SLIDE 12

Define abstraction map: α : L → ˆ L

The A Posteriori Recipe

Prove simulates under . α f ˆ f Execute abstract semantics to obtain . ˆ ℓ′ = ˆ f(ˆ ℓ) Define concrete state-space: L Define abstract state-space: ˆ L Define concrete semantics: f : L → L Define abstract semantics: ˆ f : ˆ L → ˆ L

slide-13
SLIDE 13

Define abstraction map: α : L → ˆ L

The A Posteriori Recipe

Prove simulates under . α f ˆ ℓ′ Execute abstract semantics to obtain . ˆ ℓ′ = ˆ f(ˆ ℓ) Define concrete state-space: L Define abstract state-space: ˆ L Define concrete semantics: f : L → L Define abstract semantics: ˆ f : ˆ L → ˆ L

slide-14
SLIDE 14

ˆ f : ˆ L → 2

ˆ L

Define abstract semantics: Define abstraction map: α : L → ˆ L

The A Posteriori Recipe

Prove simulates under . α f ˆ ℓ′ Execute abstract semantics to obtain . ˆ ℓ′ = ˆ f(ˆ ℓ) Define concrete state-space: L Define abstract state-space: ˆ L Define concrete semantics: f : L → L

slide-15
SLIDE 15

Illustrating the Standard Recipe

slide-16
SLIDE 16

Malloc: The Language

v := malloc()

slide-17
SLIDE 17

Malloc: The Language

v := malloc() lab :

slide-18
SLIDE 18

Concrete Semantics

State = Instruction × Store

slide-19
SLIDE 19

Concrete Semantics

State = Instruction × Store f(ς) = ς′

slide-20
SLIDE 20

Concrete Semantics

Fresh State = Instruction × Store f([ [v := malloc()] ] : i, σ) = (

  • i, σ[v → a′])
slide-21
SLIDE 21

Concrete Semantics

Fresh State = Instruction × Store a′ = alloc(ς) f([ [v := malloc()] ] : i, σ) = (

  • i, σ[v → a′])
slide-22
SLIDE 22

Concrete Semantics

Fresh State = Instruction × Store a′ = alloc(ς) = max(range(σ)) + 1 f([ [v := malloc()] ] : i, σ) = (

  • i, σ[v → a′])
slide-23
SLIDE 23

ˆ a = alloc(ˆ ς)

Abstract Semantics

  • State = Instruction ×

Store ˆ f([ [v := malloc()] ] : i, ˆ σ) = (

  • i, ˆ

σ[v → ˆ a]) (from some finite set)

slide-24
SLIDE 24

What to allocate?

  • Abstract addresses = Scarce resource
  • Avoid over-allocation: Good for speed
  • Avoid under-allocation: Good for precision
slide-25
SLIDE 25

Example: Over-allocation

3 ˆ a1 ˆ a2

slide-26
SLIDE 26

Example: Over-allocation

3 ˆ a1,2

slide-27
SLIDE 27

Example: Under-allocation

3 4 ˆ a′

slide-28
SLIDE 28

ˆ a1 ˆ a2

Example: Under-allocation

3 4

slide-29
SLIDE 29

Allocation heuristics

Observation: Objects from like contexts act alike.

slide-30
SLIDE 30

Allocation heuristics

Example:

  • alloc([

[lab : . . .] ] : i, ) = lab Observation: Objects from like contexts act alike.

slide-31
SLIDE 31

Annoyance: Soundness

α(ς) ⊑ ˆ ς α(f(ς)) ⊑ ˆ f(ˆ ς) If then

slide-32
SLIDE 32

Annoyance: Soundness

α(ς) ⊑ ˆ ς If then αAddr(alloc(ς)) ⊑ alloc(ˆ ς)

slide-33
SLIDE 33

The Issue

  • alloc([

[lab : . . .] ] : i, ) = lab What abstraction map will work here? alloc( , σ) = max(range(σ)) + 1

slide-34
SLIDE 34

Example

B : y := malloc() A : x := malloc() [x → , y → ] [ →A, → B] 1 2 1 2 αAddr = σ =

slide-35
SLIDE 35

Example

B : y := malloc() A : x := malloc() [x → , y → ] [ →A, → B] 1 2 1 2 αAddr = σ =

slide-36
SLIDE 36

Example

B : y := malloc() A : x := malloc() [x → , y → ] [ →A, → B] 1 2 1 2 αAddr = σ =

slide-37
SLIDE 37

Example

B : y := malloc() A : x := malloc() [x → , y → ] [ →A, → B] 1 2 1 2 αAddr = σ =

slide-38
SLIDE 38

Change the concrete semantics!

Standard Solution

slide-39
SLIDE 39

Change the concrete semantics!

Standard Solution

alloc( , σ) = max(range(σ)) + 1 Addr = N

slide-40
SLIDE 40

Change the concrete semantics! Addr = N × Lab

Standard Solution

alloc([ [lab : . . .] ], σ) = (max(range(σ)1) + 1, lab)

slide-41
SLIDE 41

Change the concrete semantics! Addr = N × Lab

Standard Solution

alloc([ [lab : . . .] ], σ) = (max(range(σ)1) + 1, lab) α( , lab) = lab

slide-42
SLIDE 42

Another problem: Heuristics sometimes make stupid decisions

slide-43
SLIDE 43

Another problem: Heuristics sometimes make stupid decisions Why not adapt on the fly?

slide-44
SLIDE 44

Example: Greedy Strategy

3 ˆ a1 Heuristic says, “Allocate , and bind 4.” ˆ a1

slide-45
SLIDE 45

Example: Greedy Strategy

3 4 ˆ a1 Heuristic says, “Allocate , and bind 4.” ˆ a1

slide-46
SLIDE 46

Example: Greedy Strategy

3 4 ˆ a1 Adaptive allocator says, “Try first.” r(ˆ a1) Heuristic says, “Allocate , and bind 4.” ˆ a1

slide-47
SLIDE 47

Example: Greedy Strategy

3 4 ˆ a1 r(ˆ a1) Adaptive allocator says, “Try first.” r(ˆ a1) Heuristic says, “Allocate , and bind 4.” ˆ a1

slide-48
SLIDE 48

Example: Greedy Strategy

3 ˆ a1 Heuristic says, “Allocate , and bind 3.” ˆ a2

slide-49
SLIDE 49

Example: Greedy Strategy

3 ˆ a1 ˆ a2 Heuristic says, “Allocate , and bind 3.” ˆ a2

slide-50
SLIDE 50

Example: Greedy Strategy

3 ˆ a1 ˆ a2 Adaptive allocator says, “Just use .” ˆ a1 Heuristic says, “Allocate , and bind 3.” ˆ a2

slide-51
SLIDE 51

Example: Greedy Strategy

3 ˆ a1 Adaptive allocator says, “Just use .” ˆ a1 Heuristic says, “Allocate , and bind 3.” ˆ a2

slide-52
SLIDE 52

Dynamic Optimization

Given m abstract addresses, how should they be allocated to maximize precision?

slide-53
SLIDE 53

So, why not?

Can’t within confines of standard recipe. (Counter-example in paper.)

slide-54
SLIDE 54

Making it so

slide-55
SLIDE 55
  • Factor allocation out of semantics.
  • Make allocation nondeterministic.
  • Prove nondeterministic allocation sound.

Making it so

slide-56
SLIDE 56

Locative = Address

(But also times, bindings, contours, etc.)

slide-57
SLIDE 57

Factoring out allocation

slide-58
SLIDE 58

ς

f : State → State

slide-59
SLIDE 59

ς ς′

f : State → State

slide-60
SLIDE 60

ς

f : State → State

slide-61
SLIDE 61

ς

F : State → Loc → State

slide-62
SLIDE 62

ς

F : State → Loc → State

slide-63
SLIDE 63

ς ς′ ℓ

F : State → Loc → State

slide-64
SLIDE 64

ˆ ς

ˆ f : State → 2

  • State
slide-65
SLIDE 65

ˆ ς ˆ ς′ ˆ ς′′ ˆ ς′′′

ˆ f : State → 2

  • State
slide-66
SLIDE 66

ˆ ς

ˆ f : State → 2

  • State
slide-67
SLIDE 67

ˆ ς

ˆ F : State → 2

d Loc→ State

slide-68
SLIDE 68

ˆ ς

ˆ F : State → 2

d Loc→ State

slide-69
SLIDE 69

ˆ ς ˆ ς′ ˆ ς′′ ˆ ς′′′

ˆ F : State → 2

d Loc→ State

ˆ ℓ′ ˆ ℓ′′′ ˆ ℓ′′

slide-70
SLIDE 70

Nondeterministic Abstract Interpretation

slide-71
SLIDE 71
  • Sealed abstract transition graphs.
  • Factored abstraction maps.
  • A posteriori soundness condition.

Nondeterministic Abstract Interpretation

slide-72
SLIDE 72

Transition Graphs

  • Nodes = States
  • Edge = Transition labeled by chosen locative
slide-73
SLIDE 73

Sealed Graphs

Graph is sealed under factored semantics iff every state has an edge to cover every transition.

slide-74
SLIDE 74

Example: Unsealed Graph

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 73 28 74 29 30 31 32 33 34 35 36 38 37 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 63 59 64 60 61 62 65 66 67 68 69 70 71 72 75 76 77 78 79 80 81 82
slide-75
SLIDE 75

Example: Unsealed Graph

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 73 28 74 29 30 31 32 33 34 35 36 38 37 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 63 59 64 60 61 62 65 66 67 68 69 70 71 72 75 76 77 78 79 80 81 82
slide-76
SLIDE 76

ˆ ℓ1 ˆ ℓ2 ˆ ς

slide-77
SLIDE 77

ˆ ℓ1 ˆ ℓ2 ˆ h1(ˆ ℓ1) ˆ h2(ˆ ℓ2) ˆ F(ˆ ς) = {ˆ h1, ˆ h2, ˆ h3} ˆ ς

slide-78
SLIDE 78

ˆ ℓ1 ˆ ℓ2 ˆ h1(ˆ ℓ1) ˆ h2(ˆ ℓ2)

?

ˆ F(ˆ ς) = {ˆ h1, ˆ h2, ˆ h3} ˆ ς

slide-79
SLIDE 79

Proving Sealed Graphs Sound

slide-80
SLIDE 80

Factoring Abstraction

α : State → State

slide-81
SLIDE 81

Factoring Abstraction

α : State → State β : (Loc → Loc) → (State → State)

slide-82
SLIDE 82

Dependent Simulation

slide-83
SLIDE 83

Dependent Simulation

ς

slide-84
SLIDE 84

Dependent Simulation

ς ς′ ℓ

slide-85
SLIDE 85

Dependent Simulation

ς ˆ ς′ ς′ ℓ β(αLoc[ℓ → ˆ ℓ])

slide-86
SLIDE 86

Dependent Simulation

ς ˆ ς ˆ ς′ ς′ ℓ ˆ ℓ β(αLoc) β(αLoc[ℓ → ˆ ℓ])

slide-87
SLIDE 87

A Posteriori Theorem

Dependent simulation → Abstraction always exists

slide-88
SLIDE 88

Proof Highlights

  • Reduces to existence of locative abstractor.
  • Construct abstractor as limit of sequence:

αLoc = lim

i→N αi Loc

slide-89
SLIDE 89

More in the paper

  • Nondeterministic CFA: ∃CFA.
  • More on greedy adaptive allocation.
  • Discussion of global precision sensitivity.
slide-90
SLIDE 90

Ongoing Work

  • Empirical trials: 1.5x - 3x space, time savings
  • Genetic algorithms
  • Probabilistic allocation
slide-91
SLIDE 91

So...

  • Stop changing concrete semantics.
  • Look beyond context for allocation.
  • Don’t allocate context if bad for precision.
slide-92
SLIDE 92

Thanks, y’all