Generating Precise and Concise Procedure Summaries Greta Yorsh Eran Yahav Satish Chandra.

Slides:



Advertisements
Similar presentations
Sml2java a source to source translator Justin Koser, Haakon Larsen, Jeffrey Vaughan PLI 2003 DP-COOL.
Advertisements

Dataflow Analysis for Datarace-Free Programs (ESOP 11) Arnab De Joint work with Deepak DSouza and Rupesh Nasre Indian Institute of Science, Bangalore.
Automated Theorem Proving Lecture 1. Program verification is undecidable! Given program P and specification S, does P satisfy S?
Auto-Generation of Test Cases for Infinite States Reactive Systems Based on Symbolic Execution and Formula Rewriting Donghuo Chen School of Computer Science.
Synthesis, Analysis, and Verification Lecture 04c Lectures: Viktor Kuncak VC Generation for Programs with Data Structures “Beyond Integers”
Representing Boolean Functions for Symbolic Model Checking Supratik Chakraborty IIT Bombay.
Data-Flow Analysis II CS 671 March 13, CS 671 – Spring Data-Flow Analysis Gather conservative, approximate information about what a program.
Introducing Formal Methods, Module 1, Version 1.1, Oct., Formal Specification and Analytical Verification L 5.
Context-Sensitive Interprocedural Points-to Analysis in the Presence of Function Pointers Presentation by Patrick Kaleem Justin.
Programming Languages and Paradigms
Pointer Analysis – Part I Mayur Naik Intel Research, Berkeley CS294 Lecture March 17, 2009.
3-Valued Logic Analyzer (TVP) Tal Lev-Ami and Mooly Sagiv.
1/20 Generalized Symbolic Execution for Model Checking and Testing Charngki PSWLAB Generalized Symbolic Execution for Model Checking and Testing.
Bebop: A Symbolic Model Checker for Boolean Programs Thomas Ball Sriram K. Rajamani
A survey of techniques for precise program slicing Komondoor V. Raghavan Indian Institute of Science, Bangalore.
SYMBOLIC MODEL CHECKING: STATES AND BEYOND J.R. Burch E.M. Clarke K.L. McMillan D. L. Dill L. J. Hwang Presented by Rehana Begam.
Automatic Predicate Abstraction of C-Programs T. Ball, R. Majumdar T. Millstein, S. Rajamani.
1 Semantic Description of Programming languages. 2 Static versus Dynamic Semantics n Static Semantics represents legal forms of programs that cannot be.
Formal Methods of Systems Specification Logical Specification of Hard- and Software Prof. Dr. Holger Schlingloff Institut für Informatik der.
Constraint Logic Programming Ryan Kinworthy. Overview Introduction Logic Programming LP as a constraint programming language Constraint Logic Programming.
Common Sub-expression Elim Want to compute when an expression is available in a var Domain:
Establishing Local Temporal Heap Safety Properties with Applications to Compile-Time Memory Management Ran Shaham Eran Yahav Elliot Kolodner Mooly Sagiv.
Next Section: Pointer Analysis Outline: –What is pointer analysis –Intraprocedural pointer analysis –Interprocedural pointer analysis (Wilson & Lam) –Unification.
U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science Emery Berger University of Massachusetts, Amherst Advanced Compilers CMPSCI 710.
Range Analysis. Intraprocedural Points-to Analysis Want to compute may-points-to information Lattice:
Programming Language Semantics Mooly SagivEran Yahav Schrirber 317Open space html://
Intraprocedural Points-to Analysis Flow functions:
Semantics with Applications Mooly Sagiv Schrirber html:// Textbooks:Winskel The.
Direction of analysis Although constraints are not directional, flow functions are All flow functions we have seen so far are in the forward direction.
Pointer analysis. Pointer Analysis Outline: –What is pointer analysis –Intraprocedural pointer analysis –Interprocedural pointer analysis Andersen and.
1 An introduction to design patterns Based on material produced by John Vlissides and Douglas C. Schmidt.
1/25 Pointer Logic Changki PSWLAB Pointer Logic Daniel Kroening and Ofer Strichman Decision Procedure.
272: Software Engineering Fall 2012 Instructor: Tevfik Bultan Lecture 4: SMT-based Bounded Model Checking of Concurrent Software.
Procedure Optimizations and Interprocedural Analysis Chapter 15, 19 Mooly Sagiv.
Maria-Cristina Marinescu Martin Rinard Laboratory for Computer Science Massachusetts Institute of Technology A Synthesis Algorithm for Modular Design of.
Maria-Cristina Marinescu Martin Rinard Laboratory for Computer Science Massachusetts Institute of Technology High-level Specification and Efficient Implementation.
Impact Analysis of Database Schema Changes Andy Maule, Wolfgang Emmerich and David S. Rosenblum London Software Systems Dept. of Computer Science, University.
MT311 Java Application Development and Programming Languages Li Tak Sing( 李德成 )
Finding Optimum Abstractions in Parametric Dataflow Analysis Xin Zhang Georgia Tech Mayur Naik Georgia Tech Hongseok Yang University of Oxford.
Chapter 1 Introduction Dr. Frank Lee. 1.1 Why Study Compiler? To write more efficient code in a high-level language To provide solid foundation in parsing.
1 Abstraction  Identify important aspects and ignore the details  Permeates software development programming languages are abstractions built on hardware.
Mathematical Modeling and Formal Specification Languages CIS 376 Bruce R. Maxim UM-Dearborn.
1 Employing decision procedures for automatic analysis and verification of heap-manipulating programs Greta Yorsh under the supervision of Mooly Sagiv.
Minimization of Symbolic Automata Presented By: Loris D’Antoni Joint work with: Margus Veanes 01/24/14, POPL14.
PRESTO: Program Analyses and Software Tools Research Group, Ohio State University Merging Equivalent Contexts for Scalable Heap-cloning-based Points-to.
Low-Level Detailed Design SAD (Soft Arch Design) Mid-level Detailed Design Low-Level Detailed Design Design Finalization Design Document.
Type Systems CS Definitions Program analysis Discovering facts about programs. Dynamic analysis Program analysis by using program executions.
1 Introduction to Software Engineering Lecture 1.
Compiler Principles Fall Compiler Principles Lecture 0: Local Optimizations Roman Manevich Ben-Gurion University.
Lexical Analysis: Finite Automata CS 471 September 5, 2007.
Symbolic Execution with Abstract Subsumption Checking Saswat Anand College of Computing, Georgia Institute of Technology Corina Păsăreanu QSS, NASA Ames.
Programming Languages and Design Lecture 3 Semantic Specifications of Programming Languages Instructor: Li Ma Department of Computer Science Texas Southern.
Learning Symbolic Interfaces of Software Components Zvonimir Rakamarić.
Scalable Clone Detection and Elimination for Erlang Programs Huiqing Li, Simon Thompson University of Kent Canterbury, UK.
Weighted Automata and Concurrency Akash Lal Microsoft Research, India Tayssir Touili, Nicholas Kidd and Tom Reps ACTS II, Chennai Mathematical Institute.
SASI Enforcement of Security Policies : A Retrospective* PSLab 오민경.
Generating Precise and Concise Procedure Summaries Greta Yorsh Eran Yahav Satish Chandra.
D A C U C P Speculative Alias Analysis for Executable Code Manel Fernández and Roger Espasa Computer Architecture Department Universitat Politècnica de.
MOPS: an Infrastructure for Examining Security Properties of Software Authors Hao Chen and David Wagner Appears in ACM Conference on Computer and Communications.
Operational Semantics Mooly Sagiv Tel Aviv University Sunday Scrieber 8 Monday Schrieber.
Duke CPS Programming Heuristics l Identify the aspects of your application that vary and separate them from what stays the same ä Take what varies.
Chapter 4 Static Analysis. Summary (1) Building a model of the program:  Lexical analysis  Parsing  Abstract syntax  Semantic Analysis  Tracking.
T imed Languages for Embedded Software Ethan Jackson Advisor: Dr. Janos Szitpanovits Institute for Software Integrated Systems Vanderbilt University.
Abstraction and Abstract Interpretation. Abstraction (a simplified view) Abstraction is an effective tool in verification Given a transition system, we.
Compositional Pointer and Escape Analysis for Java Programs
Graph Coverage for Specifications CS 4501 / 6501 Software Testing
Instructor: Rajeev Alur
Reasoning about code CSE 331 University of Washington.
Pointer analysis.
Discrete Controller Synthesis
Presentation transcript:

