Introduction to Software Analysis CS 6340. Why Take This Course? Learn methods to improve software quality – reliability, security, performance, etc.

Slides:



Advertisements
Similar presentations
Static Analysis for Security
Advertisements

Advanced programming tools at Microsoft
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.
Semantics Static semantics Dynamic semantics attribute grammars
Compilation 2011 Static Analysis Johnni Winther Michael I. Schwartzbach Aarhus University.
50.530: Software Engineering Sun Jun SUTD. Week 10: Invariant Generation.
Abstraction and Modular Reasoning for the Verification of Software Corina Pasareanu NASA Ames Research Center.
David Brumley, Pongsin Poosankam, Dawn Song and Jiang Zheng Presented by Nimrod Partush.
ISBN Chapter 3 Describing Syntax and Semantics.
CS 355 – Programming Languages
The Future of Correct Software George Necula. 2 Software Correctness is Important ► Where there is software, there are bugs ► It is estimated that software.
Recursion. Binary search example postponed to end of lecture.
Program analysis Mooly Sagiv html://
Dynamically Discovering Likely Program Invariants to Support Program Evolution Michael D. Ernst, Jake Cockrell, William G. Griswold, David Notkin Presented.
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
Program Analysis Mooly Sagiv Tel Aviv University Sunday Scrieber 8 Monday Schrieber.
Overview of program analysis Mooly Sagiv html://
Introduction to Program Analysis
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.
Computer Programming and Basic Software Engineering 4. Basic Software Engineering 1 Writing a Good Program 4. Basic Software Engineering.
Chapter Introduction to Computers and Programming 1.
P51UST: Unix and Software Tools Unix and Software Tools (P51UST) Compilers, Interpreters and Debuggers Ruibin Bai (Room AB326) Division of Computer Science.
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.
Software Engineering Prof. Dr. Bertrand Meyer March 2007 – June 2007 Chair of Software Engineering Static program checking and verification Slides: Based.
Effective Real-time Android Application Auditing
The Daikon system for dynamic detection of likely invariants MIT Computer Science and Artificial Intelligence Lab. 16 January 2007 Presented by Chervet.
Introduction to Software Testing. Types of Software Testing Unit Testing Strategies – Equivalence Class Testing – Boundary Value Testing – Output Testing.
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.
Cs2220: Engineering Software Class 6: Defensive Programming Fall 2010 University of Virginia David Evans.
Reasoning about programs March CSE 403, Winter 2011, Brun.
Page 1 5/2/2007  Kestrel Technology LLC A Tutorial on Abstract Interpretation as the Theoretical Foundation of CodeHawk  Arnaud Venet Kestrel Technology.
Introduction to Program Analysis CS 8803 FPL Aug 20, 2013.
(1) A beginners guide to testing Philip Johnson Collaborative Software Development Laboratory Information and Computer Sciences University of Hawaii Honolulu.
What is Testing? Testing is the process of finding errors in the system implementation. –The intent of testing is to find problems with the system.
Java Basics Hussein Suleman March 2007 UCT Department of Computer Science Computer Science 1015F.
An Undergraduate Course on Software Bug Detection Tools and Techniques Eric Larson Seattle University March 3, 2006.
12/9/20151 Programming Languages and Compilers (CS 421) Elsa L Gunter 2112 SC, UIUC Based in part on slides by Mattox.
Extended Static Checking for Java Cormac Flanagan Joint work with: Rustan Leino, Mark Lillibridge, Greg Nelson, Jim Saxe, and Raymie Stata.
Static Techniques for V&V. Hierarchy of V&V techniques Static Analysis V&V Dynamic Techniques Model Checking Simulation Symbolic Execution Testing Informal.
David Evans CS201j: Engineering Software University of Virginia Computer Science Lecture 9: Designing Exceptionally.
CUTE: A Concolic Unit Testing Engine for C Koushik SenDarko MarinovGul Agha University of Illinois Urbana-Champaign.
Dynamic Testing.
Combining Static and Dynamic Reasoning for Bug Detection Yannis Smaragdakis and Christoph Csallner Elnatan Reisner – April 17, 2008.
/ PSWLAB Evidence-Based Analysis and Inferring Preconditions for Bug Detection By D. Brand, M. Buss, V. C. Sreedhar published in ICSM 2007.
Design by Contract. The Goal Ensure the correctness of our software (correctness) Recover when it is not correct anyway (robustness) Correctness: Assertions.
Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 1: Introduction to Computers and Programming.
CS 5150 Software Engineering Lecture 21 Reliability 2.
Dataflow Analysis CS What I s Dataflow Analysis? Static analysis reasoning about flow of data in program Different kinds of data: constants, variables,
CSE 374 Programming Concepts & Tools Hal Perkins Fall 2015 Lecture 17 – Specifications, error checking & assert.
Optimistic Hybrid Analysis
Introduction to Software Analysis
CMSC 345 Defensive Programming Practices from Software Engineering 6th Edition by Ian Sommerville.
Introduction to Software Analysis
Testing Tutorial 7.
Chapter 6 CS 3370 – C++ Functions.
CSE 374 Programming Concepts & Tools
MobiSys 2017 Symbolic Execution of Android Framework with Applications to Vulnerability Discovery and Exploit Generation Qiang Zeng joint work with Lannan.
Introduction to Software Analysis
CUTE: A Concolic Unit Testing Engine for C
Foundations and Definitions
Ras Bodik WF 11-12:30 slides adapted from Mooly Sagiv
Introduction to Software Analysis
Presentation transcript:

