+ All Categories
Home > Documents > Modular Shape Analysis for Dynamically Encapsulated Programs

Modular Shape Analysis for Dynamically Encapsulated Programs

Date post: 19-Mar-2016
Category:
Upload: mercer
View: 55 times
Download: 2 times
Share this document with a friend
Description:
Modular Shape Analysis for Dynamically Encapsulated Programs. Noam Rinetzky Tel Aviv University Arnd Poetzsch-Heffter Universität Kaiserlauten Ganesan Ramalingam Microsoft Research India Mooly Sagiv Tel Aviv University Eran Yahav IBM Watson. modular shape analysis. - PowerPoint PPT Presentation
Popular Tags:
73
Modular Shape Analysis for Dynamically Encapsulated Programs Noam Rinetzky Tel Aviv University Arnd Poetzsch-Heffter Universität Kaiserlauten Ganesan Ramalingam Microsoft Research India Mooly Sagiv Tel Aviv University Eran Yahav IBM Watson
Transcript
Page 1: Modular Shape Analysis for Dynamically Encapsulated Programs

Modular Shape Analysisfor Dynamically Encapsulated Programs

Noam Rinetzky Tel Aviv University

Arnd Poetzsch-Heffter Universität Kaiserlauten Ganesan Ramalingam Microsoft Research IndiaMooly Sagiv Tel Aviv University Eran Yahav IBM Watson

Page 2: Modular Shape Analysis for Dynamically Encapsulated Programs

modular shape analysis

shape analysis?

...

modular analysis?

Page 3: Modular Shape Analysis for Dynamically Encapsulated Programs

modular shape analysis

sound static analysis programs

imperative heap-manipulating

properties no memory errors

no memory leaks no null dereferences

shape invariants lists are acyclic

shape analysis

...

Page 4: Modular Shape Analysis for Dynamically Encapsulated Programs

modular shape analysis

analyze a program by analyzing its parts scalability reusability

modular analysis

Page 5: Modular Shape Analysis for Dynamically Encapsulated Programs

modular shape analysis

sound static analysis programs

imperative heap-manipulating

properties no memory errors

no memory leaks no null dereferences

shape invariants lists are acyclic

analyze a program by analyzing its parts scalability reusability

shape analysis

...

modular analysis

Page 6: Modular Shape Analysis for Dynamically Encapsulated Programs

p

analyze programs by analyzing their parts imperative heap-manipulating

modular shape analysis

qPolygon List

Point Integer

memoryprogram

Page 7: Modular Shape Analysis for Dynamically Encapsulated Programs

p

analyze programs by analyzing their partsprogram modular analysisheap modular analysis

modular shape analysis

qPolygon List

Point Integer

program parts memoryprogram memory parts

imperative heap-manipulating

Page 8: Modular Shape Analysis for Dynamically Encapsulated Programs

p

q

analyze programs by analyzing their partsprogram modular analysisheap modular analysis

modular shape analysis

Polygon List

Point Integer

program part relevant heap parts

Page 9: Modular Shape Analysis for Dynamically Encapsulated Programs

p

q

analyze programs by analyzing their partsprogram modular analysisheap modular analysis

modular shape analysis

Polygon List

Point Integer

program part relevant heap parts

Page 10: Modular Shape Analysis for Dynamically Encapsulated Programs

analyze programs by analyzing their partsprogram modular analysisheap modular analysis

modular shape analysis

Polygon List

Point Integer

p

q

program part relevant heap parts

Page 11: Modular Shape Analysis for Dynamically Encapsulated Programs

analyze programs by analyzing their partsprogram modular analysisheap modular analysis

modular shape analysis

Polygon List

Point Integer

p

q

program part relevant heap parts

Page 12: Modular Shape Analysis for Dynamically Encapsulated Programs

analyze programs by analyzing their partsprogram modular analysisheap modular analysis

modular shape analysis

Polygon List

Point Integer