Generating Precise and Concise Procedure Summaries Greta Yorsh Eran Yahav Satish Chandra

2 Procedure Summaries A procedure summary conservatively represents the effect of calling a procedure –relation between input and output states Use summary of a procedure instead of re- analyzing it (if possible)

3 Properties of Summaries Precise: result of applying the summary is the same as the result of re-analyzing the procedure Efficient: applying the summary is more efficient than re-analyzing the procedure Concise –exploit the commonalities in procedure’s behavior –no superfluous context information

4 Motivation Modular verification –concise summary can capture infinitely-many contexts in a finite way –reuse summary of a library with different clients –summarize libraries before the client code is written Interprocedural analysis –concise summary ignores irrelevant context information –potentially more compact representation than an explicit summary table or BDDs

5 Main Challenge Restrict the representation of abstract transformers to permit automatic composition while maintaining precise summaries Composition is difficult –express intermediate states in terms of initial and final states –corresponds to quantifier elimination

6 (A1) (A2) (A3) tr 12 tr 23 Composition The result of composing the transformers tr 12 and tr 23 is transformer tr 13 that relates the initial states A1 to the final states A3 without using the intermediate states A2 tr 13

7 Structured Transformers Key to finding efficient representation –expose underlying uniformity and dependencies Decompose the values into finite number of classes with uniform behavior –transform each class of values separately –share representation within the same class

