Region-Based Model Abstraction Jeremy Condit Jim Larus Sriram Rajamani Jakob Rehof OSQ Lunch 7 September 2003.

Slides:



Advertisements
Similar presentations
PLDI’2005Page 1June 2005 Example (C code) int double(int x) { return 2 * x; } void test_me(int x, int y) { int z = double(x); if (z==y) { if (y == x+10)
Advertisements

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.
Compilation 2011 Static Analysis Johnni Winther Michael I. Schwartzbach Aarhus University.
Abstraction and Modular Reasoning for the Verification of Software Corina Pasareanu NASA Ames Research Center.
Compilation 2007 Code Generation Michael I. Schwartzbach BRICS, University of Aarhus.
1 Starting a Program The 4 stages that take a C++ program (or any high-level programming language) and execute it in internal memory are: Compiler - C++
1 Thorough Static Analysis of Device Drivers Byron Cook – Microsoft Research Joint work with: Tom Ball, Vladimir Levin, Jakob Lichtenberg,
Automatic Predicate Abstraction of C-Programs T. Ball, R. Majumdar T. Millstein, S. Rajamani.
ISBN Chapter 3 Describing Syntax and Semantics.
Symmetry-Aware Predicate Abstraction for Shared-Variable Concurrent Programs Alastair Donaldson, Alexander Kaiser, Daniel Kroening, and Thomas Wahl Computer.
Type Checking Compiler Design Lecture (02/25/98) Computer Science Rensselaer Polytechnic.
Semantic analysis Parsing only verifies that the program consists of tokens arranged in a syntactically-valid combination, we now move on to semantic analysis,
CS412/413 Introduction to Compilers Radu Rugina Lecture 16: Efficient Translation to Low IR 25 Feb 02.
Checking and Inferring Local Non-Aliasing Alex AikenJeffrey S. Foster UC BerkeleyUMD College Park John KodumalTachio Terauchi UC Berkeley.
Common Sub-expression Elim Want to compute when an expression is available in a var Domain:
Recap from last time We were trying to do Common Subexpression Elimination Compute expressions that are available at each program point.
Next Section: Pointer Analysis Outline: –What is pointer analysis –Intraprocedural pointer analysis –Interprocedural pointer analysis (Wilson & Lam) –Unification.
Control Flow Analysis Mooly Sagiv Tel Aviv University Sunday Scrieber 8 Monday Schrieber.
Speeding Up Dataflow Analysis Using Flow- Insensitive Pointer Analysis Stephen Adams, Tom Ball, Manuvir Das Sorin Lerner, Mark Seigle Westley Weimer Microsoft.
Elaboration or: Semantic Analysis Compiler Baojian Hua
1 Control Flow Analysis Mooly Sagiv Tel Aviv University Textbook Chapter 3
Encapsulation by Subprograms and Type Definitions
Type Checking in Cool Alex Aiken (Modified by Mooly Sagiv)
Automatically Validating Temporal Safety Properties of Interfaces Thomas Ball and Sriram K. Rajamani Software Productivity Tools, Microsoft Research Presented.
A Type-Checked Restrict Qualifier Jeff Foster OSQ Retreat May 9-10, 2001.
Context-sensitive Analysis, II Ad-hoc syntax-directed translation, Symbol Tables, andTypes.
Staged Information Flow for JavaScript Ravi Chugh, Jeff Meister, Ranjit Jhala, Sorin Lerner UC San Diego.
Describing Syntax and Semantics
Direction of analysis Although constraints are not directional, flow functions are All flow functions we have seen so far are in the forward direction.
Formal Verification of SpecC Programs using Predicate Abstraction Himanshu Jain Daniel Kroening Edmund Clarke Carnegie Mellon University.
Pointer analysis. Pointer Analysis Outline: –What is pointer analysis –Intraprocedural pointer analysis –Interprocedural pointer analysis Andersen and.
Symbolic Path Simulation in Path-Sensitive Dataflow Analysis Hari Hampapuram Jason Yue Yang Manuvir Das Center for Software Excellence (CSE) Microsoft.
Recursion CS Goals Discuss recursion as another form of repetition Do the following tasks, given a recursive routine Determine whether the routine.
Precision Going back to constant prop, in what cases would we lose precision?
CSC-682 Cryptography & Computer Security Sound and Precise Analysis of Web Applications for Injection Vulnerabilities Pompi Rotaru Based on an article.
1 Names, Scopes and Bindings Aaron Bloomfield CS 415 Fall
Recursion CS 302 – Data Structures Chapter 7. What is recursion? smaller A technique that solves problem by solving smaller versions of the same problem!
Aditya V. Nori, Sriram K. Rajamani Microsoft Research India.
Type Systems CS Definitions Program analysis Discovering facts about programs. Dynamic analysis Program analysis by using program executions.
Pointer Analysis Lecture 2 G. Ramalingam Microsoft Research, India.
Interpretation Environments and Evaluation. CS 354 Spring Translation Stages Lexical analysis (scanning) Parsing –Recognizing –Building parse tree.
410/510 1 of 18 Week 5 – Lecture 1 Semantic Analysis Compiler Construction.
Chapter 1 Object Oriented Programming. OOP revolves around the concept of an objects. Objects are created using the class definition. Programming techniques.
Design Patterns Gang Qian Department of Computer Science University of Central Oklahoma.
1 Compiler Design (40-414)  Main Text Book: Compilers: Principles, Techniques & Tools, 2 nd ed., Aho, Lam, Sethi, and Ullman, 2007  Evaluation:  Midterm.
CS536 Semantic Analysis Introduction with Emphasis on Name Analysis 1.
Slicing AspectJ Woven Code Luca Cavallaro Mattia Monga Antonio Castaldo D'Ursi Davide Balzarotti Politecnico di Milano.
Data Structures & Algorithms
A System to Generate Test Data and Symbolically Execute Programs Lori A. Clarke Presented by: Xia Cheng.
Generating Precise and Concise Procedure Summaries Greta Yorsh Eran Yahav Satish Chandra.
Pruning Dynamic Slices With Confidence Original by: Xiangyu Zhang Neelam Gupta Rajiv Gupta The University of Arizona Presented by: David Carrillo.
Chap. 7, Syntax-Directed Compilation J. H. Wang Nov. 24, 2015.
CS412/413 Introduction to Compilers Radu Rugina Lecture 11: Symbol Tables 13 Feb 02.
Topic 6.5. Solve Systems by Substitution Objectives: Solve Systems of Equations using Substitution Standards: Functions, Algebra, Patterns. Connections.
Opener: Find three consecutive odd integers whose sum is -63 Integer #1 = n Integer #2 = n + 2 Integer #3 = n + 4 (n) + (n + 2) + (n + 4) = -63 3n + 6.
Inter-procedural analysis
Code Optimization.
Context-Sensitive Analysis
Compilers Principles, Techniques, & Tools Taught by Jing Zhang
Solving Equations with the Variable on Each Side
3-2: Solving Systems of Equations using Substitution
Propositional Calculus: Boolean Algebra and Simplification
3-2: Solving Systems of Equations using Substitution
Solving Systems of Equations using Substitution
Over-Approximating Boolean Programs with Unbounded Thread Creation
3-2: Solving Systems of Equations using Substitution
2 Understanding Variables and Solving Equations.
Recursion.
SOFTWARE ENGINEERING INSTITUTE
Presentation transcript:

Region-Based Model Abstraction Jeremy Condit Jim Larus Sriram Rajamani Jakob Rehof OSQ Lunch 7 September 2003

Model Checking for C# Want to check properties of a C# program –e.g., conformance checking for web services The model checking approach: –Produce a simplified version of program with respect to the property –Check all possible executions of this model

Our Abstraction Technique We abstract a program by throwing away irrelevant code Relevant data is identified by a third party –Programmer annotations –Program analysis –Counterexample-driven refinement Relevant statements and expressions are those that deal with relevant data –Easy, right?

Two Problems Problem 1: Aliasing –Statements that affect aliasing can be relevant Problem 2: Indirection –Relevant data can be buried within other nonsense if (…) x = y; x.relevant_field = true; y.relevant_field = false; x.y.z.relevant_field = true;

class State { … relevant bool b; … } class Transaction { … State s; … } Example

Transaction x; Transaction y; if (…) { Transaction t1 = new Transaction(); t1.s = new State(); t1.s.b = true; x = t1; } else { Transaction t2 = new Transaction(); t2.s = new State(); t2.s.b = false; x = t2; } if (…) { Transaction t3 = new Transaction(); t3.s = new State(); t3.s.b = true; y = t3; } else { Transaction t4 = new Transaction(); t4.s = new State(); t4.s.b = false; y = t4; } if (x.s.b) … if (y.s.b) … if (x.s.b) … Example

Include all statements! Transaction x; Transaction y; if (…) { Transaction t1 = new Transaction(); t1.s = new State(); t1.s.b = true; x = t1; } else { Transaction t2 = new Transaction(); t2.s = new State(); t2.s.b = false; x = t2; } if (…) { Transaction t3 = new Transaction(); t3.s = new State(); t3.s.b = true; y = t3; } else { Transaction t4 = new Transaction(); t4.s = new State(); t4.s.b = false; y = t4; } if (x.s.b) … if (y.s.b) … if (x.s.b) … Solution 1: Program slicing

Compute alias sets for x and y: x = {t1, t2} y = {t3, t4} if (choose({t1,t2}).s.b) if (choose({t3,t4}).s.b) if (choose({t1,t2}).s.b) Transaction x; Transaction y; if (…) { Transaction t1 = new Transaction(); t1.s = new State(); t1.s.b = true; x = t1; } else { Transaction t2 = new Transaction(); t2.s = new State(); t2.s.b = false; x = t2; } if (…) { Transaction t3 = new Transaction(); t3.s = new State(); t3.s.b = true; y = t3; } else { Transaction t4 = new Transaction(); t4.s = new State(); t4.s.b = false; y = t4; } if (x.s.b) … if (y.s.b) … if (x.s.b) … Solution 2: Alias analysis

class State[  ] at  { … relevant bool b; … } class Transaction[  ] { … Stateh  i s; … } Region-Annotated Example

Region-Annotated Example Transactionh  1 i x; Transactionh  2 i y; if (…) { Transactionh  1 i t1 = new Transactionh  1 i(); t1.s = new Stateh  1 i(); t1.s.b = true; x = t1; } else { Transactionh  1 i t2 = new Transactionh  1 i(); t2.s = new Stateh  1 i(); t2.s.b = false; x = t2; } if (…) { Transactionh  2 i t3 = new Transactionh  2 i(); t3.s = new Stateh  2 i(); t3.s.b = true; y = t3; } else { Transactionh  2 i t4 = new Transaction(); t4.s = new Stateh  2 i(); t4.s.b = false; y = t4; } if (x.s.b) … if (y.s.b) … if (x.s.b) …

if (…) { s = new State(); s.b = true;  1 [= s; } else { s = new State(); s.b = false;  1 [= s; } if (…) { s = new State(); s.b = true;  2 [= s; } else { s = new State(); s.b = false;  2 [= s; } if (choose(  1 ).b) … if (choose(  2 ).b) … if (choose(  1 ).b) … Transactionh  1 i x; Transactionh  2 i y; if (…) { Transactionh  1 i t1 = new Transactionh  1 i(); t1.s = new Stateh  1 i(); t1.s.b = true; x = t1; } else { Transactionh  1 i t2 = new Transactionh  1 i(); t2.s = new Stateh  1 i(); t2.s.b = false; x = t2; } if (…) { Transactionh  2 i t3 = new Transactionh  2 i(); t3.s = new Stateh  2 i(); t3.s.b = true; y = t3; } else { Transactionh  2 i t4 = new Transaction(); t4.s = new Stateh  2 i(); t4.s.b = false; y = t4; } if (x.s.b) … if (y.s.b) … if (x.s.b) … Solution 3: Regions

Why Regions? Two phase alias analysis –Static: Identify scope of alias sets –Dynamic: Populate alias sets with objects Beneficial for model checker –Avoid loss of precision when generating models –Produce more precise alias information by exploiting the power of the model checker Solves aliasing and indirection problems Allows fine-grained tuning of trade-off between precision and performance

Our Abstraction Based on RegJava –Region type system for a Java-like language –Includes proof of soundness Given a statement or expression p, we define «p¬ to be its abstraction Distinguish three cases: 1. Relevant data 2. References to relevant data 3. All others

Example: Expressions Example:

Example: Statements Example:

Soundness Theorem Theorem: For any execution of the original RegJava program, there is a corresponding execution of the model Proof Sketch: Since we replace occurrences of variables and fields with a choice over the corresponding region, any possible value in the original program will be considered by the model

Context-Sensitivity Region type systems make our approach context-sensitive void foo[  1,  2 ](Stateh  1 i s1, Stateh  2 i s2) { s1.b = true; if (s2.b) … } void foo_model(Set  1, Set  2 ) { choose(  1 ).b = true; if (choose(  2 ).b) … }

Context-Sensitivity, Part 2 But we still have problems now and then: void foo[  ](Stateh  i s1, Stateh  i s2) { Stateh  i tmp; if (…) { tmp = s1; } else { tmp = s2; } tmp.b = true; } void foo_model(Set  ) { choose(  ).b = true; }

Context-Sensitivity, Part 3 We can create an even more dynamic model void foo[  1,  2 ](Stateh  1 i s1, Stateh  2 i s2) { Stateh  i tmp; if (…) { tmp = s1; } else { tmp = s2; } tmp.b = true; } void foo_model(Set  1, Set  2 ) { Set  ; if (…) {  [=  1 ; } else {  [=  2 ; } choose(  ).b = true; }

Capturing Correlations Need to represent important correlations in the model –Solution: Introduce local variables Stateh  i s = …; s.b = true; s.f = 42; choose(  ).b = true; choose(  ).f = 42; Stateh  i s = choose(  ); s.b = true; s.f = 42; Source: Model:

Implementation Based on Dave Hanson and Todd Proebsting’s research C# compiler Five stages: –Introduce region variables –Gather constraints and solve –Determine live regions at each AST node –Insert letregion statements to limit region scope –Translate to Zing

The Fine Print RegJava’s regions use a stack discipline –Letregion statements tend to accumulate near the most general scopes in the program –We’re looking at less restrictive region systems Region parameters accumulate upward in the class hierarchy –Interfaces can’t be modeled properly –We’re looking at alternative approaches to object- oriented region systems

Related Work Other model checking projects –SLAM, BLAST, Bandera Regions in Cyclone Flow-sensitive Cqual CqualRBMA abstract locationsregion variables flow-insensitive phasemodel generation flow-sensitive phasemodel checking {0, 1, many} pointers at each location track all pointers in each region

Conclusion Region type systems solves several model generation problems: –Aliasing –Indirection Efficient division of labor: –Model generation phase (static) –Model checking phase (dynamic) Other compiler analyses may benefit from this approach!