program

Page 13: Modular Shape Analysis for Dynamically Encapsulated Programs

approach

restrict class of programs to “well behaved” programs dynamically encapsulated programs

compute conditional module invariant approximate “well behaved” clients

use dynamic encapsulation to enable modular shape analysis, use shape analysis to verify dynamic encapsulation

Page 14: Modular Shape Analysis for Dynamically Encapsulated Programs

agenda

setting shape abstraction modular shape analysis

Page 15: Modular Shape Analysis for Dynamically Encapsulated Programs

modules simple program model

program = collection of modules module = types + procedures

module level access control

......

Listtype List { Node

hd }type Node { Node n, Point

d}int foo(List s) { Point p = p.d; int x = getX(p);}

p.x;

...

...

int getX(Point p) { Integer I = p.x; return value(I);}

Pointtype Point {Integer

x,y }Point point(int x, int y)

{}

types

procedures

Page 16: Modular Shape Analysis for Dynamically Encapsulated Programs

p

q

Polygon List

Point Integer

Polygon

Point Integer

module-local state

module can only access parts of the heap comprised of its objects

Page 17: Modular Shape Analysis for Dynamically Encapsulated Programs

module-local state

p

q

Polygon List

Point Integer

module can only access parts of the heap comprised of its objects

Page 18: Modular Shape Analysis for Dynamically Encapsulated Programs

components

Polygon List

Point Integer

p

q

sub-heaps objects of one module

maximal connected subheap outgoing references incoming references

p

q

Page 19: Modular Shape Analysis for Dynamically Encapsulated Programs

components

Polygon List

Point Integer

sub-heaps objects of one module

maximal connected subheap outgoing references incoming references

List

Point

p

q

Page 20: Modular Shape Analysis for Dynamically Encapsulated Programs

component graphs nodes: components edges: inter-component references

p

q

Polygon List

Point Integer

Polygon

Point Integer

Page 21: Modular Shape Analysis for Dynamically Encapsulated Programs

(un)sealed components unsealed component mutable sealed component immutable

p

q

Polygon List

Point Integer

Polygon

Point Integer

Page 22: Modular Shape Analysis for Dynamically Encapsulated Programs

trimming abstraction

represents only components of a single module forget other components forget component graph

Page 23: Modular Shape Analysis for Dynamically Encapsulated Programs

trimming: abstractiont

z

Page 24: Modular Shape Analysis for Dynamically Encapsulated Programs

trimming: concretization

t

z

t

z

t

z

Page 25: Modular Shape Analysis for Dynamically Encapsulated Programs

t

z

t

z

trimming: concretization

Page 26: Modular Shape Analysis for Dynamically Encapsulated Programs

t

z

t

z

trimming: concretization

Page 27: Modular Shape Analysis for Dynamically Encapsulated Programs

t

z

t

z

trimming: impossible concretization

Page 28: Modular Shape Analysis for Dynamically Encapsulated Programs

bounding abstraction (standard)

q ztrimming

bounding

q

z ...

Page 29: Modular Shape Analysis for Dynamically Encapsulated Programs

parametric shape abstraction

concrete states

trimmed states

bounded trimmed states

trimMtrim

M

boundMbound

M

Page 30: Modular Shape Analysis for Dynamically Encapsulated Programs

modular shape analysis

main challenges inferring precondition for inter-module

procedure calls to the moduledetermining effect of inter-module procedure

calls by the module

Page 31: Modular Shape Analysis for Dynamically Encapsulated Programs

inter-module procedure calls sealed component immutable unsealed component mutable

Polygon List

Point Integer

Polygon

Point Integer

list_proc(p.list, q)

q

p

Page 32: Modular Shape Analysis for Dynamically Encapsulated Programs

sealed components

Polygon

Point Integer

Polygon

s

list_proc(p.list, q)

e

sealed component immutable inputs to inter-module procedure calls

q

ListList

