Incremental Symbolic Execution Sarmad Makhdoom 2012-03-0019 - - PowerPoint PPT Presentation

incremental symbolic execution
SMART_READER_LITE
LIVE PREVIEW

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


slide-1
SLIDE 1

Sarmad ¡Makhdoom ¡ 2012-­‑03-­‑0019 ¡ ¡ Supervisors ¡ Dr ¡Junaid ¡Haroon ¡Siddiqui ¡ Dr ¡Arif ¡Zaman ¡

Incremental Symbolic Execution

slide-2
SLIDE 2
  • 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

slide-3
SLIDE 3
  • Background ¡
  • MoCvaCon ¡
  • Technique ¡
  • EvaluaCon ¡
  • Related ¡Work ¡
  • Conclusion ¡

Outline

slide-4
SLIDE 4

Background

slide-5
SLIDE 5

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

slide-6
SLIDE 6

{} 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 ¡

slide-7
SLIDE 7
  • 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 ¡

slide-8
SLIDE 8

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 ¡

slide-9
SLIDE 9

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 ¡

slide-10
SLIDE 10
  • 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 ¡

slide-11
SLIDE 11

Incremental Testing

Code ¡v1.0 ¡ Code ¡v1.1 ¡

ModificaCon ¡

X ¡X ¡X ¡X ¡X ¡X ¡X ¡X ¡X ¡X ¡X ¡X ¡

Test ¡Suite ¡

slide-12
SLIDE 12

Incremental Testing

Code ¡v1.0 ¡ Code ¡v1.1 ¡

ModificaCon ¡

X ¡X ¡X ¡X ¡X ¡X ¡X ¡X ¡X ¡X ¡X ¡X ¡

Test ¡Suite ¡

slide-13
SLIDE 13

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 ¡

slide-14
SLIDE 14

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 ¡

slide-15
SLIDE 15

Motivation

slide-16
SLIDE 16
  • 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

slide-17
SLIDE 17

Technique

slide-18
SLIDE 18
  • 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

slide-19
SLIDE 19
  • 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

slide-20
SLIDE 20

Algorithm

Algorithm ¡to ¡explore ¡new ¡ranges ¡and ¡not ¡solving ¡the ¡present ¡ path ¡condiCons ¡in ¡the ¡new ¡program ¡

slide-21
SLIDE 21

Technique

¡ ¡

t1, ¡t2, ¡t3, ¡t4, ¡t5, ¡t6,…, ¡tn ¡

Evaluate ¡& ¡Compare ¡ P ¡

t1, ¡t2, ¡t3, ¡t4 ¡ t1, ¡t2, ¡t3 ¡ t1, ¡t2 ¡ t1 ¡

slide-22
SLIDE 22

Technique

¡ ¡

Evaluate ¡& ¡Compare ¡ P ¡

t1, ¡t2, ¡t3, ¡t4, ¡t5, ¡t6,…, ¡tn ¡ t1, ¡t2, ¡t3, ¡t4 ¡ t1, ¡t2, ¡t3 ¡ t1, ¡t2 ¡ t2 ¡

slide-23
SLIDE 23

Technique

¡ ¡

Ï ¡Invalidates ¡

t1, ¡t2, ¡t3, ¡t4, ¡t5, ¡t6,…, ¡tn ¡

slide-24
SLIDE 24

Technique

¡ ¡

Ï ¡Invalidates ¡

t1, ¡t2, ¡t3, ¡t4, ¡t5, ¡t6,…, ¡tn ¡

slide-25
SLIDE 25

Technique

¡ ¡

Evaluate ¡& ¡Compare ¡ P ¡

t1, ¡t2, ¡t3, ¡t4, ¡t5, ¡t6,…, ¡tn ¡ t5, ¡t6, ¡t7, ¡t8 ¡ t5, ¡t6, ¡t7 ¡ t6, ¡t7 ¡ t8 ¡

slide-26
SLIDE 26

Technique

¡ ¡

Range ¡need ¡to ¡be ¡explored ¡ t1, ¡t2, ¡t3, ¡t4, ¡t5, ¡t6,…, ¡tn ¡

slide-27
SLIDE 27

What ¡if ¡there ¡is ¡some ¡infeasible ¡path ¡become ¡feasible ¡now? ¡

”New ¡code ¡in ¡two ¡consecuFve ¡valid ¡test ¡cases” ¡

slide-28
SLIDE 28

Explanation

Valid ¡Test ¡1 ¡ Valid ¡Test ¡2 ¡ Infeasible ¡area ¡ Change ¡

Ï ¡

slide-29
SLIDE 29

Evaluation

slide-30
SLIDE 30
  • 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

slide-31
SLIDE 31

Results of Evaluation (v7.1àv7.2 – Running Time)

71% ¡Time ¡Saved ¡

slide-32
SLIDE 32

Results of Evaluation (v7.1àv7.2 – Solver Time)

79% ¡Time ¡Saved ¡

slide-33
SLIDE 33

Results of Evaluation (v7.2àv8.1 – Running Time)

73% ¡Time ¡Saved ¡

slide-34
SLIDE 34

Results of Evaluation (v7.2àv8.1 – Solver Time)

78% ¡Time ¡Saved ¡

slide-35
SLIDE 35

Related Work

slide-36
SLIDE 36
  • 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 ¡

slide-37
SLIDE 37
  • 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 ¡

slide-38
SLIDE 38
  • 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 ¡

slide-39
SLIDE 39
  • 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 ¡

slide-40
SLIDE 40

Continued…

Green: ¡Reduce, ¡reuse ¡and ¡recycle ¡constraints ¡in ¡program ¡analysis, ¡in ¡FSE. ¡ACM, ¡2012 ¡

Program ¡Analysis ¡ Slice ¡ Canonize ¡ Reuse ¡ Translate ¡ soluCon ¡store ¡ Solver ¡

slide-41
SLIDE 41

Conclusion

slide-42
SLIDE 42
  • 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 ¡

Conclusion

slide-43
SLIDE 43

Questions