8 Efficient Representations Existing methods –IFDS transforms each dataflow fact separately –IDE transforms values of each variable independently Our method - breaks into as many levels as needed to get something uniform

9 Our Contributions Framework for generating precise, efficient and concise summaries –class of abstract domains and transformers –composition algorithm Instances of the framework include –known classes: IFDS, IDE –modular constant propagation with aliasing –modular typestate verification with aliasing Prototype implementation and evaluation for typestate

10 Framework Input –a procedure –abstract domain defined using certain domain constructors –abstract transformers expressed in a certain restricted language Output –precise efficient and concise summary of the procedure

11 Domain Constructors Powerset Product –certain reduced products can be using integrity rules Binary relation –with properties such as deterministic, reflexive, symmetric, transitive Atomic values –such as states of a finite-state automaton, integer numbers Domain parameter –a placeholder for program-specific entities such as names of program variables and fields, allocation sites

12 Example: Nullness of References Abstract value is a set M of access paths that must be null at runtime –M  P (AP) where –AP is the set of access paths of length at most 1:  AP(Vars, Fields) = P (Vars  (Fields   ))  Vars are program variables  Fields are fields of structures

13 Example: Nullness of References Abstract transformer tr for a set M operates pointwise on the elements of M –tr(M) =  d  M tr AP (d) Micro-transformer tr AP maps an access path d to a set of access paths –if d is null before the statement then every access path in tr AP (d) is null after the statement –tr AP is conditional micro-transformer

14 Example

15 d dt d=this.f d  t  d  this.f d=this.f this.f t = getComponent() Conditional Micro-Transformers if d = this.f return { this.f, t } else if d = t return { } else return { } setComponent(FileComp p) d dp d=p d  this.f  d  p d=p this.f if d = p return { this.f, p } else if d = this.freturn { } else return { d } tr AP (d) ≡ preconditions (under certain restrictions)

16 t = getComponent() setComponent(t) d dt d=this.f d  t  d  this.f d=this.f this.f d dt d=t d  this.f  d  t d=t this.f d dt d=t d  this.f  d  t d=t this.f d dt d=t d  this.f  d  t d=t this.f d:=this.f d := t d := d Example: Composition Algorithm substitution t = getComponent(); setComponent(t)

17  d d=this.f d  t  d  this.f d=this.f dt d=t d=td=t this.f this.f=t this.f t=tt=t t=tt=t ttt this.f  this.f  this.f  t d  this.f  d  t t  this.f  t  t    t  this.f  d:=this.fd:=td:=d Example: Composition Algorithm t = getComponent(); setComponent(t)

18 d d=this.f d  t  d  this.f d t=tt=t t=tt=t tthis.f d  this.f  d  t  Example: Composition Algorithm t = getComponent(); setComponent(t) d t d=this.f d  t  d  this.f d=this.f this.f d t = getComponent(); setComponent(t)

19 Example: Typestate Verification Typestate properties –describe the sequences of operations that are permitted on an object of a certain type –temporal safety properties –can be encoded as DFA –“Don’t read from a closed file” Goal: Statically ensure that no execution of a Java program can transition to err –non-trivial aliasing –flow-sensitivity –context-sensitivity err open()close() read() initopenclosed open() read() close()

20 Typestate Abstract Domain Abstract value is a set of dataflow facts Dataflow fact is –allocation site a  AS of the tracked object –type state s  Q of the tracked object –M  AP set of access-paths that must point to the tracked object –pts is a global pointers-to information  (p,a)  pts when access path p may point to an object allocated at a –alias is a global aliasing information  (p,q)  alias when access paths p and q may be aliased (may point to the object)