Page 33: Modular Shape Analysis for Dynamically Encapsulated Programs

module invariant set of sealed (stable) components

in all programs in all executions

all possible inputs to inter-module procedure calls

Page 34: Modular Shape Analysis for Dynamically Encapsulated Programs

modular shape analysis infer module invariant analysis

compute input states to inter-module procedure calls

from discovered sealed components

shape analysis within module

discover new sealed components in output states

shapeanalysis

Page 35: Modular Shape Analysis for Dynamically Encapsulated Programs

abstraction + fixpoint are we done?

Page 36: Modular Shape Analysis for Dynamically Encapsulated Programs

sanity check

Listtype List { Node hd }type Node { Node n, Point d}void push(List s, Node e) { e.n = s.hd; s.hd = e;}

...

Page 37: Modular Shape Analysis for Dynamically Encapsulated Programs

sanity check

hd n n

d d d

s

de

n

Listtype List { Node hd }type Node { Node n, Point d}void push(List s, Node e) { e.n = s.hd; s.hd = e;}

...

Page 38: Modular Shape Analysis for Dynamically Encapsulated Programs

sanity check

hd n n

d d d

s

de

ne

Listtype List { Node hd }type Node { Node n, Point d}void push(List s, Node e) { e.n = s.hd; s.hd = e;}

...

Page 39: Modular Shape Analysis for Dynamically Encapsulated Programs

main difficulty: unknown usage

unknown heap context returned references incoming references

worst case assumption

complicated analysis expensive analysis non-useful analysis

hd n n

d d d

d

n

Page 40: Modular Shape Analysis for Dynamically Encapsulated Programs

our approach

limit inter-component aliasingevery sealed component has a single entry point

q p

Page 41: Modular Shape Analysis for Dynamically Encapsulated Programs

limit inter-component aliasingevery sealed component has a single entry point tree of inter-component references

p q

our approach

Page 42: Modular Shape Analysis for Dynamically Encapsulated Programs

enque(p,q)challenge: reference parameterssolution: ignore unused references

p q

challenge

verify q is never used!

Page 43: Modular Shape Analysis for Dynamically Encapsulated Programs

specify deadnessenque(List s, Node e) // {e}

p q

lightweight annotations

Page 44: Modular Shape Analysis for Dynamically Encapsulated Programs

limit inter-component aliasingevery component has a single entry point tree of inter-component references ignoring not to be used references

p q

dynamic encapsulation

Page 45: Modular Shape Analysis for Dynamically Encapsulated Programs

dynamic encapsulation p

Page 46: Modular Shape Analysis for Dynamically Encapsulated Programs

dynamic encapsulation p p

Page 47: Modular Shape Analysis for Dynamically Encapsulated Programs

dynamic encapsulation p p

p q

Page 48: Modular Shape Analysis for Dynamically Encapsulated Programs

dynamic encapsulation p p

p p q q

Page 49: Modular Shape Analysis for Dynamically Encapsulated Programs

sanity check revisited

Listtype List { Node hd }type Node { Node n, Point d}void push(List s, Node e) //

{e} { e.n = s.hd; s.hd = e;}

...

hd n n

d d d

s

de

Page 50: Modular Shape Analysis for Dynamically Encapsulated Programs

sanity check revisited

hd n n

d d d

s

de

n

...

Listtype List { Node hd }type Node { Node n, Point d}void push(List s, Node e) //

{e} { e.n = s.hd; s.hd = e;}

Page 51: Modular Shape Analysis for Dynamically Encapsulated Programs

sanity check revisited

hd n n

d d d

s

de

n

...

Listtype List { Node hd }type Node { Node n, Point d}void push(List s, Node e) //

{e} { e.n = s.hd; s.hd = e;}

Page 52: Modular Shape Analysis for Dynamically Encapsulated Programs

our approach

concentrate on well-behaved programs“well behaved” = dynamic encapsulation

