Finding Latent Code Errors via Machine Learning over Program - - PowerPoint PPT Presentation

finding latent code errors via machine learning over
SMART_READER_LITE
LIVE PREVIEW

Finding Latent Code Errors via Machine Learning over Program - - PowerPoint PPT Presentation

Finding Latent Code Errors via Machine Learning over Program Executions Yuriy Brun Michael D. Ernst University of Southern Massachusetts Institute California of Technology Bubble Sort // Return a sorted copy of the argument double[]


slide-1
SLIDE 1

Finding Latent Code Errors via Machine Learning

  • ver Program Executions

Yuriy Brun

University of Southern California

Michael D. Ernst

Massachusetts Institute

  • f Technology
slide-2
SLIDE 2

2

Bubble Sort

// Return a sorted copy of the argument double[] bubble_sort(double[] in) { double[] out = array_copy(in); for (int x = out.length - 1; x >= 1; x--) for (int y = x - 1; y >= 1; y--) if (out[y] > out[y+1]) swap (out[y], out[y+1]); return out; }

slide-3
SLIDE 3

3

Bubble Sort

Faulty (?) Code: // Return a sorted copy of the argument double[] bubble_sort(double[] in) { double[] out = array_copy(in); for (int x = out.length - 1; x >= 1; x--) for (int y = x - 1; y >= 1; y--) if (out[y] > out[y+1]) swap (out[y], out[y+1]); return out; } Fault-revealing properties

  • ut[0] = in[0]
  • ut[1] ≤ in[1]
slide-4
SLIDE 4

4

Bubble Sort

Faulty Code: // Return a sorted copy of the argument double[] bubble_sort(double[] in) { double[] out = array_copy(in); for (int x = out.length - 1; x >= 1; x--) // lower bound should be 0, not 1 for (int y = x - 1; y >= 1; y--) if (out[y] > out[y+1]) swap (out[y], out[y+1]); return out; } Fault-revealing properties

  • ut[0] = in[0]
  • ut[1] ≤ in[1]
slide-5
SLIDE 5

5

Outline

  • Intuition for Fault Detection
  • Latent Error Finding Technique
  • Fault Invariant Classifier Implementation
  • Accuracy Experiment
  • Usability Experiment
  • Conclusion
slide-6
SLIDE 6

6

Outline

!Intuition for Fault Detection

  • Latent Error Finding Technique
  • Fault Invariant Classifier Implementation
  • Accuracy Experiment
  • Usability Experiment
  • Conclusion
slide-7
SLIDE 7

7

Targeted Errors

  • Latent Errors

– unknown errors

  • may be discovered later
  • no manifestation

– not discovered by test suite

slide-8
SLIDE 8

8

Targeted Programs

  • Programs that contain latent errors
  • Test inputs are easy to generate, but test
  • utputs can be hard to compute, e.g.:

– Complex computation programs – GUI programs – Programs without formal specification

slide-9
SLIDE 9

9

Learning from Fixes

Program B:

if (store[store.length] > 0);

Fixed Program A:

print (a[a.size - 1] + “elements”);

Program A:

print (a[a.size] + “elements”);

slide-10
SLIDE 10

10

Outline

  • Intuition for Fault Detection

!Latent Error Finding Technique

  • Fault Invariant Classifier Implementation
  • Accuracy Experiment
  • Usability Experiment
  • Conclusion
slide-11
SLIDE 11

11

Program Description Mapping

slide-12
SLIDE 12

12

Machine Learning Approach

  • Extracts knowledge from a training set
  • Creates a model that classifies new
  • bjects
  • Requires a numerical description of the

samples

slide-13
SLIDE 13

13

Training a Model

Examples:

  • ut[1] ≤ in[1]

〈1,0,0,2〉

slide-14
SLIDE 14

14

Training a Model

Examples:

  • ut[1] ≤ in[1]

〈1,0,0,2〉

slide-15
SLIDE 15

15

Classifying Properties

properties user program program analysis model machine classifier fault-revealing properties characteristic extractor features

slide-16
SLIDE 16

16

Related Work

  • Redundancy in

source code [Xie et al. 2002]

– find an error – 1.5-2 times improvement over random sampling

  • Relevance:
  • same goal
  • we have 50 times

improvement over random sampling (for C programs)

slide-17
SLIDE 17

17

Related Work

  • [Xie et al. 2002]
  • Partial invariant

violation [Hangal et al. 2002]

– is there an error?

  • Relevance:
  • similar program analysis
  • similar goal
slide-18
SLIDE 18

18

Related Work

  • [Xie et al. 2002]
  • [Hangal et al. 2002]
  • Clustering of function

call profiles [Dickinson et al. 2001, Podgurski et al. 2003]

– find relevant tests – select faulty executions

  • Relevance:
  • uses machine learning
slide-19
SLIDE 19

19

Latent Error-Finding Technique

  • Abstract properties
  • Abstract features
  • Generalizes to new

properties and programs

program with known errors program analysis properties program with errors removed program analysis properties machine learner model characteristic extractor features characteristic extractor features

slide-20
SLIDE 20

20

Model

  • A function:

– {set of features} " {fault-revealing, non-fault-revealing}

  • Examples:

– Linear combination functions – If-Then rules

slide-21
SLIDE 21

21

