A Parametric Segmentation Functor for Fully Automatic and Scalable Array Content Analysis Patrick Cousot, NYU & ENS Radhia Cousot, CNRS & ENS & MSR Francesco.

Slides:



Advertisements
Similar presentations
Meta Predicate Abstraction for Hierarchical Symbolic Heaps Josh Berdine Microsoft Research, Cambridge joint with Mike Emmi University of California, Los.
Advertisements

De necessariis pre condiciones consequentia sine machina P. Consobrinus, R. Consobrinus M. Aquilifer, F. Oratio.
Modular and Verified Automatic Program Repair Francesco Logozzo, Thomas Ball RiSE - Microsoft Research Redmond.
An Abstract Interpretation Framework for Refactoring P. Cousot, NYU, ENS, CNRS, INRIA R. Cousot, ENS, CNRS, INRIA F. Logozzo, M. Barnett, Microsoft Research.
School of EECS, Peking University “Advanced Compiler Techniques” (Fall 2011) SSA Guo, Yao.
Abstraction and Modular Reasoning for the Verification of Software Corina Pasareanu NASA Ames Research Center.
Pointer Analysis – Part I Mayur Naik Intel Research, Berkeley CS294 Lecture March 17, 2009.
CodeContracts & Clousot Francesco Logozzo - Microsoft Mehdi Bouaziz – ENS.
1 PROPERTIES OF A TYPE ABSTRACT INTERPRETATER. 2 MOTIVATION OF THE EXPERIMENT § a well understood case l type inference in functional programming à la.
1 1 Regression Verification for Multi-Threaded Programs Sagar Chaki, SEI-Pittsburgh Arie Gurfinkel, SEI-Pittsburgh Ofer Strichman, Technion-Haifa Originally.
1 How to transform an analyzer into a verifier. 2 OUTLINE OF THE LECTURE a verification technique which combines abstract interpretation and Park’s fixpoint.
Inferring Disjunctive Postconditions Corneliu Popeea and Wei-Ngan Chin School of Computing National University of Singapore - ASIAN
© Anvesh Komuravelli Quantified Invariants in Rich Domains using Model Checking and Abstract Interpretation Anvesh Komuravelli, CMU Joint work with Ken.
August Moscow meeting1August Moscow meeting1August Moscow meeting11 Deductive tools in insertion modeling verification A.Letichevsky.
Abstract Data Types Data abstraction, or abstract data types, is a programming methodology where one defines not only the data structure to be used, but.
Relational Inductive Shape Analysis Bor-Yuh Evan Chang University of California, Berkeley Xavier Rival INRIA POPL 2008.
Rahul Sharma Işil Dillig, Thomas Dillig, and Alex Aiken Stanford University Simplifying Loop Invariant Generation Using Splitter Predicates.
Lifting Abstract Interpreters to Quantified Logical Domains Sumit Gulwani, MSR Bill McCloskey, UCB Ashish Tiwari, SRI 1.
Francesco Logozzo Microsoft Research, Redmond, WA.
CS 330 Programming Languages 10 / 16 / 2008 Instructor: Michael Eckmann.
Program analysis Mooly Sagiv html://
Program analysis Mooly Sagiv html://
1 Control Flow Analysis Mooly Sagiv Tel Aviv University Textbook Chapter 3
Houdini: An Annotation Assistant for ESC/Java Cormac Flanagan and K. Rustan M. Leino Compaq Systems Research Center.
Search in the semantic domain. Some definitions atomic formula: smallest formula possible (no sub- formulas) literal: atomic formula or negation of an.
Last time Proof-system search ( ` ) Interpretation search ( ² ) Quantifiers Equality Decision procedures Induction Cross-cutting aspectsMain search strategy.
C# Programming: From Problem Analysis to Program Design1 Advanced Object-Oriented Programming Features C# Programming: From Problem Analysis to Program.
1 Program Analysis Systematic Domain Design Mooly Sagiv Tel Aviv University Textbook: Principles.
1 Type Type system for a programming language = –set of types AND – rules that specify how a typed program is allowed to behave Why? –to generate better.
1 ES 314 Advanced Programming Lec 2 Sept 3 Goals: Complete the discussion of problem Review of C++ Object-oriented design Arrays and pointers.
1/25 Pointer Logic Changki PSWLAB Pointer Logic Daniel Kroening and Ofer Strichman Decision Procedure.
Chapter 6Java: an Introduction to Computer Science & Programming - Walter Savitch 1 l Array Basics l Arrays in Classes and Methods l Programming with Arrays.
DySy: Dynamic Symbolic Execution for Invariant Inference.
Pentagons: A Weakly Relational Abstract Domain for the Efficient Validation of Array Accesses Francesco Logozzo, Manuel Fahndrich Microsoft Research, Redmond.
Compiler Construction Lecture 16 Data-Flow Analysis.
Java Generics.
1 Week 9 l Array Basics l Arrays in Classes and Methods l Programming with Arrays and Classes l Sorting Arrays l Multidimensional Arrays Arrays.
Inference and Checking of Object Ownership Wei Huang 1, Werner Dietl 2, Ana Milanova 1, Michael D. Ernst 2 1 Rensselaer Polytechnic Institute 2 University.
Program Analysis with Dynamic Change of Precision Dirk Beyer Tom Henzinger Grégory Théoduloz Presented by: Pashootan Vaezipoor Directed Reading ASE 2008.
Program Analysis and Verification Spring 2014 Program Analysis and Verification Lecture 14: Numerical Abstractions Roman Manevich Ben-Gurion University.
© ETH Zürich Eric Lo ETH Zurich a joint work with Carsten Binnig (U of Heidelberg), Donald Kossmann (ETH Zurich), Tamer Ozsu (U of Waterloo) and Peter.
Programming Languages by Ravi Sethi Chapter 6: Groupings of Data and Operations.
Data TypestMyn1 Data Types The type of a variable is not set by the programmer; rather, it is decided at runtime by PHP depending on the context in which.
Formal Specification of Intrusion Signatures and Detection Rules By Jean-Philippe Pouzol and Mireille Ducassé 15 th IEEE Computer Security Foundations.
CS 361 – Chapters 8-9 Sorting algorithms –Selection, insertion, bubble, “swap” –Merge, quick, stooge –Counting, bucket, radix How to select the n-th largest/smallest.
Object Oriented Software Development
(c) University of Washington15-1 CSC 143 Java List Implementation via Arrays Reading: 13.
Program Analysis and Verification Spring 2015 Program Analysis and Verification Lecture 12: Abstract Interpretation IV Roman Manevich Ben-Gurion University.
Chapter 8 Class Inheritance and Interfaces F Superclasses and Subclasses  Keywords: super F Overriding methods  The Object Class  Modifiers: protected,
Programming Techniques Lec03 Procedural Abstraction Software Engineering Fall 2005.
Generating Precise and Concise Procedure Summaries Greta Yorsh Eran Yahav Satish Chandra.
1 Combining Abstract Interpreters Mooly Sagiv Tel Aviv University
Pointer Analysis – Part I CS Pointer Analysis Answers which pointers can point to which memory locations at run-time Central to many program optimization.
Quantified Data Automata on Skinny Trees: an Abstract Domain for Lists Pranav Garg 1, P. Madhusudan 1 and Gennaro Parlato 2 1 University of Illinois at.
Java & C++ Comparisons How important are classes and objects?? What mechanisms exist for input and output?? Are references and pointers the same thing??
1 Numeric Abstract Domains Mooly Sagiv Tel Aviv University Adapted from Antoine Mine.
IBM Labs in Haifa © 2005 IBM Corporation Assumption-based Pruning in Conditional CSP Felix Geller and Michael Veksler.
CSC 243 – Java Programming, Spring, 2014 Week 4, Interfaces, Derived Classes, and Abstract Classes.
1 Compiler Construction Run-time Environments,. 2 Run-Time Environments (Chapter 7) Continued: Access to No-local Names.
Bill J. Ellis Dependable Systems Group Heriot-Watt University (Project page: Proving Exception.
CORRECTNESS ISSUES AND LOOP INVARIANTS Lecture 8 CS2110 – Fall 2014.
Memory Management.
Lifting Abstract Interpreters to Quantified Logical Domains (POPL’08)
Data Types In Text: Chapter 6.
Spring 2016 Program Analysis and Verification
Spring 2016 Program Analysis and Verification
Symbolic Implementation of the Best Transformer
Abstract Class As per dictionary, abstraction is the quality of dealing with ideas rather than events. For example, when you consider the case of ,
Reduction in End-User Shape Analysis
Flow Analysis Data-flow analysis, Control-flow analysis, Abstract interpretation, AAM.
Presentation transcript:

A Parametric Segmentation Functor for Fully Automatic and Scalable Array Content Analysis Patrick Cousot, NYU & ENS Radhia Cousot, CNRS & ENS & MSR Francesco Logozzo, MSR

public void Init(int[] a) { Contract.Requires(a.Length > 0); var j = 0; while (j < a.Length) { a[j] = 11; j++; } // here: ∀ k.0≤k<j ⇒ a[k]=11 } if j = 0 then a[0] … not known else if j > 0 ∧ j ≤ a.Length a[0] = … a[j-1] = 11 else impossible if j = 0 then a[0] … not known else if j > 0 ∧ j ≤ a.Length a[0] = … a[j-1] = 11 else impossible Challenge 2: Handling of disjunction Challenge 2: Handling of disjunction Challenge 1: All the elements are initialized Challenge 1: All the elements are initialized

Precision Scalability

Functor abstract domain by example

public void Init(int[] a) { Contract.Requires(a.Length > 0); var j = 0; while (j < a.Length) { a[j] = 11; j++; } Segment limits Segment abstraction Possibly empty segment Possibly empty segment

public void Init(int[] a) { Contract.Requires(a.Length > 0); var j = 0; while (j < a.Length) { a[j] = 11; j++; } Remove doubt

public void Init(int[] a) { Contract.Requires(a.Length > 0); var j = 0; while (j < a.Length) { a[j] = 11; j++; } Scalar variables abstraction (omit a.Length ∈ [1, +∞)) Scalar variables abstraction (omit a.Length ∈ [1, +∞)) ∞ Record j = 0

public void Init(int[] a) { Contract.Requires(a.Length > 0); var j = 0; while (j < a.Length) { a[j] = 11; j++; }

public void Init(int[] a) { Contract.Requires(a.Length > 0); var j = 0; while (j < a.Length) { a[j] = 11; j++; } Materialize segment Introduce ‘?’

public void Init(int[] a) { Contract.Requires(a.Length > 0); var j = 0; while (j < a.Length) { a[j] = 11; j++; } Replace j by j-1

public void Init(int[] a) { Contract.Requires(a.Length > 0); var j = 0; while (j < a.Length) { a[j] = 11; j++; }

1.Unify the segments 2.Point-wise join Similar for order, meet and widening

public void Init(int[] a) { Contract.Requires(a.Length > 0); var j = 0; while (j < a.Length) { a[j] = 11; j++; }

public void Init(int[] a) { Contract.Requires(a.Length > 0); var j = 0; while (j < a.Length) { a[j] = 11; j++ } Remove ‘?'

public void Init(int[] a) { Contract.Requires(a.Length > 0); var j = 0; while (j < a.Length) { a[j] = 11; j++; }

public void Init(int[] a) { Contract.Requires(a.Length > 0); var j = 0; while (j < a.Length) { a[j] = 11; j++; }

public void Init(int[] a) { Contract.Requires(a.Length > 0); var j = 0; while (j < a.Length) { a[j] = 11; j++; }

public void Init(int[] a) { Contract.Requires(a.Length > 0); var j = 0; while (j < a.Length) { a[j] = 11; j++; }

public void Init(int[] a) { Contract.Requires(a.Length > 0); var j = 0; while (j < a.Length) { a[j] = 11; j++; } // here j ≥ a.Length } Remove the empty segment

Abstract Semantics

Given an abstract domain B for bounds S for segments E for scalar variables environment Constructs an abstract domain F(B, S, E) to analyze programs with arrays (Main) Advantages Fine tuning of the precision/cost ratio Easy lifting of existing analyses

Sets of symbolic expressions In our examples: Exp := k | x | x + k Meaning: { e 0 … e n } { e’ 1 … e’ m } ≝ e 0 =… = e n < e’ 1 = … =e’ m { e 0 … e n } { e’ 1 … e’ m }? ≝ e 0 =… = e n ≤ e’ 1 = … =e’ m Possibly empty segments are key for scalability

public void CopyNonNull(object[] a, object[] b) { Contract.Requires(a.Length <= b.Length); var j = 0; for (var i = 0; i < a.Length; i++) { if (a[i] != null) { b[j] = a[i]; j++; } } Four partitions: j = 0 ∨ 0 ≤ j< b.Length-1 ∨ j = b.Length-1 ∨ j = b.Length Four partitions: j = 0 ∨ 0 ≤ j< b.Length-1 ∨ j = b.Length-1 ∨ j = b.Length

public void CopyNonNull(object[] a, object[] b) { Contract.Requires(a.Length <= b.Length); var j = 0; for (var i = 0; i < a.Length; i++) { if (a[i] != null) { b[j] = a[i]; j++; } } Segmentation discovered by the analysis Segmentation discovered by the analysis

Uniform abstraction for pairs (i, a[i]) More general than usual McCarthy definition Wide choice of abstract domains Fine tuning the cost/precision ratio Ex: Cardinal power of constants by parity [CC79] public void EvenOdd(int n) { var a = new int[n]; var i = 0; while (i < n) { a[i++] = 1; a[i++] = -1; }

Given two segmentations, find a common segmentation Crucial for order/join/meet/widening: 1.Unify the segments 2.Apply the operation point-wise In the concrete, a lattice of solutions In the abstract, a partial order of solutions Our algorithm tuned up by examples Details in the paper

Search the bounds for exp The search queries the scalar environment σ More precision A form of abstract domains reduction Set σ ’= σ [x ↦ A n ⊔ … ⊔ A m-1 ]

Search the bounds for exp Join the segments Split the segment Adjust emptiness May query scalar variables environment

Invertible assignment x = g(x) Replace x by g -1 (x) in all the segments Non-Invertible assignment x = g() Remove x in all the segments Remove all the empty segments Add x to all the bounds containing g()

Assume x == y Search for segments containing x/y Add y/x to them Assume x < y Adjust emptiness Assume x ≤ y Does the state implies x ≥ y ? If yes, Assume x == y Assumptions involving arrays similar

Fully implemented in CCCheck Static checker for CodeContracts Users: Professional programmers Array analysis completely transparent to users No parameters to tweak, templates, partitions … Instantiated with Expressions = Simple expressions (this talk) Segments = Intervals + NotNull + Weak bounds Environment = CCCheck default

Main.NET v2.0 Framework libraries Un-annotated code Analyzes itself at each build (0 warnings) 5297 lines of annotated C#

Inference of quantified preconditions See our VMCAI’11 Paper Handling of multi-dimensional matrixes With auto-application Inference of existential ∀∃ facts When segments interpreted existentially Array purity check The callee does not modify a sub-array …

Fully Automatic Once the functor is instantiated No hidden hypotheses Compact representation for disjunction Enables Scalability Precision/Cost ratio tunable Refine the functor parameters Refine the scalar abstract environment Used everyday in an industrial analyzer 1% Overhead on average

Backup slides

No [GRS05] and [HP07] They require a pre-determined array partition Main weakness of their approach Our segmentation is inferred by the analysis Totally automatic They explicitly handle disjunctions We have possibly empty segments

Orthogonal issue In the implementation in CCCheck Havoc arrays passed as parameters Assignment of unknown if by ref of one element Assume the postcondition Array element passed by ref Ex: f(ref a[x]) The same as assignment a[x] = Top Assume the postcondition

Orthogonal issue Depends on the underlying heap analysis In CCCheck: Optimistic hypotheses on non-aliasing FunArray easily fits in other heap models