Introduction to Software Analysis CS 6340

Why Take This Course? Learn methods to improve software quality – reliability, security, performance, etc. Become a better software developer/tester Build specialized tools for software diagnosis and testing For the war stories

The Ariane Rocket Disaster (1996)

Post Mortem Caused due to numeric overflow error – Attempt to fit 64-bit format data in 16-bit space Cost – $100M’s for loss of mission – Multi-year setback to the Ariane program Read more at

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 Read more at

East Coast USA

East Coast USA: 2003 Blackout

Post Mortem Local failure rapidly cascaded through grid Cause: unnoticed crash of automated alarm system due to race condition 10M’s of people affected Read more at

Security Vulnerabilities Exploits of errors in programs Widespread problem – Moonlight Maze (1998) – Code Red (2001) – Titan Rain (2003) – 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 useful facts about programs Broadly classified into three kinds: – Dynamic (execution-time) – Static (compile-time) – Hybrid (combines dynamic and static)

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

Static Analysis Infer facts of the program by inspecting its source (or binary) code Examples: Suspicious error patterns Lint, FindBugs, Coverity Checking API usage rules Microsoft SLAM Memory leak detection Facebook Infer Verifying invariants ESC/Java

QUIZ: Program Invariants An invariant at the end of the program is (z == c) for some constant c. What is c? int p(int x) { return x * x; } void main() { int z; if (getc() == ‘a’) z = p(6) + 6; else z = p(-7) – 7; } z = ?

QUIZ: Program Invariants An invariant at the end of the program is (z == c) for some constant c. What is c? int p(int x) { return x * x; } void main() { int z; if (getc() == ‘a’) z = p(6) + 6; else z = p(-7) – 7; if (z != 42) disaster(); } z = 42 Disaster averted!

Discovering Invariants By Dynamic Analysis (z == 42) might be an invariant (z == 30) is definitely not an invariant int p(int x) { return x * x; } void main() { int z; if (getc() == ‘a’) z = p(6) + 6; else z = p(-7) – 7; if (z != 42) disaster(); } z = 42

Discovering Invariants By Static Analysis is definitely (z == 42) might be an invariant (z == 30) is definitely not an invariant int p(int x) { return x * x; } void main() { int z; if (getc() == ‘a’) z = p(6) + 6; else z = p(-7) – 7; if (z != 42) disaster(); } z = 42

Terminology Control-flow graph Abstract vs. concrete states Termination Completeness Soundness

Example Static Analysis Problem Find variables that have a constant value at a given program point void main() { z = 3; while (true) { if (x == 1) y = 7; else y = z + 4; assert (y == 7); } }

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

QUIZ: Iterative Approximation false Fill in the value of variable b that the analysis infers at: 1) the loop header 2) entry of loop body 3) exit of loop body Enter “?” if a definite value cannot be inferred. 1) 2) 3) b = 1 while (true) b = b + 1 [b=?] true

QUIZ: Iterative Approximation b = 1 while (true) b = b + 1 false Fill in the value of variable b that the analysis infers at: 1) the loop header 2) entry of loop body 3) exit of loop body Enter “?” if a definite value cannot be inferred. [b=?] 1) 2) 3) [b=1] [b=?] [b=1] [b=?] [b=2] true

QUIZ: Dynamic vs. Static Analysis DynamicStatic Cost Effectiveness Match each box with its corresponding feature. A. Unsound (may miss errors) D. Incomplete (may report spurious errors) B. Proportional to program’s execution time C. Proportional to program’s size

DynamicStatic Cost Effectiveness QUIZ: Dynamic vs. Static Analysis Match each box with its corresponding feature. B. Proportional to program’s execution time C. Proportional to program’s size A. Unsound (may miss errors) D. Incomplete (may report spurious errors)

Undecidability of Program Properties Can program analysis be sound and complete? – Not if we want it to terminate! Questions like “is a program point reachable on some input?” are undecidable Designing a program analysis is an art – Tradeoffs dictated by consumer

Who Needs Program Analysis? Three primary consumers of program analysis: Compilers Software Quality Tools Integrated Development Environments (IDEs)

Compilers Bridge between high-level languages and architectures Use program analysis to generate efficient code z = 42 int p(int x) { return x * x; } void main(int arg) { int z; if (arg != 0) z = p(6) + 6; else z = p(-7) - 7; print (z); } int p(int x) { return x * x; } void main() { print (42); } Runs faster More energy-efficient Smaller in size

Software Quality Tools Primary focus of this course Tools for testing, debugging, and verification Use program analysis for: – Finding programming errors – Proving program invariants – Generating test cases – Localizing causes of errors –…–… int p(int x) { return x * x; } void main() { int z; if (getc() == ‘a’) z = p(6) + 6; else z = p(-7) – 7; if (z != 42) disaster(); } z = 42

Integrated Development Environments Examples: Eclipse and Microsoft Visual Studio Use program analysis to help programmers: – Understand programs – Refactor programs Restructuring a program without changing its behavior Useful in dealing with large, complex programs

What Have We Learned? What is program analysis? Dynamic vs. static analysis: pros and cons Program invariants Iterative approximation method for static analysis Undecidability => program analysis cannot ensure termination + soundness + completeness Who needs program analysis?