modularly checkableprogram P is well behave if all its modules

respect the specification

Page 53: Modular Shape Analysis for Dynamically Encapsulated Programs

for every module assume all other modules are well behavedguarantee module is well behaved

verify dynamic encapsulation discover (conditional) module invariants

may not be hold for arbitrary programs

modular analysis

Page 54: Modular Shape Analysis for Dynamically Encapsulated Programs

summary

parametric shape abstraction dynamic encapsulation

restriction on programs modular shape analysis

shape analysis dynamic

encapsulation

enable

verify modular

Page 55: Modular Shape Analysis for Dynamically Encapsulated Programs

related work

modular analysis modular heap analysis shape analysis interprocedural shape analysis encapsulation local reasoning

Page 56: Modular Shape Analysis for Dynamically Encapsulated Programs

closely related work

modular heap analysisLogozzo, SAS’03, VMCAI’04Wies et al., VMCAI’06

encapsulationZaho et al., RTSS’04Clarke et al., ECOOP’03

modular verificationLeino et al., ESOP’06

Page 57: Modular Shape Analysis for Dynamically Encapsulated Programs

future work

relax restrictions richer component-graph structures

implementation

Page 58: Modular Shape Analysis for Dynamically Encapsulated Programs

END

use dynamic encapsulation to enable modular shape analysis, use shape analysis to verify dynamic encapsulation

Page 59: Modular Shape Analysis for Dynamically Encapsulated Programs

fixpoint

Page 60: Modular Shape Analysis for Dynamically Encapsulated Programs

dry run

analysis

Listtype List { Node hd }type Node { Node n, Point d}List crtList() { ... }Node crtNode(Point p) // {p }{ ... }void push(List s, Node e) //

{ e }{ ... }Node pop(List s) { ... }

Page 61: Modular Shape Analysis for Dynamically Encapsulated Programs

dry run

analysis

Listtype List { Node hd }type Node { Node n, Point d}List crtList() { ... }Node crtNode(Point p) // {p }{ ... }void push(List s, Node e) //

{ e }{ ... }Node pop(List s) { ... }

p

p

Page 62: Modular Shape Analysis for Dynamically Encapsulated Programs

dry run

analysis

Listtype List { Node hd }type Node { Node n, Point d}List crtList() { ... }Node crtNode(Point p) // {p }{ ... }void push(List s, Node e) //

{ e }{ ... }Node pop(List s) { ... }

s e

s e

Page 63: Modular Shape Analysis for Dynamically Encapsulated Programs

dry run

analysis

Listtype List { Node hd }type Node { Node n, Point d}List crtList() { ... }Node crtNode(Point p) // {p }{ ... }void push(List s, Node e) //

{ e }{ ... }Node pop(List s) { ... }

s e

s e...

Page 64: Modular Shape Analysis for Dynamically Encapsulated Programs

conditional module invariant program dynamically-encapsulated module invariant holds

Page 65: Modular Shape Analysis for Dynamically Encapsulated Programs

partitioned module invariant

Page 66: Modular Shape Analysis for Dynamically Encapsulated Programs

partitioned module invariant

Page 67: Modular Shape Analysis for Dynamically Encapsulated Programs

partitioned module invariant

Page 68: Modular Shape Analysis for Dynamically Encapsulated Programs

related work

Page 69: Modular Shape Analysis for Dynamically Encapsulated Programs

Manevich et al., TACAS’07

x x

zy

y z x

y

z

Page 70: Modular Shape Analysis for Dynamically Encapsulated Programs

ownership types

p

Page 71: Modular Shape Analysis for Dynamically Encapsulated Programs

trace

Page 72: Modular Shape Analysis for Dynamically Encapsulated Programs

inter-module procedure calls input: sealed component observation: unmodified since last call

Page 73: Modular Shape Analysis for Dynamically Encapsulated Programs

inter-module procedure calls input: sealed component observation: unmodified since last call


Recommended