Functor abstract domain by example

Similar documents
A Parametric Segmentation Functor for Fully Automatic and Scalable Array Content Analysis

A Parametric Segmentation Functor for Fully Automatic and Scalable Array Content Analysis

Lecture 6. Abstract Interpretation

Simplifying Loop Invariant Generation Using Splitter Predicates. Rahul Sharma Işil Dillig, Thomas Dillig, and Alex Aiken Stanford University

CodeContracts & Clousot. Francesco Logozzo - Microsoft Mehdi Bouaziz ENS

A Gentle Introduction to Program Analysis

Modular and Verified Automatic Program Repairs

Clousot: Static Contract Checking with Abstract Interpretation

COMP 507: Computer-Aided Program Design

Automatic Inference of Necessary Preconditions

The Apron Library. Bertrand Jeannet and Antoine Miné. CAV 09 conference 02/07/2009 INRIA, CNRS/ENS

Interval Polyhedra: An Abstract Domain to Infer Interval Linear Relationships

VS 3 : SMT Solvers for Program Verification

Advanced Programming Methods. Introduction in program analysis

Structuring an Abstract Interpreter through Value and State Abstractions: EVA, an Evolved Value Analysis for Frama C

Embedded Software Verification Challenges and Solutions. Static Program Analysis

Hierarchical Shape Abstraction of Dynamic Structures in Static Blocks

Types and Type Inference

Adam Chlipala University of California, Berkeley ICFP 2006

Formal Systems II: Applications

A Context-Sensitive Memory Model for Verification of C/C++ Programs

Principles of Program Analysis. Lecture 1 Harry Xu Spring 2013

SMT-Style Program Analysis with Value-based Refinements

Programming Languages Third Edition

The Rule of Constancy(Derived Frame Rule)

Hoare Logic: Proving Programs Correct

Modular and Verified Automatic Program Repair

Types and Type Inference

No model may be available. Software Abstractions. Recap on Model Checking. Model Checking for SW Verif. More on the big picture. Abst -> MC -> Refine

Logic-Flow Analysis of Higher-Order Programs

Softwaretechnik. Program verification. Albert-Ludwigs-Universität Freiburg. June 28, Softwaretechnik June 28, / 24

Overview. Verification with Functions and Pointers. IMP with assertions and assumptions. Proof rules for Assert and Assume. IMP+: IMP with functions

Static Analysis by A. I. of Embedded Critical Software

Verification Modulo Versions: Towards Usable Verification

Principles of Programming Languages

Inference of Necessary Field Conditions with Abstract Interpretation

Flow Analysis. Data-flow analysis, Control-flow analysis, Abstract interpretation, AAM

Lectures 20, 21: Axiomatic Semantics

PreInfer: Automatic Inference of Preconditions via Symbolic Analysis

A Framework for Numeric Analysis of Array Operations

Algebraic Program Analysis

Block-wise abstract interpretation by combining abstract domains with SMT

Program Verification (6EC version only)

CMSC 330: Organization of Programming Languages

Thursday, December 23, The attack model: Static Program Analysis

Lecture 10 Design by Contract

Abstract Semantic Differencing for Numerical Programs

Pietro Ferrara and Peter Müller

Christoph Csallner, University of Texas at Arlington (UTA)

Part II. Hoare Logic and Program Verification. Why specify programs? Specification and Verification. Code Verification. Why verify programs?

Chapter 3. Image Processing Methods. (c) 2008 Prof. Dr. Michael M. Richter, Universität Kaiserslautern

APA Interprocedural Dataflow Analysis

An Experimental Evaluation of Deliberate Unsoundness in a Static Program Analyzer

Sendmail crackaddr - Static Analysis strikes back

A New Abstraction Framework for Affine Transformers

Program Static Analysis. Overview

Assertions & Verification & Example Loop Invariants Example Exam Questions

Polyèdres et compilation

Separation Logic 2: project: Annotation Assistant for Partially Specified Programs plus some high-level observations. Hengle Jiang & John-Paul Ore

Quickly Detecting Relevant Program Invariants

Pawns: a declarative/imperative language

COSC252: Programming Languages: Semantic Specification. Jeremy Bolton, PhD Adjunct Professor

Assertions & Verification Example Exam Questions

Spark verification features

CS 6110 S14 Lecture 38 Abstract Interpretation 30 April 2014

Advanced Compiler Construction

Lecture 5 - Axiomatic semantics

Generating Small Countermodels. Andrew Reynolds Intel August 30, 2012

Intel Thread Building Blocks, Part II

G Programming Languages Spring 2010 Lecture 6. Robert Grimm, New York University

Harvard School of Engineering and Applied Sciences CS 152: Programming Languages

CS 161 Computer Security

BOOGIE. Presentation by Itsik Hefez A MODULAR REUSABLE VERIFIER FOR OBJECT-ORIENTED PROGRAMS MICROSOFT RESEARCH

Automated Refinement Checking of Asynchronous Processes. Rajeev Alur. University of Pennsylvania

Exercise 3 Subtyping and Behavioral Subtyping October 13, 2017

An Approach to Behavioral Subtyping Based on Static Analysis

Verifying Program Invariants with Refinement Types

Sorting L7.2 Recall linear search for an element in an array, which is O(n). The divide-and-conquer technique of binary search divides the array in ha

