Sarmad ¡Makhdoom ¡ 2012-‑03-‑0019 ¡ ¡ Supervisors ¡ Dr ¡Junaid ¡Haroon ¡Siddiqui ¡ Dr ¡Arif ¡Zaman ¡
Incremental Symbolic Execution Sarmad Makhdoom 2012-03-0019 - - PowerPoint PPT Presentation
Incremental Symbolic Execution Sarmad Makhdoom 2012-03-0019 - - PowerPoint PPT Presentation
Incremental Symbolic Execution Sarmad Makhdoom 2012-03-0019 Supervisors Dr Junaid Haroon Siddiqui Dr Arif Zaman Introduction What is soAware tesCng? Its
- What ¡is ¡soAware ¡tesCng? ¡
▫ It’s ¡all ¡about ¡finding ¡bugs ¡
- Why ¡do ¡we ¡need ¡to ¡test? ¡
▫ Bugs ¡fixing ¡cost ¡is ¡increasing ¡
- How ¡do ¡we ¡test? ¡
▫ StaCc ¡vs ¡Dynamic ¡analysis ¡
- Famous ¡failures ¡ ¡
▫ Ariane ¡5 ¡Explosion ¡($500m) ¡[h#p://www.ima.umn.edu/~arnold/disasters/ariane.html] ¡ ▫ NASA ¡Mars ¡Climate ¡Orbiter ¡($125m) ¡[h#p://mars.jpl.nasa.gov/msp98/news/mco991110.html] ¡
Introduction
- Background ¡
- MoCvaCon ¡
- Technique ¡
- EvaluaCon ¡
- Related ¡Work ¡
- Conclusion ¡
Outline
Background
int ¡mid(int ¡x, ¡int ¡y, ¡int ¡z) ¡{ ¡ ¡ ¡if ¡(x<y){ ¡ ¡ ¡ ¡ ¡if ¡(y<z){ ¡ ¡ ¡ ¡ ¡ ¡ ¡return ¡y; ¡ ¡ ¡ ¡ ¡}else{ ¡ ¡ ¡ ¡ ¡ ¡ ¡if ¡(x<z) ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡return ¡z; ¡ ¡ ¡ ¡ ¡ ¡ ¡else ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡return ¡x; ¡ ¡ ¡ ¡ ¡} ¡ ¡ ¡}else{ ¡ ¡ ¡ ¡ ¡if ¡(x<z){ ¡ ¡ ¡ ¡ ¡ ¡ ¡return ¡x; ¡ ¡ ¡ ¡ ¡}else{ ¡ ¡ ¡ ¡ ¡ ¡ ¡if ¡(y<z) ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡return ¡z; ¡ ¡ ¡ ¡ ¡ ¡ ¡else ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡return ¡y; ¡ ¡ ¡ ¡ ¡} ¡ ¡ ¡} ¡ } ¡
Concrete Execution
x=1 ¡ y=3 ¡ z=2 ¡ Concrete ¡test ¡
{} x < y x < y, y ≥ z x < z ≤ y
{} x < y x < y, y < z x < y, y ≥ z x < z ≤ y z ≤ x < y x ≥ y x ≥ y, x < z x ≥ y, x ≥ z y < z ≤ x z ≤ y ≤ x {} x < y x < y, y < z x < y, y ≥ z x < z ≤ y z ≤ x < y x ≥ y x ≥ y, x < z x ≥ y, x ≥ z y < z ≤ x z ≤ y ≤ x
int ¡mid(int ¡x, ¡int ¡y, ¡int ¡z) ¡{ ¡ ¡ ¡if ¡(x<y){ ¡ ¡ ¡ ¡ ¡if ¡(y<z){ ¡ ¡ ¡ ¡ ¡ ¡ ¡return ¡y; ¡ ¡ ¡ ¡ ¡}else{ ¡ ¡ ¡ ¡ ¡ ¡ ¡if ¡(x<z) ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡return ¡z; ¡ ¡ ¡ ¡ ¡ ¡ ¡else ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡return ¡x; ¡ ¡ ¡ ¡ ¡} ¡ ¡ ¡}else{ ¡ ¡ ¡ ¡ ¡if ¡(x<z){ ¡ ¡ ¡ ¡ ¡ ¡ ¡return ¡x; ¡ ¡ ¡ ¡ ¡}else{ ¡ ¡ ¡ ¡ ¡ ¡ ¡if ¡(y<z) ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡return ¡z; ¡ ¡ ¡ ¡ ¡ ¡ ¡else ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡return ¡y; ¡ ¡ ¡ ¡ ¡} ¡ ¡ ¡} ¡ } ¡
Symbolic Execution Demo
Path ¡condiCon ¡ (feasible) ¡
x=1 ¡ y=3 ¡ z=2 ¡
Solve ¡ Concrete ¡Test ¡
- Concrete ¡execuCon ¡fixes ¡input ¡variables ¡and ¡exercises ¡one ¡path ¡per ¡
input ¡
- Symbolic ¡execuCon ¡uses ¡symbols ¡with ¡no ¡restricCons ¡other ¡than ¡type ¡
- Both ¡branches ¡of ¡every ¡condiCon ¡in ¡the ¡program ¡are ¡explored ¡
- A ¡path ¡condiCon ¡is ¡built ¡for ¡every ¡path ¡and ¡contains ¡the ¡constraints ¡
required ¡to ¡take ¡this ¡path ¡
Symbolic Execution [CACM’76]
“Symbolic ¡ExecuFon ¡and ¡Program ¡TesFng” ¡– ¡CACM ¡1976 ¡
Ranged Symbolic Execution [OOPSLA’12]
{} x > y x < y, y < z x < y, y ≥ z x < z ≤ y z ≤ x < y x ≥ y x ≥ y, x < z x ≥ y, x ≥ z y < z ≤ x z ≤ y ≤ x
x=1 ¡ y=3 ¡ z=2 ¡
unexplored ¡ explored ¡
Scaling ¡symbolic ¡execuFon ¡using ¡ranged ¡analysis. ¡ACM-‑OOPSLA ¡2012 ¡
Ranged Symbolic Execution [OOPSLA’12]
{} x > y x < y, y < z x < y, y ≥ z x < z ≤ y z ≤ x < y x ≥ y x ≥ y, x < z x ≥ y, x ≥ z y < z ≤ x z ≤ y ≤ x
x=1 ¡ y=3 ¡ z=2 ¡ x=2 ¡ y=1 ¡ z=3 ¡
Skip ¡ Skip ¡
Explore ¡
Scaling ¡symbolic ¡execuFon ¡using ¡ranged ¡analysis. ¡ACM-‑OOPSLA ¡2012 ¡
- An ¡open ¡source ¡symbolic ¡executor ¡based ¡on ¡LLVM ¡
▫ Generate ¡high ¡coverage ¡test ¡cases ¡
- LLVM ¡(Low ¡Level ¡Virtual ¡Machine) ¡
▫ Converts ¡code ¡into ¡bytecode ¡
- Constraint ¡Solving ¡
▫ STP ¡(fast ¡SMT ¡solver) ¡
KLEE [OSDI’08]
LLVM bytecode
K L E E
SYMBOLIC ENVIRONMENT Constraint Solver (STP) x ¡= ¡3 ¡
x ¡= ¡-‑2 ¡ x ¡= ¡1234 ¡ x ¡= ¡3 ¡
C code
x ¡≥ ¡0 ¡ x ¡≠ ¡1234 ¡
L L V M
KLEE: ¡Unassisted ¡and ¡AutomaFc ¡GeneraFon ¡of ¡High-‑Coverage ¡Tests ¡for ¡Complex ¡Systems ¡Programs, ¡OSDI ¡2008 ¡
Incremental Testing
Code ¡v1.0 ¡ Code ¡v1.1 ¡
ModificaCon ¡
X ¡X ¡X ¡X ¡X ¡X ¡X ¡X ¡X ¡X ¡X ¡X ¡
Test ¡Suite ¡
Incremental Testing
Code ¡v1.0 ¡ Code ¡v1.1 ¡
ModificaCon ¡
X ¡X ¡X ¡X ¡X ¡X ¡X ¡X ¡X ¡X ¡X ¡X ¡
Test ¡Suite ¡
Incremental Testing
Code ¡v1.0 ¡ Code ¡v1.1 ¡
ModificaCon ¡
X ¡X ¡X ¡X ¡X ¡X ¡X ¡X ¡X ¡X ¡X ¡X ¡
Test ¡Suite ¡
X ¡X ¡X ¡X ¡X ¡
Test ¡Suite ¡
Incremental Testing
Code ¡v1.0 ¡ Code ¡v1.1 ¡
ModificaCon ¡
X ¡X ¡X ¡X ¡X ¡ X ¡X ¡X ¡X ¡X ¡X ¡X ¡X ¡X ¡X ¡X ¡X ¡
Test ¡Suite ¡ Test ¡Suite ¡
Final ¡Test ¡Suite ¡
Motivation
- All ¡execuCon ¡paths ¡may ¡be ¡very ¡large ¡and ¡may ¡not ¡be ¡of ¡interest ¡
- Only ¡execuCon ¡paths ¡that ¡differ ¡between ¡two ¡versions ¡are ¡of ¡interest ¡
- Test ¡only ¡program ¡changes ¡not ¡the ¡whole ¡program ¡
- Incremental ¡symbolic ¡execuCon ¡is ¡useful ¡in ¡bug ¡finding ¡and ¡regression ¡
tesCng ¡
Motivation
Technique
- Majority ¡of ¡search ¡space ¡is ¡invalid ¡
- Solving ¡path ¡condiCons ¡is ¡expensive ¡
- Comparing ¡and ¡validaCng ¡of ¡path ¡condiCons ¡is ¡cheap ¡
- One ¡way ¡is ¡to ¡compare ¡both ¡CFGs ¡[DiSE’11] ¡
▫ StaCc ¡analysis ¡ ▫ Inexact ¡(in-‑depth ¡node ¡changes ¡are ¡problemaCc) ¡ ¡ ¡ ▫ Scalability ¡issues ¡
Key Ideas
- Full ¡symbolic ¡execuCon ¡with ¡iniCal ¡version: ¡
▫ Generates ¡inputs ¡for ¡each ¡disCnct ¡path ¡
- Incremental ¡symbolic ¡execuCon ¡on ¡subsequent ¡versions ¡
▫ On ¡exploraCon ¡divide ¡tests ¡based ¡on ¡each ¡branch ¡condiCon ¡ ▫ Compare ¡and ¡validate ¡tests ¡
If ¡test ¡is ¡valid, ¡don’t ¡use ¡solver ¡ If ¡test ¡is ¡invalid, ¡explore ¡the ¡program ¡for ¡new ¡states ¡
Technique
Algorithm
Algorithm ¡to ¡explore ¡new ¡ranges ¡and ¡not ¡solving ¡the ¡present ¡ path ¡condiCons ¡in ¡the ¡new ¡program ¡
Technique
¡ ¡
t1, ¡t2, ¡t3, ¡t4, ¡t5, ¡t6,…, ¡tn ¡
Evaluate ¡& ¡Compare ¡ P ¡
t1, ¡t2, ¡t3, ¡t4 ¡ t1, ¡t2, ¡t3 ¡ t1, ¡t2 ¡ t1 ¡
Technique
¡ ¡
Evaluate ¡& ¡Compare ¡ P ¡
t1, ¡t2, ¡t3, ¡t4, ¡t5, ¡t6,…, ¡tn ¡ t1, ¡t2, ¡t3, ¡t4 ¡ t1, ¡t2, ¡t3 ¡ t1, ¡t2 ¡ t2 ¡
Technique
¡ ¡
Ï ¡Invalidates ¡
t1, ¡t2, ¡t3, ¡t4, ¡t5, ¡t6,…, ¡tn ¡
Technique
¡ ¡
Ï ¡Invalidates ¡
t1, ¡t2, ¡t3, ¡t4, ¡t5, ¡t6,…, ¡tn ¡
Technique
¡ ¡
Evaluate ¡& ¡Compare ¡ P ¡
t1, ¡t2, ¡t3, ¡t4, ¡t5, ¡t6,…, ¡tn ¡ t5, ¡t6, ¡t7, ¡t8 ¡ t5, ¡t6, ¡t7 ¡ t6, ¡t7 ¡ t8 ¡
Technique
¡ ¡
Range ¡need ¡to ¡be ¡explored ¡ t1, ¡t2, ¡t3, ¡t4, ¡t5, ¡t6,…, ¡tn ¡
What ¡if ¡there ¡is ¡some ¡infeasible ¡path ¡become ¡feasible ¡now? ¡
”New ¡code ¡in ¡two ¡consecuFve ¡valid ¡test ¡cases” ¡
Explanation
Valid ¡Test ¡1 ¡ Valid ¡Test ¡2 ¡ Infeasible ¡area ¡ Change ¡
Ï ¡
Evaluation
- Incremental ¡tesCng ¡on ¡two ¡different ¡GNU ¡CoreuCls ¡Suite ¡
▫ Minor ¡update ¡release ¡(v7.1 ¡à ¡v7.2) ¡ ▫ Major ¡update ¡release ¡(v7.2 ¡à ¡v8.1) ¡
¡
- 85 ¡stand-‑alone ¡(i.e. ¡excluding ¡wrappers) ¡apps ¡ ¡
▫ File ¡system ¡management: ¡ls, ¡mkdir, ¡chmod, ¡etc. ¡ ▫ Management ¡of ¡system ¡properCes: ¡hostname, ¡printenv, ¡etc. ¡ ▫ Text ¡file ¡processing ¡: ¡sort, ¡wc, ¡od, ¡etc. ¡ ¡ ▫ … ¡
- Tests ¡performed ¡on ¡Lonestar ¡Linux ¡cluster ¡at ¡TACC ¡
¡ ¡ ¡ ¡ ¡ ¡(hmp://tacc.utexas.edu/) ¡
Evaluation
Results of Evaluation (v7.1àv7.2 – Running Time)
71% ¡Time ¡Saved ¡
Results of Evaluation (v7.1àv7.2 – Solver Time)
79% ¡Time ¡Saved ¡
Results of Evaluation (v7.2àv8.1 – Running Time)
73% ¡Time ¡Saved ¡
Results of Evaluation (v7.2àv8.1 – Solver Time)
78% ¡Time ¡Saved ¡
Related Work
- Compute ¡affected ¡locaCon ¡by ¡comparing ¡CFGs ¡
- Their ¡technique ¡is ¡based ¡on ¡staCc ¡analysis ¡and ¡reachability ¡analysis ¡
- Perform ¡symbolic ¡execuCon ¡on ¡only ¡modified ¡CFG ¡
- Out ¡technique ¡perform ¡dynamic ¡analysis ¡
- Generate ¡test ¡suite ¡for ¡whole ¡new ¡program ¡not ¡only ¡for ¡modified ¡area ¡
Directed Incremental Symbolic Execution [PLDI’11]
Directed ¡incremental ¡symbolic ¡execuFon. ¡PLDI ¡2011 ¡
- Combines ¡staCc ¡and ¡dynamic ¡analysis ¡for ¡increased ¡coverage ¡
- Katch ¡select ¡tests ¡from ¡manual ¡generated ¡test ¡suite ¡
- Perform ¡heurisCcs ¡based ¡dynamic ¡analysis ¡to ¡increase ¡chance ¡of ¡hipng ¡
modified ¡code ¡
- Execute ¡modified ¡code ¡symbolically ¡for ¡test ¡suite ¡generaCon ¡
- We ¡don’t ¡use ¡staCc ¡analysis ¡or ¡manual ¡test ¡suite ¡for ¡incremental ¡tesCng ¡
- Our ¡technique ¡can ¡also ¡explore ¡in ¡deeper ¡depth ¡in ¡less ¡Cme ¡
KATCH [FSE’13]
KATCH: ¡High-‑Coverage ¡TesFng ¡of ¡So^ware ¡Patches. ¡FSE ¡2013 ¡
- Cache ¡based ¡symbolic ¡execuCon ¡technique ¡
- Store ¡the ¡results ¡in ¡trie-‑based ¡data ¡structure ¡
- Re-‑use ¡results ¡from ¡previous ¡run ¡by ¡maintaining ¡and ¡updaCng ¡trie ¡
- Saving ¡relies ¡on ¡posiCon ¡on ¡change ¡
- Our ¡proposed ¡technique ¡based ¡on ¡ranged ¡analysis ¡is ¡more ¡effecCve ¡
- Low ¡cost ¡of ¡storing ¡tests ¡
Memoized Symbolic Execution [ISSTA’12]
Memoized ¡Symbolic ¡ExecuFon. ¡ISSTTA ¡2012 ¡
- An ¡interface ¡between ¡analyzer ¡and ¡solver ¡
- Benefits ¡
▫ Reuse ¡within ¡an ¡analysis ¡run ¡ ▫ Reuse ¡Across ¡Programs, ¡Analyses, ¡Solvers ¡
- Procedure ¡
▫ Path ¡CondiConing ¡Slicing ¡ ▫ CanonizaCon ¡ ▫ Storage ¡ ▫ The ¡Green ¡Solver ¡Interface ¡
Green: Reducing, Reusing and Recycling Constraints [FSE’12]
Green: ¡Reduce, ¡reuse ¡and ¡recycle ¡constraints ¡in ¡program ¡analysis, ¡in ¡FSE. ¡ACM, ¡2012 ¡
Continued…
Green: ¡Reduce, ¡reuse ¡and ¡recycle ¡constraints ¡in ¡program ¡analysis, ¡in ¡FSE. ¡ACM, ¡2012 ¡
Program ¡Analysis ¡ Slice ¡ Canonize ¡ Reuse ¡ Translate ¡ soluCon ¡store ¡ Solver ¡
Conclusion
- Symbolic ¡execuCon ¡allows ¡us ¡to ¡reason ¡about ¡mulCple ¡concrete ¡
execuCons ¡
- Ranged ¡symbolic ¡execuCon ¡allows ¡dividing ¡the ¡problem ¡of ¡symbolic ¡
execuCon ¡
- The ¡proposed ¡Incremental ¡technique ¡enables ¡more ¡effecFve ¡and ¡
efficient ¡tesCng ¡of ¡code ¡using ¡symbolic ¡execuCon ¡
▫ Fully ¡dynamic ¡approach ¡to ¡find ¡changes ¡ ▫ Incremental ¡tesCng ¡in ¡much ¡less ¡Cme ¡
- Results ¡show ¡Cme ¡saving ¡for ¡the ¡same ¡programs ¡running ¡incrementally ¡
- n ¡their ¡new ¡versions ¡