From last time S1: l := new Cons p := l S2: t := new Cons *p := t p := t l p S1 l p tS2 l p S1 t S2 l t S1 p S2 l t S1 p S2 l t S1 p L2 l t S1 p S2 l t.

Slides:



Advertisements
Similar presentations
1 Verification by Model Checking. 2 Part 1 : Motivation.
Advertisements

Advanced programming tools at Microsoft
Demand-driven inference of loop invariants in a theorem prover
Automated Theorem Proving Lecture 1. Program verification is undecidable! Given program P and specification S, does P satisfy S?
Challenges in increasing tool support for programming K. Rustan M. Leino Microsoft Research, Redmond, WA, USA 23 Sep 2004 ICTAC Guiyang, Guizhou, PRC joint.
An Abstract Interpretation Framework for Refactoring P. Cousot, NYU, ENS, CNRS, INRIA R. Cousot, ENS, CNRS, INRIA F. Logozzo, M. Barnett, Microsoft Research.
Advanced Compiler Techniques LIU Xianhua School of EECS, Peking University Pointer Analysis.
Flow insensitive pointer analysis: fixed S1: l := new Cons p := l S2: t := new Cons *p := t p := t l p S1 l p tS2 l p S1 t S2 l t S1 p S2 l t S1 p S2 l.
School of EECS, Peking University “Advanced Compiler Techniques” (Fall 2011) Pointer Analysis.
Worst case complexity of Andersen *x = y x abc y def x abc y def Worst case: N 2 per statement, so at least N 3 for the whole program. Andersen is in fact.
© Chinese University, CSE Dept. Software Engineering / Software Engineering Topic 1: Software Engineering: A Preview Your Name: ____________________.
A survey of techniques for precise program slicing Komondoor V. Raghavan Indian Institute of Science, Bangalore.
ISBN Chapter 3 Describing Syntax and Semantics.
Formal Specification and Verification. Specifications Imprecise specifications can cause serious problems downstream Lots of interpretations even with.
1 Semantic Description of Programming languages. 2 Static versus Dynamic Semantics n Static Semantics represents legal forms of programs that cannot be.
Automated Soundness Proofs for Dataflow Analyses and Transformations via Local Rules Sorin Lerner* Todd Millstein** Erika Rice* Craig Chambers* * University.
The Design and Implementation of a Certifying Compiler [Necula, Lee] A Certifying Compiler for Java [Necula, Lee et al] David W. Hill CSCI
Formal Methods of Systems Specification Logical Specification of Hard- and Software Prof. Dr. Holger Schlingloff Institut für Informatik der Humboldt.
ESC Java. Static Analysis Spectrum Power Cost Type checking Data-flow analysis Model checking Program verification AutomatedManual ESC.
VIDE Integrated Environment for Development and Verification of Programs.
Proof-system search ( ` ) Interpretation search ( ² ) Main search strategy DPLL Backtracking Incremental SAT Natural deduction Sequents Resolution Main.
Automatically Proving the Correctness of Compiler Optimizations Sorin Lerner Todd Millstein Craig Chambers University of Washington.
Final exam week Three things on finals week: –final exam –final project presentations –final project report.
Static and Dynamic Contract Verifiers For Java Hongming Liu.
Programmability with Proof-Carrying Code George C. Necula University of California Berkeley Peter Lee Carnegie Mellon University.
Interprocedural pointer analysis for C We’ll look at Wilson & Lam PLDI 95, and focus on two problems solved by this paper: –how to represent pointer information.
Advanced Compilers CSE 231 Instructor: Sorin Lerner.
Flow insensitivity and imprecision If you ignore flow, then you lose precision. main() { x := &y;... x := &z; } Flow insensitive analysis tells us that.
CS 330 Programming Languages 09 / 18 / 2007 Instructor: Michael Eckmann.
Range Analysis. Intraprocedural Points-to Analysis Want to compute may-points-to information Lattice:
Houdini: An Annotation Assistant for ESC/Java Cormac Flanagan and K. Rustan M. Leino Compaq Systems Research Center.
Software Reliability Methods Sorin Lerner. Software reliability methods: issues What are the issues?
Validating High-Level Synthesis Sudipta Kundu, Sorin Lerner, Rajesh Gupta Department of Computer Science and Engineering, University of California, San.
Advanced Compilers CSE 231 Instructor: Sorin Lerner.
Intraprocedural Points-to Analysis Flow functions:
Copyright © 2006 The McGraw-Hill Companies, Inc. Programming Languages 2nd edition Tucker and Noonan Chapter 18 Program Correctness To treat programming.
A Type System for Expressive Security Policies David Walker Cornell University.
ESC Java. Static Analysis Spectrum Power Cost Type checking Data-flow analysis Model checking Program verification AutomatedManual ESC.
ESP [Das et al PLDI 2002] Interface usage rules in documentation –Order of operations, data access –Resource management –Incomplete, wordy, not checked.
Well-cooked Spaghetti: Weakest-Precondition of Unstructured Programs Mike Barnett and Rustan Leino Microsoft Research Redmond, WA, USA.
Comparison Caller precisionCallee precisionCode bloat Inlining context-insensitive interproc Context sensitive interproc Specialization.
Provably Correct Compilers (Part 2) Nazrul Alam and Krishnaprasad Vikram April 21, 2005.
Describing Syntax and Semantics
Pointer analysis. Flow insensitive loss of precision S1: l := new Cons p := l S2: t := new Cons *p := t p := t l t S1 p S2 l t S1 p S2 l t S1 p S2 l t.
Automatically Checking the Correctness of Program Analyses and Transformations.
Pointer analysis. Pointer Analysis Outline: –What is pointer analysis –Intraprocedural pointer analysis –Interprocedural pointer analysis Andersen and.
Cormac Flanagan University of California, Santa Cruz Hybrid Type Checking.
Computer Science 340 Software Design & Testing Design By Contract.
Have Your Verified Compiler And Extend It Too Zachary Tatlock Sorin Lerner UC San Diego.
Software Engineering Prof. Dr. Bertrand Meyer March 2007 – June 2007 Chair of Software Engineering Static program checking and verification Slides: Based.
1 Program Correctness CIS 375 Bruce R. Maxim UM-Dearborn.
Proof Carrying Code Zhiwei Lin. Outline Proof-Carrying Code The Design and Implementation of a Certifying Compiler A Proof – Carrying Code Architecture.
Chapter 25 Formal Methods Formal methods Specify program using math Develop program using math Prove program matches specification using.
Proof-Carrying Code & Proof-Carrying Authentication Stuart Pickard CSCI 297 June 2, 2005.
ISBN Chapter 3 Describing Semantics -Attribute Grammars -Dynamic Semantics.
CS 363 Comparative Programming Languages Semantics.
Reasoning about programs March CSE 403, Winter 2011, Brun.
Semantics In Text: Chapter 3.
SAFE KERNEL EXTENSIONS WITHOUT RUN-TIME CHECKING George C. Necula Peter Lee Carnegie Mellon U.
Static Techniques for V&V. Hierarchy of V&V techniques Static Analysis V&V Dynamic Techniques Model Checking Simulation Symbolic Execution Testing Informal.
Proving Optimizations Correct using Parameterized Program Equivalence University of California, San Diego Sudipta Kundu Zachary Tatlock Sorin Lerner.
Pointer Analysis CS Alias Analysis  Aliases: two expressions that denote the same memory location.  Aliases are introduced by:  pointers  call-by-reference.
Weakest Precondition of Unstructured Programs
Formal Methods in Software Engineering 1
Programming Languages 2nd edition Tucker and Noonan
Hoare-style program verification
Compilers have many bugs
Semantics In Text: Chapter 3.
Pointer analysis.
Programming Languages 2nd edition Tucker and Noonan
Presentation transcript:

From last time S1: l := new Cons p := l S2: t := new Cons *p := t p := t l p S1 l p tS2 l p S1 t S2 l t S1 p S2 l t S1 p S2 l t S1 p L2 l t S1 p S2 l t S1 p S2 l t S1 p S2 l t L1 p L2 l t S1 p S2 Iter 1Iter 2Iter 3 l t S1 p S2 Final result This is Andersen’s algorithm ’94

Flow insensitive loss of precision Flow insensitive analysis leads to loss of precision! main() { x := &y;... x := &z; } Flow insensitive analysis tells us that x may point to z here! However: –uses less memory (memory can be a big bottleneck to running on large programs) –runs faster

Worst case complexity of Andersen *x = y x abc y def x abc y def Worst case: N 2 per statement, so at least N 3 for the whole program. Andersen is in fact O(N 3 )

New idea: one successor per node Make each node have only one successor. This is an invariant that we want to maintain. x a,b,c y d,e,f *x = y x a,b,c y d,e,f

x *x = y y More general case for *x = y

x *x = y yxyxy More general case for *x = y

x x = *y y Handling: x = *y

x x = *y yxyxy Handling: x = *y

x x = y y x = &y xy Handling: x = y (what about y = x?) Handling: x = &y

x x = y yxyxy x = &y xyx y,… xy Handling: x = y (what about y = x?) Handling: x = &y get the same for y = x

Our favorite example, once more! S1: l := new Cons p := l S2: t := new Cons *p := t p := t

Our favorite example, once more! S1: l := new Cons p := l S2: t := new Cons *p := t p := t l S1 t S2 p l S1 l p l t S2 p l S1,S2 tp l S1 t S2 p 4 5

bar() { i := &a; j := &b; foo(&i); foo(&j); // i pnts to what? *i :=...; } void foo(int* p) { printf(“%d”,*p); } Another example

bar() { i := &a; j := &b; foo(&i); foo(&j); // i pnts to what? *i :=...; } void foo(int* p) { printf(“%d”,*p); } i a j b p i a i a j b i a j b p i,j a,b p Another example 4 3

Steensgaard & beyond A well engineered implementation of Steensgaard ran on Word97 (2.1 MLOC) in 1 minute. One Level Flow (Das PLDI 00) is an extension to Steensgaard that gets more precision and runs in 2 minutes on Word97.

Program analysis and Software Reliability

Software reliability: issues What are the issues?

Software reliability: issues What is software reliability? How to measure it? –Bug counts ? Will we ever have bug-free software? –How many 9’s ? –Service Level Agreements ? What is a bug? –Adherence to specifications –But what is a specification… –User unhappy: is that a bug? –Different levels of severity

Software reliability: issues Cost of the methods for achieving reliability –Independently develop 5 versions of the software, run them all in parallel ) less likely that they fail at the same time in the same way. But… cost… is… high –For tools, cost of development of the tools Burden on the programmer –fully automated vs. semi-automated methods –allow progressive adoption Scalability vs. precision –start with scalability and get precision later? –Or the other way around?

Software reliability: issues Level of guarantee provided by the method –Hard guarantees, statistical guarantees, no formal guarantee –What if tool is broken: trusted computing base When is the method used? –compile-time, link-time, load-time, run-time What does the tool see? –source code, assembly, the whole program or part of the program

One way of dividing the spectrum Compiler if (…) { x := …; } else { y := …; } …;

One way of dividing the spectrum if (…) { x := …; } else { y := …; } …; Static techniques Testing techniques Run-time techniques Compiler if (…) { x := …; } else { y := …; } …;

One way of dividing the spectrum if (…) { x := …; } else { y := …; } …; Static techniques Testing techniques Run-time techniques Static techniques

Static Techniques Spec: says what code should and should not do Complete spec: specifies all behaviors (hard to formalize) Incomplete spec: only defines some behaviors –e.g. “no null derefs”, “requests received are eventually processed” Many formalisms exist for specs (Pre/Post conditions, FSMs, Temporal Logic, Abstract State Machines etc.) if (…) { x := …; } else { y := …; } …; Spec   «  ¬   $  \ r t  l Code satisfies spec?

Static Techniques Language Design –Clean language design –Type Systems –Domain-specific languages –…–… if (…) { x := …; } else { y := …; } …; Spec   «  ¬   $  \ r t  l Code satisfies spec? Program Analysis –Dataflow analysis –WP/SP –Model checking –Automated Theorem Proving –… Interaction between the two CleanL TSys DSL DFA WP/SP MC ATP

ESC/Java [Leino et al PLDI 2002] object Foo { PRE (FORMULA) method bar(...) {... } POST (FORMULA) } Compute Weakest Precondition WP(POST, bar) = weakest condition Q such that Q at entry to bar establishes POST at exist ) Programmer annotates code with pre- and post- conditions, tool verifies that these hold Automated Theorem Prover CleanL TSys DSL DFA WP/SP MC ATP

How does Program Analysis fit in? First, WP computation is a kind of program analysis –in fact, can be seen as a dataflow analysis –predicates as sets of states –WP operator acts as flow function –WP-based concrete semantics Second, can use global points-to analysis to help WP computation –do better job with pointer stores *x :=... –or with field assignments o.f :=...

Parser Code Gen Compiler DSL Opt DSL Opt DSL Opt DSL Opt DSL Opt DSL Opt Checker Rhodium [Lerner et al POPL 2005] CleanL TSys DSL DFA WP/SP MC ATP

DSL Opt DSL Opt DSL Opt Checker DSL Opt Checker DSL Opt Checker DSL Opt Rhodium [Lerner et al POPL 2005] CleanL TSys DSL DFA WP/SP MC ATP

Rhodium [Lerner et al POPL 2005] VCGen Local VC Automatic Theorem Prover Rdm Opt Checker Lemma For any Rhodium opt: If Local VC is true Then opt is OK Proof   «  ¬   $  \ r t  l Opt-independent Opt- dependent CleanL TSys DSL DFA WP/SP MC ATP

How does Program Analysis fit in? First, Rhodium is a system for expressing and checking the correctness of DFAs Second, the Rhodium system is an example of program analysis of a domain-specific language