43
Software Maintenance Delta Debugging 1 Debugging [email protected] Delta

[email protected]€¦ · Software Maintenance Delta Debugging 4 . Printing this page makes Mozilla crash . Quelle: Zeller, A.; Society, I. C. & Hildebrandt, R.: Simplifying and Isolating

  • Upload
    others

  • View
    4

  • Download
    0

Embed Size (px)

Citation preview

Page 1: soma@ist.tugraz€¦ · Software Maintenance Delta Debugging 4 . Printing this page makes Mozilla crash . Quelle: Zeller, A.; Society, I. C. & Hildebrandt, R.: Simplifying and Isolating

Software Maintenance Delta Debugging

1

Debugging

[email protected]

Delta

Page 2: soma@ist.tugraz€¦ · Software Maintenance Delta Debugging 4 . Printing this page makes Mozilla crash . Quelle: Zeller, A.; Society, I. C. & Hildebrandt, R.: Simplifying and Isolating

Software Maintenance Delta Debugging

2

Outline - Delta Debugging

Motivation

Basic definitions Test result Interference Inconsistency

Algorithms Minimization Differences

Areas of application

Page 3: soma@ist.tugraz€¦ · Software Maintenance Delta Debugging 4 . Printing this page makes Mozilla crash . Quelle: Zeller, A.; Society, I. C. & Hildebrandt, R.: Simplifying and Isolating

Software Maintenance Delta Debugging

3

Motivation

Initial Situation Large Input that causes a failure

Challenge Find a smaller input that still causes the failure

Solution Use the principle of divide and conquer Minimization by Delta Debugging Developed by Andreas Zeller et al.

(www.st.cs.uni-sb.de/dd/)

Page 4: soma@ist.tugraz€¦ · Software Maintenance Delta Debugging 4 . Printing this page makes Mozilla crash . Quelle: Zeller, A.; Society, I. C. & Hildebrandt, R.: Simplifying and Isolating

Software Maintenance Delta Debugging

4

Printing this page makes Mozilla crash

Quelle: Zeller, A.; Society, I. C. & Hildebrandt, R.: Simplifying and Isolating Failure-Inducing Input IEEE Transactions on Software Engineering, 2002, 28, 2002

Excerpt:

Page 5: soma@ist.tugraz€¦ · Software Maintenance Delta Debugging 4 . Printing this page makes Mozilla crash . Quelle: Zeller, A.; Society, I. C. & Hildebrandt, R.: Simplifying and Isolating

Software Maintenance Delta Debugging

5

How do minimize this input?

Web page has over 40,000 characters

Remove single characters 40,000 tests

Better:

First: cut away large parts

Later: increase granularity

Page 6: soma@ist.tugraz€¦ · Software Maintenance Delta Debugging 4 . Printing this page makes Mozilla crash . Quelle: Zeller, A.; Society, I. C. & Hildebrandt, R.: Simplifying and Isolating

Software Maintenance Delta Debugging

6

Narrowing down hypothesis

Source: A. Zeller, www.st.cs.uni-sb.de/dd/

Possible failure cause Set up first hypothesis Test first hypothesis

Page 7: soma@ist.tugraz€¦ · Software Maintenance Delta Debugging 4 . Printing this page makes Mozilla crash . Quelle: Zeller, A.; Society, I. C. & Hildebrandt, R.: Simplifying and Isolating

Software Maintenance Delta Debugging

7

Narrowing down hypothesis

Source: A. Zeller, www.st.cs.uni-sb.de/dd/

Second hypothesis

Page 8: soma@ist.tugraz€¦ · Software Maintenance Delta Debugging 4 . Printing this page makes Mozilla crash . Quelle: Zeller, A.; Society, I. C. & Hildebrandt, R.: Simplifying and Isolating

Software Maintenance Delta Debugging

8

Narrowing down hypothesis

Source: A. Zeller, www.st.cs.uni-sb.de/dd/

Third hypothesis

Page 9: soma@ist.tugraz€¦ · Software Maintenance Delta Debugging 4 . Printing this page makes Mozilla crash . Quelle: Zeller, A.; Society, I. C. & Hildebrandt, R.: Simplifying and Isolating

Software Maintenance Delta Debugging

9

