Lightweight Verification of Array Indexing
Martin Kellogg*, Vlastimil Dort**, Suzanne Millstein*, Michael D. Ernst*
* University of Washington, Seattle ** Charles University, Prague
Lightweight Verification of Array Indexing Martin Kellogg* , - - PowerPoint PPT Presentation
Lightweight Verification of Array Indexing Martin Kellogg* , Vlastimil Dort**, Suzanne Millstein*, Michael D. Ernst* * University of Washington, Seattle ** Charles University, Prague The problem: unsafe array indexing In unsafe
* University of Washington, Seattle ** Charles University, Prague
crashes
2
3
Strength of guarantees Practical for developers
4
Strength of guarantees Practical for developers Coq KeY Clousot
5
Strength of guarantees Practical for developers Coq KeY Clousot FindBugs Coverity
6
Strength of guarantees Practical for developers Coq KeY Clousot FindBugs Coverity The Index Checker (this talk)
7
8
9
10
11
Solve all three problems:
12
Solve all three problems:
13
Solve all three problems:
14
Solve all three problems:
15
We need to show that:
16
We need to show that:
17
We need to show that:
A lower bound on i
An upper bound on i
18
T ↑ i ≥ -1 ↑ ↑ i ≥ 0 i ≥ 1
@LowerBoundUnknown int i
↑
@GTENegativeOne int i
↑ ↑
@NonNegative int i @Positive int i
19
T ↑ i ≥ -1 ↑ ↑ i ≥ 0 i ≥ 1
@LowerBoundUnknown int i
↑
@GTENegativeOne int i
↑ ↑
@NonNegative int i @Positive int i
20
if (i >= 0 && i < a.length) { a[i] = ... }
21
if (i >= 0 && i < a.length) { a[i] = ... }
22
i < a.length @LTLengthOf(“a”) int i
Linear inequalities i < j Minimum lengths a.length > 10 Negative indices | i | < a.length Lower bounds i ≥ 0 Equal lengths a.length = b.length Upper bounds i < a.length
23
Linear inequalities i < j Minimum lengths a.length > 10 Negative indices | i | < a.length Lower bounds i ≥ 0 Equal lengths a.length = b.length Upper bounds i < a.length
24
if (a.length >= 3) { a[2] = ...; }
25
if (a.length >= 3) { a[2] = ...; }
26
a.length ≥ i
T @MinLen(i) [] a
Three case studies:
Comparison to existing tools:
27
Guava JFreeChart plume-lib Total Lines of code 10,694 94,233 14,586 119,503 Bugs found 5 64 20 89 Annotations 510 2,938 241 3,689 False positives 138 386 43 567 Java casts 222 2,740 219 3,181
28
Tool Index Checker FindBugs KeY Clousot True Positives False Negatives Approach
Types Bug finder
Time (100k LoC)
29
Tool Index Checker FindBugs KeY Clousot True Positives False Negatives Approach
Types Bug finder
Time (100k LoC) ~10 minutes ~1 minute cannot scale ~200 minutes
30
Tool Index Checker FindBugs KeY Clousot True Positives
18/18 0/18 9/18 16/18
False Negatives
0/18 18/18 1/18 2/18
Approach
Types Bug finder
Time (100k LoC) ~10 minutes ~1 minute cannot scale ~200 minutes
31
www.checkerframework.org
32
codebases (and finding bugs in the process!)
33