Introduction to Program Analysis CS 8803 FPL Aug 20, 2013.

Slides:



Advertisements
Similar presentations
Advanced programming tools at Microsoft
Advertisements

Automated Theorem Proving Lecture 1. Program verification is undecidable! Given program P and specification S, does P satisfy S?
Runtime Techniques for Efficient and Reliable Program Execution Harry Xu CS 295 Winter 2012.
Automatic Memory Management Noam Rinetzky Schreiber 123A /seminar/seminar1415a.html.
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.
Chair of Software Engineering From Program slicing to Abstract Interpretation Dr. Manuel Oriol.
Background for “KISS: Keep It Simple and Sequential” cs264 Ras Bodik spring 2005.
Program Analysis and Verification Spring 2015 Program Analysis and Verification Lecture 1: Introduction Roman Manevich Ben-Gurion University.
David Brumley, Pongsin Poosankam, Dawn Song and Jiang Zheng Presented by Nimrod Partush.
CSE , Autumn 2011 Michael Bond.  Name  Program & year  Where are you coming from?  Research interests  Or what’s something you find interesting?
ISBN Chapter 3 Describing Syntax and Semantics.
CS 355 – Programming Languages
An Integration of Program Analysis and Automated Theorem Proving Bill J. Ellis & Andrew Ireland School of Mathematical & Computer Sciences Heriot-Watt.
Software Engineering: Where are we? And where do we go from here? V Software Engineering Lecture 23 Clark Barrett New York University 4/17/2006.
Program analysis Mooly Sagiv html://
Synergy: A New Algorithm for Property Checking
An Overview on Program Analysis Mooly Sagiv Tel Aviv University Textbook: Principles of Program.
An Overview on Static Program Analysis Mooly Sagiv Tel Aviv University Textbook: Principles of.
Program analysis Mooly Sagiv html://
1 Program Analysis Mooly Sagiv Tel Aviv University Textbook: Principles of Program Analysis.
Overview of program analysis Mooly Sagiv html://
Describing Syntax and Semantics
CS 153: Concepts of Compiler Design August 25 Class Meeting Department of Computer Science San Jose State University Fall 2014 Instructor: Ron Mak
Program Analysis Mooly Sagiv Tel Aviv University Sunday Scrieber 8 Monday Schrieber.
Overview of program analysis Mooly Sagiv html://
Scalable and Flexible Static Analysis of Flight-Critical Software Guillaume P. Brat Arnaud J. Venet Carnegie.
Examining the Code [Reading assignment: Chapter 6, pp ]
Introduction to Program Analysis
1CMSC 345, Version 4/04 Verification and Validation Reference: Software Engineering, Ian Sommerville, 6th edition, Chapter 19.
An Overview on Static Program Analysis Mooly Sagiv.
CS527: (Advanced) Topics in Software Engineering Overview of Software Quality Assurance Tao Xie ©D. Marinov, T. Xie.
Verification and Validation Yonsei University 2 nd Semester, 2014 Sanghyun Park.
CUTE: A Concolic Unit Testing Engine for C Technical Report Koushik SenDarko MarinovGul Agha University of Illinois Urbana-Champaign.
Towards Scalable Modular Checking of User-defined Properties Thomas Ball, MSR Brian Hackett, Mozilla Shuvendu Lahiri, MSR Shaz Qadeer, MSR Julien Vanegue,
CS 501: Software Engineering Fall 1999 Lecture 16 Verification and Validation.
Software Engineering Prof. Dr. Bertrand Meyer March 2007 – June 2007 Chair of Software Engineering Static program checking and verification Slides: Based.
1 A Simple but Realistic Assembly Language for a Course in Computer Organization Eric Larson Moon Ok Kim Seattle University October 25, 2008.
An Overview on Program Analysis Mooly Sagiv Tel Aviv University Textbook: Principles of Program.
The Daikon system for dynamic detection of likely invariants MIT Computer Science and Artificial Intelligence Lab. 16 January 2007 Presented by Chervet.
Use of Coverity & Valgrind in Geant4 Gabriele Cosmo.
CS 363 Comparative Programming Languages Semantics.
Unit Testing 101 Black Box v. White Box. Definition of V&V Verification - is the product correct Validation - is it the correct product.
Reasoning about programs March CSE 403, Winter 2011, Brun.
1 CSCD 326 Data Structures I Software Design. 2 The Software Life Cycle 1. Specification 2. Design 3. Risk Analysis 4. Verification 5. Coding 6. Testing.
An Undergraduate Course on Software Bug Detection Tools and Techniques Eric Larson Seattle University March 3, 2006.
Testing. Today’s Topics Why Testing? Basic Definitions Kinds of Testing Test-driven Development Code Reviews (not testing) 1.
PROGRAMMING TESTING B MODULE 2: SOFTWARE SYSTEMS 22 NOVEMBER 2013.
Static Techniques for V&V. Hierarchy of V&V techniques Static Analysis V&V Dynamic Techniques Model Checking Simulation Symbolic Execution Testing Informal.
CUTE: A Concolic Unit Testing Engine for C Koushik SenDarko MarinovGul Agha University of Illinois Urbana-Champaign.
Introduction to Software Analysis CS Why Take This Course? Learn methods to improve software quality – reliability, security, performance, etc.
1 Proving program termination Lecture 5 · February 4 th, 2008 TexPoint fonts used in EMF. Read the TexPoint manual before you delete this box.: A.
/ PSWLAB Evidence-Based Analysis and Inferring Preconditions for Bug Detection By D. Brand, M. Buss, V. C. Sreedhar published in ICSM 2007.
CSC3315 (Spring 2009)1 CSC 3315 Languages & Compilers Hamid Harroud School of Science and Engineering, Akhawayn University
Verification vs. Validation Verification: "Are we building the product right?" The software should conform to its specification.The software should conform.
CS 5150 Software Engineering Lecture 21 Reliability 2.
Sung-Dong Kim, Dept. of Computer Engineering, Hansung University Java - Introduction.
CSE 374 Programming Concepts & Tools Hal Perkins Fall 2015 Lecture 17 – Specifications, error checking & assert.
Content Coverity Static Analysis Use cases of Coverity Examples
Introduction to Software Analysis
CMSC 345 Defensive Programming Practices from Software Engineering 6th Edition by Ian Sommerville.
Introduction to Software Analysis
Seminar in automatic tools for analyzing programs with dynamic memory
CSE 374 Programming Concepts & Tools
runtime verification Brief Overview Grigore Rosu
Improving software quality using Visual Studio 11 C++ Code Analysis
Introduction to Software Analysis
Language-based Security
Ras Bodik WF 11-12:30 slides adapted from Mooly Sagiv
Introduction to Software Analysis
Presentation transcript:

Introduction to Program Analysis CS 8803 FPL Aug 20, 2013

Course Communication All class materials and annoucements provided via t-square – To ask questions: – Post to forum on Piazza – Meet me after class – Send to – Send for appointment (KACB 2320)

Course Content Focus on program analysis – Concerns discovering facts about programs Both principles and practice Mix of basic and advanced material Other trends not covered in this course: – Program synthesis – Programming language design

Course Structure Lectures, from notes and research papers – No required textbook Evaluation components: – Class participation (5%) – In-class mid-term (20%) and final (20%) – Programming assignments (30%) – Team project and presentation (25%)

Prerequisites and Credits Pre-Reqs: None, but expect to program in Java Credits: 3 hours, counts toward: – Elective in MS CS program for specializations of “Information Security” and “DB + SE” – Breadth component in PhD CS program for areas of “PLC” and “SE” Auditing allowed in exceptional cases

Learning Outcomes Prepare for research in program analysis – This is where the field is headed Be able to apply program analysis to problems in other areas (security, systems, etc.) Become a better software developer or tester For the war stories

The Ariane Rocket Disaster (1996)

Post Mortem Failed due to unhandled floating-point exception Cost – $100M’s for loss of mission – Multi-year setback to the Ariane program

Mars Polar Lander (1999)

Post Mortem A units problem – Caller expected values in inches/feet – Callee assumed values in meters – Essentially, a type error Total loss of $100M mission

East Coast USA

East Coast USA: 2003 Blackout

Post Mortem Local failure rapidly cascaded through grid Major contributing cause was unnoticed crash of automated alarm systems 10M’s of people affected