Narrowing down hypothesis

Source: A. Zeller, www.st.cs.uni-sb.de/dd/

Fourth hypothesis

Page 10: soma@ist.tugraz€¦ · Software Maintenance Delta Debugging 4 . Printing this page makes Mozilla crash . Quelle: Zeller, A.; Society, I. C. & Hildebrandt, R.: Simplifying and Isolating

Software Maintenance Delta Debugging

10

<SELECT NAME=„priority“ MULTIPLE SIZE=7> <SELECT NAME=„priority“ MULTIPLE SIZE=7> <SELECT NAME=„priority“ MULTIPLE SIZE=7> <SELECT NAME=„priority“ MULTIPLE SIZE=7>

Minimizing ...

<SELECT NAME=„priority“ MULTIPLE SIZE=7>

Page 11: soma@ist.tugraz€¦ · Software Maintenance Delta Debugging 4 . Printing this page makes Mozilla crash . Quelle: Zeller, A.; Society, I. C. & Hildebrandt, R.: Simplifying and Isolating

Software Maintenance Delta Debugging

11

<SELECT NAME=„priority“ MULTIPLE SIZE=7> <SELECT NAME=„priority“ MULTIPLE SIZE=7> <SELECT NAME=„priority“ MULTIPLE SIZE=7> <SELECT NAME=„priority“ MULTIPLE SIZE=7>

Minimizing ...

< <SELECT NAME=„priority“ MULTIPLE SIZE=7>

Page 12: soma@ist.tugraz€¦ · Software Maintenance Delta Debugging 4 . Printing this page makes Mozilla crash . Quelle: Zeller, A.; Society, I. C. & Hildebrandt, R.: Simplifying and Isolating

Software Maintenance Delta Debugging

12

<SELECT NAME=„priority“ MULTIPLE SIZE=7> <SELECT NAME=„priority“ MULTIPLE SIZE=7> <SELECT NAME=„priority“ MULTIPLE SIZE=7> <SELECT NAME=„priority“ MULTIPLE SIZE=7>

Minimizing ...

< <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>

Page 13: soma@ist.tugraz€¦ · Software Maintenance Delta Debugging 4 . Printing this page makes Mozilla crash . Quelle: Zeller, A.; Society, I. C. & Hildebrandt, R.: Simplifying and Isolating

Software Maintenance Delta Debugging

13

Problem description

Given:

Testing function test(x) mapping input x to ,,.

An input C with test(C) = .

Goal:

Search for a smaller c ⊂ C so that test(c‘) = .

Page 14: soma@ist.tugraz€¦ · Software Maintenance Delta Debugging 4 . Printing this page makes Mozilla crash . Quelle: Zeller, A.; Society, I. C. & Hildebrandt, R.: Simplifying and Isolating

Software Maintenance Delta Debugging

14

Basic definitions Testing function

Takes a program and an input

The test either

succeeds (PASS, ),

produces the failure (FAIL, ) or

produces indeterminate results (UNRES, )

Page 15: soma@ist.tugraz€¦ · Software Maintenance Delta Debugging 4 . Printing this page makes Mozilla crash . Quelle: Zeller, A.; Society, I. C. & Hildebrandt, R.: Simplifying and Isolating

Software Maintenance Delta Debugging

15

DD Process

Test case x

Program

test(x)

Delta Debugging minimize

Page 16: soma@ist.tugraz€¦ · Software Maintenance Delta Debugging 4 . Printing this page makes Mozilla crash . Quelle: Zeller, A.; Society, I. C. & Hildebrandt, R.: Simplifying and Isolating

Software Maintenance Delta Debugging

16

Basic definitions

Interference

Combination of several inputs reveals a bug

No interference: test(x) = iff „1“⊆ x test(x) = otherwise

Interference: test(x) = iff „18“⊆ x test(x) = otherwise

Page 17: soma@ist.tugraz€¦ · Software Maintenance Delta Debugging 4 . Printing this page makes Mozilla crash . Quelle: Zeller, A.; Society, I. C. & Hildebrandt, R.: Simplifying and Isolating

Software Maintenance Delta Debugging

17

Basic definitions

