Model Checking Java Programs (Java PathFinder)

Slides:



Advertisements
Similar presentations
The behavior of SAT solvers in model checking applications K. L. McMillan Cadence Berkeley Labs.
Advertisements

Abstraction in Model Checking Nishant Sinha. Model Checking Given a: –Finite transition system M –A temporal property p The model checking problem: –Does.
Abstraction of Source Code (from Bandera lectures and talks)
Delta Debugging and Model Checkers for fault localization
CS 267: Automated Verification Lecture 8: Automata Theoretic Model Checking Instructor: Tevfik Bultan.
Partial Order Reduction: Main Idea
Introduction to Formal Methods for SW and HW Development 09: SAT Based Abstraction/Refinement in Model-Checking Roberto Sebastiani Based on work and slides.
SAT Based Abstraction/Refinement in Model-Checking Based on work by E. Clarke, A. Gupta, J. Kukula, O. Strichman (CAV’02)
Introducing Formal Methods, Module 1, Version 1.1, Oct., Formal Specification and Analytical Verification L 5.
Automatic Verification Book: Chapter 6. What is verification? Traditionally, verification means proof of correctness automatic: model checking deductive:
Abstraction and Modular Reasoning for the Verification of Software Corina Pasareanu NASA Ames Research Center.
Current Techniques in Language-based Security David Walker COS 597B With slides stolen from: Steve Zdancewic University of Pennsylvania.
CS 267: Automated Verification Lecture 10: Nested Depth First Search, Counter- Example Generation Revisited, Bit-State Hashing, On-The-Fly Model Checking.
1 Temporal Claims A temporal claim is defined in Promela by the syntax: never { … body … } never is a keyword, like proctype. The body is the same as for.
Discovering Affine Equalities Using Random Interpretation Sumit Gulwani George Necula EECS Department University of California, Berkeley.
1 Introduction to Computability Theory Lecture11: Variants of Turing Machines Prof. Amos Israeli.
1 Basic abstract interpretation theory. 2 The general idea §a semantics l any definition style, from a denotational definition to a detailed interpreter.
1 Model Checking, Abstraction- Refinement, and Their Implementation Based on slides by: Orna Grumberg Presented by: Yael Meller June 2008.
Constraint Logic Programming Ryan Kinworthy. Overview Introduction Logic Programming LP as a constraint programming language Constraint Logic Programming.
What Went Wrong? Alex Groce Carnegie Mellon University Willem Visser NASA Ames Research Center.
Operational Semantics Semantics with Applications Chapter 2 H. Nielson and F. Nielson
1 Abstraction Refinement for Bounded Model Checking Anubhav Gupta, CMU Ofer Strichman, Technion Highly Jet Lagged.
CS 267: Automated Verification Lecture 13: Bounded Model Checking Instructor: Tevfik Bultan.
Formal Verification of SpecC Programs using Predicate Abstraction Himanshu Jain Daniel Kroening Edmund Clarke Carnegie Mellon University.
272: Software Engineering Fall 2012 Instructor: Tevfik Bultan Lecture 4: SMT-based Bounded Model Checking of Concurrent Software.
1 Bisimulations as a Technique for State Space Reductions.
Java PathFinder (JPF) cs498dm Software Testing January 19, 2012.
Finding Feasible Counter-examples when Model Checking Abstracted Java Programs Corina S. Pasareanu, Matthew B. Dwyer (Kansas State University) and Willem.
Model construction and verification for dynamic programming languages Radu Iosif
Model Checking Java Programs using Structural Heuristics
Symbolic Execution with Abstract Subsumption Checking Saswat Anand College of Computing, Georgia Institute of Technology Corina Păsăreanu QSS, NASA Ames.
1 CSEP590 – Model Checking and Automated Verification Lecture outline for August 6, 2003.
jFuzz – Java based Whitebox Fuzzing
Learning Symbolic Interfaces of Software Components Zvonimir Rakamarić.
Static Techniques for V&V. Hierarchy of V&V techniques Static Analysis V&V Dynamic Techniques Model Checking Simulation Symbolic Execution Testing Informal.
Review A program is… a set of instructions that tell a computer what to do. Programs can also be called… software. Hardware refers to… the physical components.
Abstraction and Abstract Interpretation. Abstraction (a simplified view) Abstraction is an effective tool in verification Given a transition system, we.
Complexity Relief Techniques for Model Checking METU, Aug SOFTWARE VERIFICATION WORKSHOP Hüsnü Yenigün Sabanci University Informatics Institute,
Counterexample-Guided Abstraction Refinement By Edmund Clarke, Orna Grumberg, Somesh Jha, Yuan Lu, and Helmut Veith Presented by Yunho Kim Provable Software.
Sung-Dong Kim, Dept. of Computer Engineering, Hansung University Java - Introduction.
Presentation Title 2/4/2018 Software Verification using Predicate Abstraction and Iterative Refinement: Part Bug Catching: Automated Program Verification.
SS 2017 Software Verification Bounded Model Checking, Outlook
John D. McGregor Session 9 Testing Vocabulary
Testing and Debugging PPT By :Dr. R. Mall.
Abstraction of Source Code
Input Space Partition Testing CS 4501 / 6501 Software Testing
GC211Data Structure Lecture2 Sara Alhajjam.
Abstraction Data type based abstractions
Introduction Enosis Learning.
John D. McGregor Session 9 Testing Vocabulary
Introduction to Software Verification
Java Virtual Machine Complete subject details are available at:
Chapter 15 QUERY EXECUTION.
Introduction Enosis Learning.
John D. McGregor Session 9 Testing Vocabulary
It is great that we automate our tests, but why are they so bad?
Property Directed Reachability with Word-Level Abstraction
Objective of This Course
Model Checking for an Executable Subset of UML
Over-Approximating Boolean Programs with Unbounded Thread Creation
Mincer: a distributed automated problem determination tool
Automatic Test Generation SymCrete
Introduction to Requirements Modeling
Scalability in Model Checking
Abstraction, Verification & Refinement
Foundations and Definitions
Predicate Abstraction
Instructor: Aaron Roth
Course: CS60030 Formal Systems
SAT Based Abstraction/Refinement in Model-Checking
Presentation transcript:

Model Checking Java Programs (Java PathFinder) CS 510/10 Model Checking Java Programs (Java PathFinder) Slides partially compiled from the NASA JavaPathFinder project and E. Clarke’s course material

Java PathFinder JPF is an explicit state software model checker for Java bytecode JPF is a Java virtual machine that executes your program not just once (like a normal VM), but theoretically in all possible ways, checking for property violations like deadlocks or unhandled exceptions along all potential execution paths.

Symbolic Model Checking Program Analysis Engine CNF SAT Solver Claim Cbmc, smv SAT (counterexample exists) UNSAT (no counterexample found)

Explicit State Model Checking The program is indeed executing jpf <your class> <parameters> Very similar to “java <your class> <parameters> Execute in a way that all possible scenarios are explored Thread interleaving Undeterministic values (random values) Concrete input is provided A state is indeed a concrete state, consisting of Concrete values in heap/stack memory Jpf, spin, slam

JPF Status developed at the Robust Software Engineering Group at NASA Ames Research Center currently in it’s fourth development cycle v1: Spin/Promela translator - 1999 v2: backtrackable, state matching JVM - 2000 v3: extension infrastructure (listeners, MJI) - 2004 v4: symbolic execution, choice generators - 4Q 2005 open sourced since 04/2005 under NOSA 1.3 license: <javapathfinder.sourceforge.net> it’s a first: no NASA system development hosted on public site before 11100 downloads since publication 04/2005

An Example

One execution corresponds to one path. An Example (cont.) One execution corresponds to one path.

JPF explores multiple possible executions GIVEN THE SAME CONCRETE INPUT

Another Example