Outline

  • Intuition for Fault Detection
  • Latent Error Finding Technique

!Fault Invariant Classifier Implementation

  • Accuracy Experiment
  • Usability Experiment
  • Conclusion
slide-22
SLIDE 22

22

Tools Required for Fault Invariant Classifier

  • Program Property Extractor

– Daikon: Dynamic analysis tool

  • Property to Characteristic Vector

Converter

  • Machine Learning

– Support Vector Machines (SVMfu)

  • technique is equally applicable to static

and dynamic analysis

program with known errors program analysis properties program with errors removed program analysis properties machine learner model characteristic extractor features characteristic extractor features

slide-23
SLIDE 23

23

Daikon: Program Property Extractor

  • Daikon

– Dynamic analysis tool – Reports properties that are true over program executions – Examples:

  • myPositiveInt > 0
  • length = data.size
slide-24
SLIDE 24

24

Characteristic Vector Extractor

  • Daikon uses Java objects to represent

properties

  • Converter extracts all possible numeric

information from those objects

– # of variables e.g. x>5"1 x∈array"2 – is inequality? e.g. x>5"1 x∈array"0 – involves an array? e.g. x>5"0 x∈array"1

  • Total: 388 features
slide-25
SLIDE 25

25

Support Vector Machine Model

  • Predictive power
  • But not explicative power
  • Consists of thousands of support vectors

that define a separating area of the search space

slide-26
SLIDE 26

26

Outline

  • Intuition for Fault Detection
  • Latent Error Finding Technique
  • Fault Invariant Classifier Implementation

!Accuracy Experiment

  • Usability Experiment
  • Conclusion
slide-27
SLIDE 27

27

Subject Programs

  • 12 Programs

– C and Java programs – Largest: 9500 lines – 373 errors (132 seeded, 241 real)

  • with corrected versions

– Authors (at least 132):

  • Students
  • Industry
  • Researchers
slide-28
SLIDE 28

28

Accuracy Experiment

  • Goal:

– Test if machine learning can extrapolate knowledge from some programs to others

  • Train on errors from all but one program
  • Classify properties for each version of that
  • ne program
  • Compare to expected results
slide-29
SLIDE 29

29

Measurements and Definitions

  • Fault-revealing property:

– property of an erroneous program but not of that program with the error corrected – indicative of an error

  • Brevity:

– average number of properties one must examine to find a fault-revealing property – best possible brevity is 1

slide-30
SLIDE 30

30

Accuracy Experiment Results

  • C programs (single-error)

– brevity = 2.2 – improvement = 49.6 times

  • Java programs (mostly multiple-error)

– brevity = 1.7 – improvement = 4.8 times

slide-31
SLIDE 31

31

Outline

  • Intuition for Fault Detection
  • Latent Error Finding Technique
  • Fault Invariant Classifier Implementation
  • Accuracy Experiment

!Usability Experiment

  • Conclusion
slide-32
SLIDE 32

32

Fault Invariant Classifier Usability Study

  • Would properties identified by the fault

invariant classifier lead a programmer to errors in code?

  • Preliminary experimentation:

– 1 programmer’s evaluation – 2 programs (41 errors, 410 properties)

slide-33
SLIDE 33

33

Usability Study Results

  • Replace (32 errors)

– 68% of properties reported fault-revealing would lead a programmer to the error

  • Schedule (9 errors)

– 58% of properties reported fault-revealing would lead a programmer to the error

The majority of the reported properties were effective in indicating errors

slide-34
SLIDE 34

34

Outline

  • Intuition for Fault Detection
  • Latent Error Finding Technique
  • Fault Invariant Classifier Implementation
  • Accuracy Experiment
  • Usability Experiment

!Conclusion

slide-35
SLIDE 35

35

Conclusion

  • Designed a technique for finding latent errors
  • Implemented a fully automated Fault Invariant

Classifier

  • Fault Invariant Classifier revealed fault-revealing

properties with brevity around 2

  • Most of the fault-revealing properties are

expected to lead a programmer to the error

  • Overall, examining 3 properties is expected to

lead a programmer to the error in our tests

slide-36
SLIDE 36

36

Backup Slides

  • Works Cited
  • Explicative Machine Learning Model
slide-37
SLIDE 37

37

Works Cited

[Dickinson et al. 2001] W. Dickinson, D. Leon, and A. Podgurski. Finding failures by clust execution profiles. In ICSE, pages 339–348, May 2001. [Hangal at al. 2002] S. Hangal and M. S. Lam. Tracking down software bugs using autom

  • detection. In ICSE, pages 291–301, May 2002.

[Podgurski at al. 2003] A. Podgurski, D. Leon, P. Francis, W. Masri, M. Minch, J. Sun, an Automated support for classifying software failure reports. In ICSE, pages 465–475, May 2003. [Xie et al. 2002] Y. Xie and D. Engler. Using redundancies to find errors. In FSE, pages 5

  • Nov. 2002.
slide-38
SLIDE 38

38

Explicative Machine Learning Model

  • C5.0 decision tree machine learner
  • Examples:
  • Based on large number of samples and neither

an equality nor a linear relationship of three variables # likely fault-revealing

  • Sequences contains no duplicates or always

contains an element # likely fault-revealing

– No field accesses # even more likely fault-revealing