Inconsistency Input a cannot be applied without input b Example C = “12345678” test(x) = ? iff (“2“⊆ x ۸ “7“ ⊄ x) ۷ (“7“⊆ x ۸ “2“ ⊄ x) test(x) = iff “8“⊆ x ⊆ C test(x) = otherwise

Page 18: soma@ist.tugraz€¦ · Software Maintenance Delta Debugging 4 . Printing this page makes Mozilla crash . Quelle: Zeller, A.; Society, I. C. & Hildebrandt, R.: Simplifying and Isolating

Software Maintenance Delta Debugging

18

Basic definitions

=⊆∀ )(: ctestCc ≠⊇∀→ )'(:' ctestcc

=⊆∀ )(: ctestCc ≠⊆∀→ )'(:' ctestcc

• Monotony

Page 19: soma@ist.tugraz€¦ · Software Maintenance Delta Debugging 4 . Printing this page makes Mozilla crash . Quelle: Zeller, A.; Society, I. C. & Hildebrandt, R.: Simplifying and Isolating

Software Maintenance Delta Debugging

19

Algorithm – Version 1

|∆1| ≈ |∆2|

Page 20: soma@ist.tugraz€¦ · Software Maintenance Delta Debugging 4 . Printing this page makes Mozilla crash . Quelle: Zeller, A.; Society, I. C. & Hildebrandt, R.: Simplifying and Isolating

Software Maintenance Delta Debugging

20

Example 1

Input C = “12345678“ Function test test(x) = iff “7“ ⊆ x ⊆ C test(x) = otherwise

Page 21: soma@ist.tugraz€¦ · Software Maintenance Delta Debugging 4 . Printing this page makes Mozilla crash . Quelle: Zeller, A.; Society, I. C. & Hildebrandt, R.: Simplifying and Isolating

Software Maintenance Delta Debugging

21

Example 2

Input C = “12345678“ Function test test(x) = iff “37“ ⊆ x ⊆ C test(x) = , otherwise

Interference

Page 22: soma@ist.tugraz€¦ · Software Maintenance Delta Debugging 4 . Printing this page makes Mozilla crash . Quelle: Zeller, A.; Society, I. C. & Hildebrandt, R.: Simplifying and Isolating

Software Maintenance Delta Debugging

22

Algorithm – Version 1

Cannot deal with interference!

|∆1| ≈ |∆2|

Page 23: soma@ist.tugraz€¦ · Software Maintenance Delta Debugging 4 . Printing this page makes Mozilla crash . Quelle: Zeller, A.; Society, I. C. & Hildebrandt, R.: Simplifying and Isolating

Software Maintenance Delta Debugging

23

Algorithm – Version 2

Divide and conquer!

Page 24: soma@ist.tugraz€¦ · Software Maintenance Delta Debugging 4 . Printing this page makes Mozilla crash . Quelle: Zeller, A.; Society, I. C. & Hildebrandt, R.: Simplifying and Isolating

Software Maintenance Delta Debugging

24

Example 2

Input C = “12345678“ Function test test(x) = iff “37“ ⊆ x ⊆ C test(x) = , otherwise

Page 25: soma@ist.tugraz€¦ · Software Maintenance Delta Debugging 4 . Printing this page makes Mozilla crash . Quelle: Zeller, A.; Society, I. C. & Hildebrandt, R.: Simplifying and Isolating

Software Maintenance Delta Debugging

25

Example *

Input C = “12345678“ Function test test(x) = if “18“ ⊆ x ⊆ C test(x) = if “35“ ⊆ x ⊆ C test(x) = otherwise

Several faults

Page 26: soma@ist.tugraz€¦ · Software Maintenance Delta Debugging 4 . Printing this page makes Mozilla crash . Quelle: Zeller, A.; Society, I. C. & Hildebrandt, R.: Simplifying and Isolating

Software Maintenance Delta Debugging

26

Algorithm – Version 2

Does not work in case of several errors!

Page 27: soma@ist.tugraz€¦ · Software Maintenance Delta Debugging 4 . Printing this page makes Mozilla crash . Quelle: Zeller, A.; Society, I. C. & Hildebrandt, R.: Simplifying and Isolating

Software Maintenance Delta Debugging

27

Algorithm – Version 2

Instead use the result of