Choice points are those that jpf VM selects which thread to proceed Choice points are those that jpf VM selects which thread to proceed. They are usually thread start, join points, synchronization points, shared variable reference points. Why? Because they are the points that matter. We will come back to this issue when we are going to talk about partial order reduction. For this moment, students should understand that either main thread or the racer thread gets executed at each choice point. For example, if you have two threads. T1 { int i, j; i=10; j= 20; } T2 { int x, y; y=20;

Two Essential Capabilities Backtracking Means that JPF can restore previous execution states, to see if there are unexplored choices left. While this is theoretically can be achieved by re-executing the program from the beginning, backtracking is a much more efficient mechanism if state storage is optimized. State matching JPF checks every new state if it already has seen an equal one, in which case there is no use to continue along the current execution path, and JPF can backtrack to the nearest non-explored non-deterministic choice Heap and thread-stack snapshots.

The Challenge

The Challenge (cont.) State Explosion!! Random variables A program that potentially has infinite long execution State Explosion!!

JPF’s Solution Configurable search strategy Host VM Execution Directing the search so that defects can be found quicker A debugging tool instead of a “proof” system. User can easily develop his/her own strategy Host VM Execution Delegate execution to the underlying host VM (no state tracking). Reducing state storage State collapsing Premise: only a tiny part of the state is changed upon each transaction. (e.g. a single stack frame) Dividing a state into components, use hashtable to index a specific value for a component.

Solution- State Collapsing For example, x, y, z are static fields, they comprise a component. That is, a hash value is created for a unique value assignment for the component. If i, j, k are fields in a class C, a hash value is used for a dynamic object, representing that object. Question: why do you use a vector instead of an hash value to represent a state? In one extreme, we can use one hash value to represent the whole state. But that is useless as each time a single variable is changed, a new entry (the entire image) of the state has to be stored in the pool.

Solution (3) – State Reduction Orthogonal (our focus) State Abstraction Partial Order Reduction

Abstraction Eliminate details irrelevant to the property Obtain simple finite models sufficient to verify the property Disadvantage Loss of Precision: False positives/negatives

Data Abstraction h S S’ Abstraction Function h : from S to S’

Data Abstraction Example Abstraction proceeds component-wise, where variables are components Even Odd …, -2, 0, 2, 4, … x:int …, -3, -1, 1, 3, … Pos Neg Zero …, -3, -2, -1 y:int 1, 2, 3, …

How do we Abstract Behaviors? Abstract domain A Abstract concrete values to those in A Then compute transitions in the abstract domain

Data Type Abstraction Code Abstract Data domain int x = 0; if (x == 0) x = x + 1; we transform the code so that to operate on the abs domain and it looks like this; here the concrete type int was replaced by abs type signs, concrete constants 0 and 1 were replaced with abs ct 0 and pos; and primitive ops on ints were replaced with calls to some methods that implement the abs.ops.that manipulate abstract values. Ex : equality operator was replaced with a call to method signs.eq and + was replace by signs.add . So, how do we apply this abstraction technique to the DEOS example ? We have to decide which variables to abstract, what abstrations to use and then we have to effectively transform the system to encode the abstractions. The translation s homomorphic. h(v*u)=h(v)@h(u), * is an operator on the original domain and @ is an operator on the abstract domain. (n<0) : NEG (n==0): ZERO (n>0) : POS Signs NEG POS ZERO Signs x = ZERO; if (Signs.eq(x,ZERO)) x = Signs.add(x,POS);

Existential/Universal Abstractions Make a transition from an abstract state if at least one corresponding concrete state has the transition. Abstract model M’ simulates concrete model M Universal Make a transition from an abstract state if all the corresponding concrete states have the transition.

Existential Abstraction (Over-approximation) Use the x=x+1 example (abstracted to the Signs domain) to explain the idea. Red is a faulty state x=x+1; y=10/x This makes x=0 a faulty state. I h I S’

Universal Abstraction (Under-Approximation) abstract state 1 does not have a self-loop, last state does not have a successor abs state 1 does have a transition to the next state. no self loop on the red state h I S’

Guarantees from Abstraction Assume M’ is an abstraction of M Strong Preservation: P holds in M’ iff P holds in M Weak Preservation: P holds in M’ implies P holds in M

Guarantees from Exist. Abstraction Let φ be a hold-for-all-paths property M’ existentially abstracts M M’ Preservation Theorem M’ ⊨ φ  M ⊨ φ M Converse does not hold M’ ⊭ φ  M ⊭ φ M’ ⊭ φ : counterexample may be spurious

Spurious counterexample in Over-approximation Deadend states I Bad States I Failure State f

Refinement Problem: Deadend and Bad States are in the same abstract state. Solution: Refine abstraction function. The sets of Deadend and Bad states should be separated into different abstract states.

Refinement h’ Refinement : h’

Automated Abstraction/Refinement Good abstractions are hard to obtain Automate both Abstraction and Refinement processes Counterexample-Guided AR (CEGAR) Build an abstract model M’ Model check property P, M’ ⊨ P? If M’ ⊨ P, then M ⊨ P by Preservation Theorem Otherwise, check if Counterexample (CE) is spurious Refine abstract state space using CE analysis results Repeat

Counterexample-Guided Abstraction-Refinement (CEGAR) Build New Abstract Model Model Check M M’ Pass No Bug Fail Check Counterexample Obtain Refinement Cue Spurious CE Real CE Bug