21 Typestate Abstract Transformers Abstract transformers operate pointwise on dataflow facts –tr(X) =  x  X tr 1 (x) Micro-transformer tr 1 operates separately on the type-state part and on the must-set: –tr 1 ( )=tr TS ( )  tr MS (M)  {pts}  {alias} –pts and alias remain unchanged tr TS is a conditional micro-transformer tr MS operates pointwise on the access paths in M –tr(M) =  d  M tr AP (d) tr AP is a conditional micro-transformer

22 Example

23 Typestate tr TS ( )Must Access Path if p  M return { } else if p  M  (p,a)  pts return {, } else return { } if d = p return { p, this.f } else if d=v.f  (v, this)  alias return {d} else if d=v.g  f≠g  v.g≠p return {d} else return { } init(p) TypestateMust Access Path if this.f  M return { } else … identity process() Conditional Micro-Transformers tr AP (d)

24 Preconditions may refer to parameters of the micro- transformer and to additional context –Nullness of reference: preconditions refer to the parameter d only –Typestate with aliasing: preconditions refer to the parameter r and to set M Handle context using a generalized version of weakest precondition Leverage the structure of the micro-transformers –preconditions are disjoint and total Composition Algorithm for Conditional Micro-Transformers

25 Composition Algorithm for Conditional Micro-Transformers (A1) (A2) (A3) tr 23 = if pre B (d) then { f B (d), g B (d) } else …. pre A pre B tr 12 = if pre A (d) then { f A (d), g A (d) } else …. fAfA gAgA gAgA gBgB fBfB fAfA

26 pre B pre A wp (A1) (A2) (A3) wp(pre A, d:= f A (d))  pre B tr 13 = if wp(pre A, d:=f A (d))  pre B then { f B (f A (d)), g B (f A (d)) } else …. substitution fAfA gBgB fBfB Composition Algorithm for Conditional Micro-Transformers tr 23 = if pre B (d) then { f B (d), g B (d) } else …. tr 12 = if pre A (d) then { f A (d), g A (d) } else ….

27 Typestate tr TS ( )Must Access Path if p  M return { } else if p  M  (p,a)  pts return {, } else if (p,a)  pts return { } init(p) TypestateMust Access Path if this.f  M return { } else … … process() init(p); process(p) wp(this.f  M, init(p) ) = ? Typestate Example: Composition tr AP (d) tr AP if d = p return { p, this.f } else if d=v.f  (v, this)  alias return {d} else if d=v.g  f≠g  v.g≠p return {d} else return { } if d = p return { p, this.f } else if d=v.f  (v, this)  alias return {d} else if d=v.g  f≠g  v.g≠p return {d} else return { } If tr AP is invertible then we can automatically compute wp The precondition on d for which tr AP (d) = this.f is d=p  d=this.f  (this,this)  alias pMpM  

28 Typestate tr TS ( )Must Access Path if p  M return { } else if p  M  (p,a)  pts return {, } else if (p,a)  pts return { } init(p) TypestateMust Access Path if this.f  M return { } else … … process() init(p); process(p) wp(this.f  M, init(p) ) = ? Typestate Example: Composition tr AP (d) tr AP if d = p return { p, this.f } else if d=v.f  (v, this)  alias return {d} else if d=v.g  f≠g  v.g≠p return {d} else return { } if d = p return { p, this.f } else if d=v.f  (v, this)  alias return {d} else if d=v.g  f≠g  v.g≠p return {d} else return { } if p  M  p  M return { } else if p  M  p  M  (p,a)  pts return …. else if p  M  (p,a)  pts return …. pMpM   

29 Principles Capture infinitely-many calling contexts in a finite way Ignore context information that is irrelevant under abstraction Identify constraints on the parameters of the abstraction and on their correlations Describe how each parameter is updated possibly using –its previous value and –values of other parameters Delay decisions to time of transformer evaluation

30 Laziness has a price Conditions are accumulated as transformers are composed Why does it work? –some combined conditions are non-satisfiable –number of distinctions relevant to typestate are relatively small Can be still costly…

31 Prototype Implementation Heart of the implementation: substitution-based composition Requires non-trivial consistency checking and simplification of formulas –Theory of lists for access paths –Additional theories (e.g., for simplifying composed automata transitions) even non-optimized summaries (maintaining precision) are of moderate sizes Interesting tradeoffs between cost of simplification and the size of summaries In practice, need to trade precision for scalability (e.g., impose hard size limits on summaries) Future work: investigate ways in which precision can be lost in a controlled manner

32 Summary Identified a class of (parametric) abstract domains and transformers –conditional micro-transformers Defined efficient composition algorithm –case-splitting and substitutions Generalized IFDS, IDE to modular setting Applied to typestate verification in the presence of aliasing –the language of summaries is closed under composition and finite