Page 28: soma@ist.tugraz€¦ · Software Maintenance Delta Debugging 4 . Printing this page makes Mozilla crash . Quelle: Zeller, A.; Society, I. C. & Hildebrandt, R.: Simplifying and Isolating

Software Maintenance Delta Debugging

28

Example **

Input C = “12345678“ Function test: test(x) = ? iff (“2“ ⊆ x ۸ “7“ ⊄ x)

۷ (“7“ ⊆ x ۸ “2“ ⊄ x) (case 1)

test(x) = iff “8“ ⊆ x ⊆ C ۸ not case 1 test(x) = otherwise

Inconsistency

Page 29: soma@ist.tugraz€¦ · Software Maintenance Delta Debugging 4 . Printing this page makes Mozilla crash . Quelle: Zeller, A.; Society, I. C. & Hildebrandt, R.: Simplifying and Isolating

Software Maintenance Delta Debugging

29

Algorithm – Version 3

Page 30: soma@ist.tugraz€¦ · Software Maintenance Delta Debugging 4 . Printing this page makes Mozilla crash . Quelle: Zeller, A.; Society, I. C. & Hildebrandt, R.: Simplifying and Isolating

Software Maintenance Delta Debugging

30

Example 4

Input C = “12345678“ Function test: test(x) = if “34“ ⊆ x ⊆ C test(x) = if “7“ ⊆ x ⊆ C test(x) = otherwise

Minimal solution?

Page 31: soma@ist.tugraz€¦ · Software Maintenance Delta Debugging 4 . Printing this page makes Mozilla crash . Quelle: Zeller, A.; Society, I. C. & Hildebrandt, R.: Simplifying and Isolating

Software Maintenance Delta Debugging

31

Minimality criterias

Global minimum An input c ⊆ C is said to be the global minimum iff

/ Requires testing all 2|C| subsets

Local minimum An input c ⊆ C is said to be the local minimum iff

/ Requires 2|c| -2 tests

|||'|)'(:')( ccctestCcctest <∧=⊆∃∧=

=⊂∃∧= )'(:')( ctestccctest

Page 32: soma@ist.tugraz€¦ · Software Maintenance Delta Debugging 4 . Printing this page makes Mozilla crash . Quelle: Zeller, A.; Society, I. C. & Hildebrandt, R.: Simplifying and Isolating

Software Maintenance Delta Debugging

32

Minimality criterias

The problem of checking local and global minimality is a decision problem which is NP-complete. n-minimality An input c ⊆ C is n-minimal iff

≠⇒≤−⊂∀ )'(|'|||:' ctestncccc

Page 33: soma@ist.tugraz€¦ · Software Maintenance Delta Debugging 4 . Printing this page makes Mozilla crash . Quelle: Zeller, A.; Society, I. C. & Hildebrandt, R.: Simplifying and Isolating

Software Maintenance Delta Debugging

33

Properties of ddmin

ddmin returns a 1-minimal result.

The complexity of ddmin is O(|c|2).

In the best case the complexity of ddmin is Ω(log2(|c|)).

Page 34: soma@ist.tugraz€¦ · Software Maintenance Delta Debugging 4 . Printing this page makes Mozilla crash . Quelle: Zeller, A.; Society, I. C. & Hildebrandt, R.: Simplifying and Isolating

Software Maintenance Delta Debugging

34

bug.c / gcc V2.95.2 (Intel-Linux) #define SIZE 20 double mult(double z[], int n) int i,j; i=0; for(j=0;j<n;j++) i = i + j +1; z[i] = z[i]*(z[0]+1.0);

return z[n]; void copy(double to[], from[], int count) int n = (count + 7 ) / 8; switch (count % 8) do case 0: *to++ = *from++; ...

while (--n > 0); return mult(to,2);

int main (...) ... return copy(y,x,SIZE);

WHICH PART CAUSES GCC TO

CRASH?

Page 35: soma@ist.tugraz€¦ · Software Maintenance Delta Debugging 4 . Printing this page makes Mozilla crash . Quelle: Zeller, A.; Society, I. C. & Hildebrandt, R.: Simplifying and Isolating

Software Maintenance Delta Debugging

35