NAME (as it appears on your UF ID): (Please PRINT) CEN Software Engineering

Type checking. Jianguo Lu. November 27, slides adapted from Sean Treichler and Alex Aiken s. Jianguo Lu November 27, / 39

Foundations of AI. 9. Predicate Logic. Syntax and Semantics, Normal Forms, Herbrand Expansion, Resolution

Using widenings to infer loop invariants inside an SMT solver, or: A theorem prover as abstract domain

Overview of Clustering

Abstract Interpretation

Certified Memory Usage Analysis

Type assignment for intersections and unions in call-by-value languages

On Search Strategies for Constraint-Based Bounded Model Checking. Michel RUEHER

Symbolic Execution and Verification Conditions. Review of Verification Conditions. Survey from Homework 4. Time spent: 7.1 hrs (mean), 6 hrs (median)

Type Checking and Type Inference

Enhancing the Alloy Analyzer with Patterns of Analysis

4/24/18. Overview. Program Static Analysis. Has anyone done static analysis? What is static analysis? Why static analysis?

DPLL(Γ+T): a new style of reasoning for program checking

Faculty of Electrical Engineering, Mathematics, and Computer Science Delft University of Technology

Runtime Checking for Program Verification Systems

DySy: Dynamic Symbolic Execution for Invariant Inference

Multi-event IDS Categories. Introduction to Misuse Intrusion Detection Systems (IDS) Formal Specification of Intrusion Signatures and Detection Rules

A Scalable Segmented Decision Tree Abstract Domain

Weeks 6&7: Procedures and Parameter Passing

Code Contracts. Pavel Parízek. CHARLES UNIVERSITY IN PRAGUE faculty of mathematics and physics

Hoare logic. A proof system for separation logic. Introduction. Separation logic

Transcription:

A Parametric Segmentation Functor for Fully Automatic and Scalable Array Content Analysis Scalability Patrick Cousot, NYU & ENS Radhia Cousot, CNRS & ENS & MSR Francesco Logozzo, MSR Precision // 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 Functor abstract domain by example Challenge 1: All the elements are initialized Challenge 2: Handling of disjunction

0 Top a.length? Segment limits Segment abstraction Possibly empty segment 0,j Top a.length j:[0,0] Record j = 0 Scalar variables abstraction (omit a.length [1, + )) 0 Top a.length Remove doubt 0,j Top a.length j:[0,0]

0,j [11, 11] 1, j+1 Top a.length? j:[0,0] 0,j Top a.length j:[0,0] 0,j-1 [11, 11] 1, j Top a.length? j:[1,1] Materialize segment IІntroduce? 1. Unify the segments 0,j Top a.length 0,j-1 [11, 11] 1,j Top a.length? 0 j? Top a.length 0 [11, 11] j Top a.length? 0,j-1 [11, 11] 1,j Top a.length? j:[1,1] 2. Point-wise join 0 [11, 11] j? Top a.length? Replace j by j-1 Similar for order, meet and widening

0 [11, 11] j? Top a.length? j [0,1] 0 [11,11] j? [11,11] j+1 Top a.length? j [0,1] 0 [11, 11] j? Top a.length j [0,1] j++ Remove?' 0 [11,11] j-1? [11,11] j? Top a.length? j [1,2]

0 [11, 11] j? Top a.length? j [0,1] 0 [11,11] j-1? [11,11] j? Top a.length? j [1,2] // here j a.length 0 [11, 11] j? Top a.length? j [0,+ ) Remove the empty segment 0 [11, 11] j, a.length j [1,+ ) 0 [11, 11] j? Top a.length? j [0,+ ) 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 public void CopyNonNull(object[] a, object[] b) Contract.Requires(a.Length <= b.length); for (var i = 0; i < a.length; i++) if (a[i]!= null) b[j] = a[i]; Four partitions: j = 0 0 j< b.length-1 j = b.length-1 j = b.length 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); for (var i = 0; i < a.length; i++) if (a[i]!= null) b[j] = a[i]; 0 NotNull j? Top b.length? j [0,+ ) 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; 0 even 1 odd -1 i, n, a.length? i [0,+ ) Search the bounds for exp B n A n A m-1 B m σ The search queries the scalar environment σ More precision A form of abstract domains reduction Set σ = σ [x A n A m-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 B n A n A m-1 B m Join the segments B n A n.. A m-1 B m Split the segment B n A n.. A m-1 exp σ(x) exp+1 A n.. A m-1 B m 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() Fully implemented in CCCheck Static checker for CodeContracts Users: Professional programmers Array analysis completely transparent to users No parameters to tweak, templates, partiіtiіons Instantiated with Expressions = Simple expressions (this talk) Segments = Intervals + NotNull + Weak bounds Environment = CCCheck default 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 Main.NET v2.0 Framework libraries Un-annotated code Assembly # funcs base With functor Analyzes itself at each build (0 warnings) 5297 lines of annotated C# Δ # array invariants Mscorlib 21 475 4:06 4:15 0:09 2 430 System 15 489 3:40 3:46 0:06 1 385 System.Data 12 408 4:49 4:55 0:06 1 325 System.Drawings 3 123 0:28 0:29 0:01 289 System.Web 23 647 4:56 5:02 0:06 840 System.Xml 10 510 3:59 4:16 0:17 807

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 Backup slides 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 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