isolating failure causes
play

Isolating Failure Causes Andreas Zeller 1 Isolating Causes Actual - PDF document

Isolating Failure Causes Andreas Zeller 1 Isolating Causes Actual world Alternate world ? Test Mixed world 2 2 Isolating Causes Alternate world Actual world +1.0 How can we automate this? ? Test Mixed world 3


  1. Isolating Failure Causes Andreas Zeller 1 Isolating Causes Actual world Alternate world ✔ ✘ ? Test Mixed world 2 2 Isolating Causes Alternate world Actual world +1.0 How can we automate this? ✘ ✔ ? Test Mixed world 3 3

  2. Simplifying Input ✘ <SELECT NAME="priority" MULTIPLE SIZE=7> ✔ <SELECT NAME="priority" MULTIPLE SIZE=7> ✔ <SELECT NAME="priority" MULTIPLE SIZE=7> <SELECT NAME="priority" MULTIPLE SIZE=7> ✔ ✘ <SELECT NAME="priority" MULTIPLE SIZE=7> ✘ <SELECT NAME="priority" MULTIPLE SIZE=7> ✔ <SELECT NAME="priority" MULTIPLE SIZE=7> 4 4 Simplifying Input ✘ ✘ ✘ Failure Cause … ✘ ✔ 5 5 Isolating Input ✘ <SELECT NAME="priority" MULTIPLE SIZE=7> Difference narrowed down <SELECT NAME="priority" MULTIPLE SIZE=7> ✔ ✔ <SELECT NAME="priority" MULTIPLE SIZE=7> 6 6

  3. Isolating Input ✘ <SELECT NAME="priority" MULTIPLE SIZE=7> ✘ <SELECT NAME="priority" MULTIPLE SIZE=7> <SELECT NAME="priority" MULTIPLE SIZE=7> ✔ ✔ <SELECT NAME="priority" MULTIPLE SIZE=7> Failure Cause ✔ <SELECT NAME="priority" MULTIPLE SIZE=7> ✔ <SELECT NAME="priority" MULTIPLE SIZE=7> ✔ <SELECT NAME="priority" MULTIPLE SIZE=7> 7 7 Isolating Input ✘ ✘ … ✘ ✔ Failure Cause … ✔ ✔ 8 8 Finding Causes Simplifying Isolating Input Input ! ! ! ! … ! ! " … Failure Cause ! … Failure Cause " " " 5 7 • minimal input • minimal difference • minimal context • common context 9 9

  4. Configuration Circumstance δ All circumstances C = { δ 1 , δ 2 , . . . } Configuration c ⊆ C c = { δ 1 , δ 2 , . . . δ n } 10 10 Tests Testing function test (c) ∈ { ✔ , ✘ , ? } Initial configurations test (c ✔ ) = ✔ test (c ✘ ) = ✘ 11 11 Minimal Di fg erence Goal: Subsets ✘ and c � c � ✔ ∅ = c ✔ ⊆ c � ✔ ⊂ c � ✘ ⊆ c ✘ Difference ∆ = c � ✘ \ c � ✔ Difference is 1-minimal ∀ δ i ∈ ∆ · test (c � ✔ ∪ { δ i } ) �= ✔ ∧ test (c � ✘ \ { δ i } ) �= ✘ 12 12

  5. Isolating Input test (c ✘ ) = ✘ ✘ ✘ … ∆ = c � ✘ \ c � ✘ ✔ ✔ Failure Cause … ✔ test (c ✔ ) = ✔ ✔ 13 Algorithm Sketch • Extend ddmin such that it works on two sets at a time – and c � c � ✘ ✔ • Compute subsets ∆ 1 ∪ ∆ 2 ∪ · · · ∪ ∆ n = ∆ = c � ✘ \ c � ✔ • For each subset, test • the addition c � ✔ ∪ ∆ i • the removal c � ✘ \ ∆ i 14 14 Test Outcomes ✘ ✔ = c � ✘ \ = c � t (c � ✘ \ ∆ ✘ \ ✔ ∪ = c � = c � t (c � ✔ ∪ ✔ ∪ otherwise increase gra e granularity most valuable outcomes 15 15

  6. dd in a Nutshell ∆ = c � ✘ \ c � ✔ is 1-minimal dd (c ✔ , c ✘ ) = (c � ✔ , c � ✘ ) dd (c ✔ , c ✘ ) = dd � (c ✔ , c ✘ , 2 ) dd � (c � ✔ , c � ✘ , n) =  (c � ✔ , c � ✘ ) if | ∆ | = 1    dd � (c �  ✘ \ ∆ i , c � if ∃ i ∈ { 1 ..n } · test (c � ✘ , 2 ) ✘ \ ∆ i ) = ✔      dd � (c � ✔ , c � if ∃ i ∈ { 1 ..n } · test (c �  ✔ ∪ ∆ i , 2 ) ✔ ∪ ∆ i ) = ✘     dd � � c � ✔ ∪ ∆ i , c � else if ∃ i ∈ { 1 ..n } · test (c � ✘ , max (n − 1 , 2 ) � ✔ ∪ ∆ i ) = ✔  dd � � c � ✔ , c � else if ∃ i ∈ { 1 ..n } · test (c �  ✘ \ ∆ i , max (n − 1 , 2 ) � ✘ \ ∆ i ) = ✘     dd � �  c � ✔ , c � ✘ , min ( 2 n, | ∆ | ) � else if n < | ∆ | (“increase granularity”)      (c � ✔ , c �  ✘ ) otherwise  16 16 def dd(c_pass, c_fail): n = 2 while 1: delta = listminus(c_fail, c_pass) deltas = split(delta, n); offset = 0; j = 0 while j < n: i = (j + offset) % n next_c_pass = listunion(c_pass, deltas[i]) next_c_fail = listminus(c_fail, deltas[i]) if test(next_c_fail) == FAIL and n == 2: c_fail = next_c_fail; n = 2; offset = 0; break elif test(next_c_fail) == PASS: c_pass = next_c_fail; n = 2; offset = 0; break elif test(next_c_pass) == FAIL: c_fail = next_c_pass; n = 2; offset = 0; break elif test(next_c_fail) == FAIL: c_fail = next_c_fail; n = max(n - 1, 2); offset = i; break elif test(next_c_pass) == PASS: c_pass = next_c_pass; n = max(n - 1, 2); offset = i; break else: j = j + 1 if j >= n: if n >= len(delta): return (delta, c_pass, c_fail) else: n = min(len(delta), n * 2) 17 17 Properties number of tests t – worst case: t = | ∆ | 2 + 7 | ∆ | where ∆ = c ✘ \ c ✔ number of tests t – best case (no unresolved outcomes): t ≤ log 2 ( ∆ ) size of difference – no unresolved outcomes | c � ✘ \ c � ✔ | = 1 18 18

  7. Applications Code Input Schedules Changes 19 19 Applications Code Input Schedules Changes 20 20 Isolating Input ✘ <SELECT NAME="priority" MULTIPLE SIZE=7> ✘ <SELECT NAME="priority" MULTIPLE SIZE=7> <SELECT NAME="priority" MULTIPLE SIZE=7> ✔ Isolation: 5 tests ✔ <SELECT NAME="priority" MULTIPLE SIZE=7> Failure Cause Simplification: 48 tests ✔ <SELECT NAME="priority" MULTIPLE SIZE=7> ✔ <SELECT NAME="priority" MULTIPLE SIZE=7> ✔ <SELECT NAME="priority" MULTIPLE SIZE=7> 21 21

  8. DDInput 22 22 Applications Code Input Schedules Changes 23 23 Applications Code Input Schedules Changes 24 24

  9. Code Changes From: Brian Kahne <bkahne@ibmoto.com> To: DDD Bug Report Address <bug-ddd@gnu.org> Subject: Problem with DDD and GDB 4.17 When using DDD with GDB 4.16, the run command correctly uses any prior command-line arguments, or the value of "set args". However, when I switched to GDB 4.17, this no longer worked: If I entered a run command in the console window, the prior command- line options would be lost. [...] 25 25 Version Di fg erences New version Program works Wie finden wir Old version Program fails die alternative Welt? Causes 26 26 What was Changed $ diff -r gdb-4.16 gdb-4.17 diff -r gdb-4.16/COPYING gdb-4.17/COPYING 5c5 < 675 Mass Ave, Cambridge, MA 02139, USA --- > 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 282c282 < Appendix: How to Apply These Terms to Your New Programs --- > How to Apply These Terms to Your New Programs …and so on for 178,200 lines (8,721 locations) 27 27

  10. Challenges • Granularity – within some large change, only a few lines may be relevant • Interference – some (later) changes rely on other (earlier) changes • Inconsistency – some changes may have to be combined to produce testable code Delta debugging handles all this 28 28 General Plan • Decompose diff into changes per location (= 8,721 individual changes) • Apply subset of changes, using PATCH • Reconstruct GDB; build errors mean unresolved test outcome • Test GDB and return outcome 29 29 Isolating Changes Delta Debugging Log 100000 GDB with ddmin algorithm ... with dd algorithm 10000 ... plus scope information Changes left 1000 100 10 1 0 50 100 150 200 250 300 Tests executed • Result after 98 tests (= 1 hour) 30 30

  11. The Failure Cause diff -r gdb-4.16/gdb/infcmd.c gdb-4.17/gdb/infcmd.c 1239c1278 < "Set arguments to give program being debugged when it is started.\n --- > "Set argument list to give program being debugged when it is started.\n • Documentation becomes GDB output • DDD expects Arguments, but GDB outputs Argument list 31 31 DDChange 32 32 Optimizations • History – group changes by creation time • Reconstruction – cache several builds • Grouping – according to scope • Failure Resolution – scan error messages for possibly missing changes 33 33

  12. Applications Code Input Schedules Changes 34 34 Applications Code Input Schedules Changes 35 35 Thread Schedules Schedule Thread A Thread B Schedule Thread A Thread B open(".htpasswd") open(".htpasswd") read(...) open(".htpasswd") modify(...) read(...) write(...) read(...) close(...) modify(...) open(".htpasswd") write(...) Thread read(...) close(...) Switch modify(...) modify(...) write(...) write(...) close(...) close(...) ! " A’s updates get lost! 36 36

  13. Record + Replay recorded schedule x = 45 y = 39 z = 67 record replay x = 45 x = 45 y = 39 y = 39 z = 67 z = 67 x = 45 y = 39 z = 67 DEJAVU 37 37 Schedules as Input replay replay ! " The schedule difference causes the failure! 38 38 Finding Di fg erences t1 • We start with runs ! and " • We determine the di ff erences t2 ∆ i between thread switches t i : – t 1 occurs in ! at “time” 254 – t 1 occurs in " at “time” 278 – The di ff erence t3 ∆ 1 = | 278 − 254 | induces a statement interval: the code executed between “time” 254 and 278 " ! – Same applies to t 2 , t 3 , etc. 39 39

Recommend


More recommend