bug.c / gcc V2.95.2 (Intel-Linux) #define SIZE 20 double mult(double z[], int n) int i,j; i=0; for(j=0;j<n;j++) i = i + j +1; z[i] = z[i]*(z[0]+1.0);

return z[n]; void copy(double to[], from[], int count) int n = (count + 7 ) / 8; switch (count % 8) do case 0: *to++ = *from++; ...

while (--n > 0); return mult(to,2);

int main (...) ... return copy(y,x,SIZE);

Remove half of the program and try gcc again.

If there is a crash, repeat removing

substrings. Otherwise, choose

a different substring.

(BINARY SEARCH)

Page 36: soma@ist.tugraz€¦ · Software Maintenance Delta Debugging 4 . Printing this page makes Mozilla crash . Quelle: Zeller, A.; Society, I. C. & Hildebrandt, R.: Simplifying and Isolating

Software Maintenance Delta Debugging

36

bug.c / gcc V2.95.2 (Intel-Linux) Result after minimization:

double mult(double z[],int n) int i,j; for(;;) i=i+j+1; z[i]=z[i]*(z[0]+1.0); return z[n];

The resulting substring is substantially smaller!

Page 37: soma@ist.tugraz€¦ · Software Maintenance Delta Debugging 4 . Printing this page makes Mozilla crash . Quelle: Zeller, A.; Society, I. C. & Hildebrandt, R.: Simplifying and Isolating

Software Maintenance Delta Debugging

37

Isolation of differences

Page 38: soma@ist.tugraz€¦ · Software Maintenance Delta Debugging 4 . Printing this page makes Mozilla crash . Quelle: Zeller, A.; Society, I. C. & Hildebrandt, R.: Simplifying and Isolating

Software Maintenance Delta Debugging

38

Example 1

Input C = “12345678“ Function test: test(x) = ? iff (“37“⊄ x) (Case 1) test(x) = iff “6“ ⊆ x ⊆ C ۸ not case 1 test(x) = otherwise

Page 39: soma@ist.tugraz€¦ · Software Maintenance Delta Debugging 4 . Printing this page makes Mozilla crash . Quelle: Zeller, A.; Society, I. C. & Hildebrandt, R.: Simplifying and Isolating

Software Maintenance Delta Debugging

39

Areas of application

Test case reduction Minimizing failure inducing input User input Data input

Code reduction Identifying software changes that lead to failures

Page 40: soma@ist.tugraz€¦ · Software Maintenance Delta Debugging 4 . Printing this page makes Mozilla crash . Quelle: Zeller, A.; Society, I. C. & Hildebrandt, R.: Simplifying and Isolating

Software Maintenance Delta Debugging

40

Case Study (Zeller 2002)

Mozilla web browser Example Crash after 95 user actions Automatic reduction to 3 relevant user actions Automatic minimization of 44 bug reports

GCC

Page 41: soma@ist.tugraz€¦ · Software Maintenance Delta Debugging 4 . Printing this page makes Mozilla crash . Quelle: Zeller, A.; Society, I. C. & Hildebrandt, R.: Simplifying and Isolating

Software Maintenance Delta Debugging

41

Conclusions

Successfully used to minimize test cases

Does not (always) find the global/local minimum

Not only for inputs of type STRING

Helps to locate bugs in software

Page 42: soma@ist.tugraz€¦ · Software Maintenance Delta Debugging 4 . Printing this page makes Mozilla crash . Quelle: Zeller, A.; Society, I. C. & Hildebrandt, R.: Simplifying and Isolating

Software Maintenance Delta Debugging

42

Example ***

Input C = “12345678“ Function test: test(x) = ? iff (“26“⊄ x) (Case 1) test(x) = iff “7“ ⊆ x ⊆ C ۸ not case 1 test(x) = otherwise

Page 43: soma@ist.tugraz€¦ · Software Maintenance Delta Debugging 4 . Printing this page makes Mozilla crash . Quelle: Zeller, A.; Society, I. C. & Hildebrandt, R.: Simplifying and Isolating

Software Maintenance Delta Debugging

43

Example ****

Input C = “12345678“ Function test: test(x) = ? iff (“17“⊄ x) test(x) = if “2“ ⊆ x ⊆ C test(x) = if “8“ ⊆ x ⊆ C test(x) = otherwise