Security Vulnerabilities Often exploit bugs in programs Widespread problem – Code Red – Titan Rain – Moonlight Maze – Operation Orchard – Stuxnet Worm Getting worse … 2011 Mobile Threat Report (Lookout™ Mobile Security) million Android users affected by malware in first half of out of 10 Android owners likely to face web-based threat each year Attackers using increasingly sophisticated ways to steal data and money

What is Program Analysis? Body of work to discover facts about programs Broadly classified into two kinds: – Dynamic (execution-time) – Static (compile-time) This course will cover both kinds, and more! – Data-driven (machine learning) – “Crowd-sourcing” (leveraging human intelligence) – Synergistic combinations of above approaches

Dynamic Program Analysis Infer facts of program by monitoring its runs Examples: – Array bound checking Purify – Memory leak detection Valgrind – Datarace detection Eraser – Finding likely invariants Daikon

Static Analysis Infer facts of the program by inspecting its source (or binary) code

An Example Static Analysis Problem Find variables with constant value at a given program location Example program: int p(int x) { return x * x; } void main() { int z; if (getc()) z = p(6) + 8; else z = p(-7) - 5; printf (z); } z = 44

Iterative Approximation z =3 while (x > 0) if (x == 1) y =7y = z + 4 assert (y == 7) [x=?, y=?, z=?] [x=?, y=?, z=3] [x=1, y=?, z=3] [x=1, y=7, z=3] [x=?, y=7, z=3] [x=?, y=?, z=3] true false true false

Another Static Analysis Problem Liveness Analysis: find which variables are live at each program point These are variables that are used before being set on some path from current program point Many applications: – Compilers: register allocation – Software Quality Tools: find uninitialized variable use

Liveness Analysis on Example Program a = 0 L: b = a + 1 c = c + b a = b * 2 if (c < N) goto L false return c true { c } { c, a } { c, b } { c, a } { c }

Other Static Analysis Problems Reaching definitions Expressions that are “available” Dead code Pointer variables never point into the same location Points in the program in which it is safe to free an object An invocation of virtual method whose address is unique Statements that can be executed in parallel Integer intervals

Dynamic vs. Static Analysis DynamicStatic Effectiveness Unsound (may miss errors) Incomplete (may report spurious errors) Cost Proportional to program’s execution Proportional to program’s size

Dynamic vs. Static Analysis DynamicStatic Effectiveness Unsound (may miss errors) Incomplete (may report spurious errors) Cost Proportional to program’s execution Proportional to program’s size

Undecidability of Program Properties Even seemingly simple program properties are undecidable – e.g.: is a program point reachable on some input? => no program analysis can be sound and complete Some properties undecidable even if program is simplified (e.g., conditionals are ignored)

Who Needs Program Analysis? Compilers – Advanced computer architectures – High-level programming languages (functional, OO, garbage-collected, concurrent) Software Quality Tools (Testing, Verification, Debugging) – Generate test cases – Find programming errors – Generate certification proofs – Localize causes of errors Program Understanding (e.g., IDEs)

Software Quality Tools Detecting hazards (lint) – e.g.: Using uninitialized variables a = malloc() ; b = a; free(a); c = malloc(); if (b == c) printf(“unexpected equality”); References outside array bounds Memory leaks (even in Java!)

Case Study 1: Static Driver Verifier Driver’s Source Code in C API Usage Rules (SLIC) Defects 100% path coverage Windows API Static Driver Verifier Model of Windows Kernel

Overview of SLAM Process C program SLIC rules Boolean Program C2BP BEBOP Abstract Error Trace NEWTON Concrete Error Trace Proof 

Bill Gates’ Quote about SLAM "Things like even software verification, this has been the Holy Grail of computer science for many decades but now in some very key areas, for example, driver verification we’re building tools that can do actual proof about the software and how it works in order to guarantee the reliability.” Bill Gates, April 18, Keynote address at WinHec 2002

Case Study 2: ASTRÉE Prove absence of bugs in safety critical C code ASTRÉE automatically proved absence of bugs in the primary flight control software of Airbus A340’s fly-by-wire system – Analyzed a program of 132,000 lines of C code