Download presentation
Presentation is loading. Please wait.
Published byRichard Blocker Modified over 9 years ago
1
1/20 Generalized Symbolic Execution for Model Checking and Testing Charngki Hong @ PSWLAB Generalized Symbolic Execution for Model Checking and Testing Sarfraz Khurshid, Corina S. P ă s ă reanu, and Willem Visser TACAS 2003
2
2/20 Generalized Symbolic Execution for Model Checking and Testing Charngki Hong @ PSWLAB Contents Introduction General Methodology Background Symbolic Execution Two-fold Generalization of Symbolic Execution Lazy initialization Instrumentation Implementations Applications Conclusion
3
3/20 Generalized Symbolic Execution for Model Checking and Testing Charngki Hong @ PSWLAB Introduction (1/2) Modern software systems are concurrent and manipulate complex dynamically allocated data structures (e.g., linked lists or binary trees) Two common techniques for checking correctness of software Testing widely used but doesn’t give us an assurance is not good at finding errors related to concurrent behavior Model Checking is automatic and good at analyzing concurrent systems suffers from state-space explosion problem and typically requires a closed system, i.e., bound on input sizes Symbolic execution + model checking Symbolic execution + model checking
4
4/20 Generalized Symbolic Execution for Model Checking and Testing Charngki Hong @ PSWLAB Introduction (2/2) Symbolic execution well-known program analysis traditionally arose in the context of checking sequential programs with a fixed number of integer variables requires dedicated tools to perform the analyses and do not handle concurrent systems with complex inputs Generalization of traditional symbolic execution 1.Source to source translation to instrument a model checkable program 2.Novel symbolic execution algorithm for handling dynamically allocated structures (e.g., lists and trees)
5
5/20 Generalized Symbolic Execution for Model Checking and Testing Charngki Hong @ PSWLAB General Methodology Code Instrumentation Model Checking Decision Procedure Source Program Instrumented Program Counter example continue/backtrack Correctness specification precondition/ postcondition
6
6/20 Generalized Symbolic Execution for Model Checking and Testing Charngki Hong @ PSWLAB Background (1/2) Symbolic Execution The main idea is to use symbolic values, instead of actual data, as input values, and to represent the value of program variables as expressions The state of a symbolically executed program includes the symbolic values of program variables and a path condition (pc) A symbolic execution tree characterizes the execution paths followed during the symbolic execution of a program
7
7/20 Generalized Symbolic Execution for Model Checking and Testing Charngki Hong @ PSWLAB Background (2/2) Symbolic Execution (Example) int x, y; 1: if (x > y) { 2: x = x + y ; 3: y = x – y ; 4: x = x – y ; 5: if (x – y > 0) 6: assert(false); } x : =A y := B PC := true x : = A y := B PC := A>B x : =A y := B PC := A<=B x : =A+B, y :=B PC := A>B x : =A+B, y :=A PC := A>B x : =B, y :=A PC := A>B x : =B, y :=A PC := A>B & B-A>0 FALSE! x : =B, y :=A PC := A>B & B-A <=0 1 2 3 4 5 5 1
8
8/20 Generalized Symbolic Execution for Model Checking and Testing Charngki Hong @ PSWLAB Two-fold Generalization of symbolic execution (1/9) Lazy initialization is an algorithm for generalizing traditional symbolic execution to support advanced constructs of modern programming languages, such as Java and C++ A key feature of the lazy initialization algorithm is that it starts execution of the method on inputs with uninitialized fields and use lazy initialization to assign values to these field, i.e., it initialize fields when they are first accessed during the method’s symbolic execution
9
9/20 Generalized Symbolic Execution for Model Checking and Testing Charngki Hong @ PSWLAB Lazy initialization Two-fold Generalization of symbolic execution (2/9) if ( F is uninitialized ) { if ( F is a reference field of user-defined type T ) { nondeterministically initialize F to 1. null 2. a new object of class T (with uninitialized field values) 3. an object created during a prior initialization of a field of type T if ( method precondition is violated ) backtrack(); } if ( F is a primitive field ) initialize F to a new symbolic value of appropriate type } decision procedure : checks the path condition is satisfied. If not, backtracks
10
10/20 Generalized Symbolic Execution for Model Checking and Testing Charngki Hong @ PSWLAB class Node { int elem; Node next; Node swapNode() { 1: if (next != null) 2: if (elem > next.elem) { 3: Node t = next; 4: next = t.next; 5: t.next = this; 6: return t; } return this; } } Two-fold Generalization of symbolic execution (3/9) Lazy initialization (example) ? next Node instance with uninitialized element next field not accessed
11
11/20 Generalized Symbolic Execution for Model Checking and Testing Charngki Hong @ PSWLAB ? ? next ? ? ? consider executing 1: if (next != null) Precondition: acyclic list Two-fold Generalization of symbolic execution (4/9) ? next ? 1
12
12/20 Generalized Symbolic Execution for Model Checking and Testing Charngki Hong @ PSWLAB consider executing 2: if (elem - next.elem>0) Two-fold Generalization of symbolic execution (5/9) ? next ? 1 E0 next ? E0 next E1 next E0 next E1 next 2 PC : E0 > E1, E0 next E1 next 2 PC : E0 <= E1, } initialize “elem” } initialize “next.elem”
13
13/20 Generalized Symbolic Execution for Model Checking and Testing Charngki Hong @ PSWLAB E0 next E1 next t null t E0 next E1 next ? E0 next E1 t next E0 next E1 next t E0 next E1 next t consider executing 4: next = t.next; Precondition: acyclic list E0E1 next t null next t E0E1 next ? Two-fold Generalization of symbolic execution (6/9)
14
14/20 Generalized Symbolic Execution for Model Checking and Testing Charngki Hong @ PSWLAB Instrumentation Two steps 1. The integer fields and operations are instrumented 1. The declared type of integer fields of input objects is changed to Expression, which is a library class for manipulation of symbolic integer expression 2. The field accesses are instrumented 1. Field reads are replaced by get method, get methods implement the lazy initialization 2. Filed updates are replaced by set method Two-fold Generalization of symbolic execution (7/9)
15
15/20 Generalized Symbolic Execution for Model Checking and Testing Charngki Hong @ PSWLAB Instrumentation (example) Two-fold Generalization of symbolic execution (8/9) class Node { int elem; Node next; Node swapNode () { if (next !=null) if (elem – next.elem) >0) { Node t = next; next = t.next; t.next = this; return t; } return this; } class Node { Expression elem; Node next; boolean _next_is_initialized; boolean _elem_is_initialized; Node swapNode () { if(_get_next() != null) if(Expression._pc._update_GT( _get_elem()._minus( _get_next()._get_elem()), new IntegerConstant(0) ) { Node t = _get_next(); _set_next(t._get_next()); t._set_next(this); return t; } return this; } }
16
16/20 Generalized Symbolic Execution for Model Checking and Testing Charngki Hong @ PSWLAB Instrumentation (example) Two-fold Generalization of symbolic execution (9/9) class Expression { static PathCondition _pc; Expression _minus(Expression e) { … } class PathCondition { Constraints c; boolean _update_GT(Expression e1, Expression e2) { boolean result = choose_boolean(); if (result) c.add_constraint_GT(e1, e2); else c.add_constraint_LE(e1, e2); if (!c.is_satisfiable()) backtrack(); return result; }} nondeterministic choice add (e1 > e2) to the path condition add (e1 <= e2) to the path condition decision procedure pc
17
17/20 Generalized Symbolic Execution for Model Checking and Testing Charngki Hong @ PSWLAB Implementations Code instrumentation build on the Korat tool Model checking Java PathFinder (JPF) Decision procedure Java implementation of the Omega library
18
18/20 Generalized Symbolic Execution for Model Checking and Testing Charngki Hong @ PSWLAB Applications (1/2) Checking multithreaded programs with inputs distributed sorting method
19
19/20 Generalized Symbolic Execution for Model Checking and Testing Charngki Hong @ PSWLAB Applications (2/2) The implementation to symbolically execute distributed sort took 11 seconds to analyze the method’s correctness and it produced a counterexample input list : [X] [Y] [Z] such that X > Y > Z Thread- 1 : swaps X and Y Thread -2 : swaps X and Z resulting list : [Y] [Z] [X] ; Y and Z out of order
20
20/20 Generalized Symbolic Execution for Model Checking and Testing Charngki Hong @ PSWLAB Conclusions Novel framework based on symbolic execution, for automated checking of concurrent software systems that manipulate complex data structures Two-fold generalization Future work Plan to integrate different constraints solvers that will allow us to handle floats and non-linear constraints Symbolic execution during model checking is powerful but we don’t know how well it scales to real applications
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.