Presentation is loading. Please wait.

Presentation is loading. Please wait.

Francesco Logozzo Microsoft Research, Redmond, WA.

Similar presentations


Presentation on theme: "Francesco Logozzo Microsoft Research, Redmond, WA."— Presentation transcript:

1 Francesco Logozzo Microsoft Research, Redmond, WA

2

3

4

5

6

7 A.dll B.dll Z.dll C.dll … Call Graph Construction Contract Extraction Analysis Inference Assertion Checking

8

9

10

11

12 Analyses Bounds, nonnull, arrays… Expression analysisHeap analysisStack analysis Source: z = x + y

13

14 MDTransform 9000 straight line instructions MDTransform

15

16

17 Pietro Ferrara, Francesco Logozzo and Manuel Fahndrich Safer Unsafe Code in.NET, in OOPSLA 2008

18

19 Intervals O(n) a ≤ x ≤ b No  Pentagons O(n) a≤ x ≤ b & x <y Yes Octagons O(n 3 ) ± x ± y ≤ a Yes Polyhedra O(2 n ) Σ a i x i ≤ b Yes

20 Domain D1 Domain D2 Domain D3

21

22 Vincent Laviron and Francesco Logozzo, Subpolyhedra: A (more) scalable approach to the inference of linear inequalities, in VMCAI 2009

23 assume x <= yx = 0; y = 1 assert x <= y 〈 x - y == β, β ∈ [- ∞, 0] 〉 〈 T, x ∈ [0,0] ⋀ y ∈ [1,1] 〉 〈 T, T 〉

24 Vincent Laviron and Francesco Logozzo, Refining Abstract Interpretation- based Static Analyses with Hints, in APLAS 2009

25

26

27 assume x == yx = 0; y = 1 assert x<= y 〈 x - y == 0, T 〉 〈 T, x ∈ [0,0] ⋀ y ∈ [1,1] 〉 〈 T, T 〉 〈 x - y == β, β ∈ [- 1, 0] 〉

28

29

30

31 public void Init(int N) { Contract.Requires(N > 0); int[] a = new int[N]; int i = 0; while (i < N) { a[i] = 222; i = i + 1; } Contract.Assert( ∀ k ∈ [0, N). a[k] == 222); } public void Init(int N) { Contract.Requires(N > 0); int[] a = new int[N]; int i = 0; while (i < N) { a[i] = 222; i = i + 1; } Contract.Assert( ∀ k ∈ [0, N). a[k] == 222); } If i == 0 then a not initialized a not initialized else if i > 0 a[0] == … a[i] == 222 a[0] == … a[i] == 222else impossible impossible If i == 0 then a not initialized a not initialized else if i > 0 a[0] == … a[i] == 222 a[0] == … a[i] == 222else impossible impossible Challenge 1: Effective handling of disjunction Challenge 1: Effective handling of disjunction Challenge 2: No overapproximation (can be unsound) (no hole, all the elements are initialized) Challenge 2: No overapproximation (can be unsound) (no hole, all the elements are initialized)

32 [222, 222] 00 i, k [0, 0] NN Segment bounds Uniform content abstraction ?? 0 i, 0 k 0 ≤ i, 0 ≤ k i == i == k i < N, k N i < N, k < N DisjunctionDisjunction

33 Contract.Requires(N > 0); int[] a = new int[N]; Contract.Requires(N > 0); int[] a = new int[N]; int i = 0; assume i < N a[i] = 222; assume i ≥ N j = i+1; i -> _ j -> i N -> N i -> _ j -> i N -> N 0000NN 000,i0,iNN 000,i0,iNN 2222220,i0,iNN001,i+11,i+1?? 2222220,i0,iNN001,i+1,j1,i+1,j?? 22222200NN001,i1,i??

34 000,i0,i NN22222200NN001,i1,i?? 00 00 NN ⊥ ⊥ii ??22222200NN001,i1,i?? 0000NN ⊥ ⊥ii??22222200NN00ii?? 22222200NN00ii???? Join Can be empty segments! (Disjunction)

35 Contract.Requires(N > 0); int[] a = new int[N]; Contract.Requires(N > 0); int[] a = new int[N]; int i = 0; assume i < N a[i] = 222; assume i ≥ N j = i+1; i -> _ j -> i N -> N i -> _ j -> i N -> N 22222200NN00ii???? 22222200NN00ii?? And so on up to a fixpoint … 22222200 i, N Remove doubts (i == N && N > 0) Remove doubts (i == N && N > 0) We visited all the elements in [0, N)

36

37

38

39

40 〈 T, x ∈ [0,1] ⋀ y ∈ [0,+ ∞ ] 〉 〈 T, x ∈ [0,0] ⋀ y ∈ [0,+ ∞ ] 〉 assume y >= 0 ; x = 0; while x < y x++;assert x == y ; 〈 T, x ∈ [0,0] ⋀ y ∈ [0,+ ∞ ] 〉 〈 T, x ∈ [0,0] ⋀ y ∈ [1,+ ∞ ] 〉 〈 T, x ∈ [1,1] ⋀ y ∈ [1,+ ∞ ] 〉 〈 T, x ∈ [0,0] ⋀ y ∈ [0,0] 〉 〈 x – y == β’, x ∈ [0,1] ⋀ y ∈ [0,1] ⋀ β’ ∈ [0,0] 〉 〈 x – y == β, x ∈ [0,1] ⋀ y ∈ [0,1] ⋀ β ∈ [0,+ ∞ ] 〉 〈 x – y == β’, x ∈ [0,1] ⋀ y ∈ [0,+ ∞ ] ⋀ β’ ∈ [- ∞, 0] 〉


Download ppt "Francesco Logozzo Microsoft Research, Redmond, WA."

Similar presentations


Ads by Google