Automatically Finding Patches Using Genetic Programming

Similar documents
A Systematic Study of Automated Program Repair: Fixing 55 out of 105 Bugs for $8 Each

Using Execution Paths to Evolve Software Patches

Fixing software bugs in 10 minutes or less using evolutionary computation

Automatically Finding Patches Using Genetic Programming. Westley Weimer, Claire Le Goues, ThanVu Nguyen, Stephanie Forrest

Program Synthesis. SWE 795, Spring 2017 Software Engineering Environments

Repair & Refactoring

Automatically Finding Patches Using Genetic Programming

Automatically Finding Patches Using Genetic Programming

AUTOMATIC PROGRAM REPAIR USING GENETIC PROGRAMMING

Trusted Software Repair for System Resiliency. Westley Weimer, Stephanie Forrest, Miryung Kim, Claire Le Goues, Patrick Hurley

LEVERAGING LIGHTWEIGHT ANALYSES TO AID SOFTWARE MAINTENANCE ZACHARY P. FRY PHD PROPOSAL

REPAIRING PROGRAMS WITH SEMANTIC CODE SEARCH. Yalin Ke Kathryn T. Stolee Claire Le Goues Yuriy Brun

ASTOR: A Program Repair Library for Java

DynaMoth: Dynamic Code Synthesis for Automatic Program Repair

Genetic Programming for Julia: fast performance and parallel island model implementation

Substitution Based Rules for Efficient Code Duplication on Object Oriented Systems

Representations and Operators for Improving Evolutionary Software Repair

Leveraging Program Equivalence for Adaptive Program Repair: Models and First Results. Westley Weimer, UVA Zachary P. Fry, UVA Stephanie Forrest, UNM

SemFix: Program Repair via Semantic Analysis. Ye Wang, PhD student Department of Computer Science Virginia Tech

Automated Program Repair

Automated Program Repair through the Evolution of Assembly Code

UEE1302(1066) F12: Introduction to Computers and Programming Function (II) - Parameter

An Unsystematic Review of Genetic Improvement. David R. White University of Glasgow UCL Crest Open Workshop, Jan 2016

Automatically Repairing Concurrency Bugs with ARC MUSEPAT 2013 Saint Petersburg, Russia

Introduction to Scientific Modeling CS 365, Fall Semester, 2011 Genetic Algorithms

9/5/17. The Design and Implementation of Programming Languages. Compilation. Interpretation. Compilation vs. Interpretation. Hybrid Implementation

Automa'c, Efficient, and General Repair of So8ware Defects using Lightweight Program Analyses

TACi: Three-Address Code Interpreter (version 1.0)

CSCE 110: Programming I

Automatic Repair of Real Bugs in Java: A Large-Scale Experiment on the Defects4J Dataset

Algorithm Design: GCD

What is recursion? Recursion. How can a function call itself? Recursive message() modified. contains a reference to itself. Week 7. Gaddis:

Names and Functions. Chapter 2

AC64/AT64 DESIGN & ANALYSIS OF ALGORITHMS DEC 2014

1.7 Recursion. Department of CSE

Standard Version of Starting Out with C++, 4th Edition. Chapter 19 Recursion. Copyright 2003 Scott/Jones Publishing

Describing and Implementing Algorithms

15-122: Principles of Imperative Computation (Section G)

A Systematic Study of Automated Program Repair: Fixing 55 out of 105 bugs for $8 Each

Chapter 4 Functions By C.K. Liang

Loops / Repetition Statements

What is recursion? Recursion. How can a function call itself? Recursive message() modified. Week 10. contains a reference to itself.

3. Logical Values. Boolean Functions; the Type bool; logical and relational operators; shortcut evaluation

Lecture 7: General Loops (Chapter 7)

arxiv: v1 [cs.se] 25 Mar 2014

Combining Bug Detection and Test Case Generation

Automated Program Repair by Using Similar Code Containing Fix Ingredients

Planning and Search. Genetic algorithms. Genetic algorithms 1

Mosig M1 - PLSCD Written exam

Aryan College. Fundamental of C Programming. Unit I: Q1. What will be the value of the following expression? (2017) A + 9

CSI32 Object-Oriented Programming

Upcoming. Repairing Automated Repair. Generalizing 3/19/18

Chapter 4 C Program Control

Technical Section. Lab 4 while loops and for loops. A. while Loops or for loops

Classification Using Genetic Programming. Patrick Kellogg General Assembly Data Science Course (8/23/15-11/12/15)

IntroClassJava: A Benchmark of 297 Small and Buggy Java Programs

An automated approach to program repair with semantic code search

OPERATING SYSTEMS, ASSIGNMENT 4 FILE SYSTEM

Automatically Repairing Broken Workflows for Evolving GUI Applications

Reading assignment: Reviews and Inspections

Page 1. Reading assignment: Reviews and Inspections. Foundations for SE Analysis. Ideally want general models. Formal models

Control Statements. if for while

Searching for Program Invariants using Genetic Programming and Mutation Testing

AMCAT Automata Coding Sample Questions And Answers

Scientific Computing

Exam 2, Version 2. For the following code, mark True or False for statements 1.8 to 1.10.

CS 101: Computer Programming and Utilization

CIS 110 Introduction To Computer Programming. February 29, 2012 Midterm

Conditionals !

Odds and Ends. Think about doing research Programming grading. Assignment 3 due Tuesday

3. Logical Values. Our Goal. Boolean Values in Mathematics. The Type bool in C++

EECS1012. Net-centric Introduction to Computing. Lecture 7 Computational Thinking. Fall 2018, EECS York University. M.S. Brown and Amir H.

A Fitness Function to Find Feasible Sequences of Method Calls for Evolutionary Testing of Object-Oriented Programs

Lecture Overview Code generation in milestone 2 o Code generation for array indexing o Some rational implementation Over Express Over o Creating

3. Logical Values. Our Goal. Boolean Values in Mathematics. The Type bool in C++

Using Genetic Algorithms to Solve the Box Stacking Problem

CS 310 Advanced Data Structures and Algorithms

Programming (1.0hour)

Evolutionary Search in Machine Learning. Lutz Hamel Dept. of Computer Science & Statistics University of Rhode Island

(Not Quite) Minijava

Paul POCATILU, PhD Economics Informatics and Cybernetics Department The Bucharest Academy of Economic Studies

Euclid's Algorithm. MA/CSSE 473 Day 06. Student Questions Odd Pie Fight Euclid's algorithm (if there is time) extended Euclid's algorithm

APCS Semester #1 Final Exam Practice Problems

Operating Systems. Lecture 05

TESTING AND DEBUGGING

COMPUTER PROGRAMMING LAB

A function is a named piece of code that performs a specific task. Sometimes functions are called methods, procedures, or subroutines (like in LC-3).

GENETIC PROGRAMMING FOR SOFTWARE TRANSPLANTS IMAN HEMATI MOGHADAM

A Practical Approach to Programming With Assertions

Agile Software Development. Lecture 7: Software Testing

UCT Algorithm Circle: Number Theory

Fall 2015 COMP Operating Systems. Lab #3

Lecture Notes on Contracts

What is recursion? Recursion. Recursive message() modified. How can a function call itself? contains a reference to itself. Week 10. Gaddis:

Founda'ons of So,ware Engineering. Sta$c analysis (1/2) Claire Le Goues

Intro to Computational Programming in C Engineering For Kids!

Search-Based Generalization and Refinement of Code Templates

Comp 182 Data Structures Sample Midterm Examination

CIS 110 Introduction to Computer Programming. February 29, 2012 Midterm

Programming in Visual Basic with Microsoft Visual Studio 2010

Transcription:

Automatically Finding Patches Using Genetic Programming Authors: Westley Weimer, ThanhVu Nguyen, Claire Le Goues, Stephanie Forrest Presented by: David DeBonis, Qi Lu, Shuang Yang Department of Computer Science University of New Mexico February, 0

Outline Mutation Crossover 5

Error Correction in Source Code Based on positive / negative test cases Program isolation Repair by insert / delete / swap Repeat until a variant passes all tests Minimize difference

5 6 7 8 9 0 Example of Errant Code Listing : Euclid s greatest common divisor algorithm /* requires : a >= 0, b >= 0 */ void gcd ( int a, int b ) { if ( a == 0) { printf ( " % d ", b ); } while ( b!= 0) a = a - b; else b = b - a; printf ( " % d ", a ); exit (0); }

Variants Creation and Representation Restricted to code substitutions from other parts Mutation / Crossover constrained to area relevant to error Abstract Syntax Tree (AST) Weighted program path P Fitness = N i= wi passed test cases

An abstract syntax tree(ast). It includes all of the statements in the program. A weighted path through the program, (statement, weight). The weighted path is a list of pairs, each pair contains a statement and a weight based on that statement s occurrences in various testcases.

The algorithm of mutation

The example for Mutation 5 6 while ( b!= 0) a = a - b; else b = b + a; return a ;

The example for Mutation statement sequence return 0.0 while 0.0 0.0 op:!= : a branch 5 6 while ( b!= 0) a = a - b; else b = b + a; return a ; : b constant: 0 : a op: > : b : a : a 0 bin op: : b : b Figure: The AST of the program : b bin op: + : a

Mutation: Swap statement sequence return 0.0 while 0.0 0.0 op:!= : a branch : b constant: 0 : a op: > : b : b : b 0 bin op: + : a : a : a bin op: : b

Mutation: Swap 5 6 while ( b!= 0) a = a - b; else b = b + a; return a ; 5 6 while ( b!= 0) b = b + a; else a = a - b; return a ;

Mutation: Insertion statement sequence 0.0 condition while 0.0 body op:!= : a branch : b constant: 0 : a 0.0 return condition if body op: > : b : a : a bin op: else body : a 0 bin op: : b : a : b : b : b bin op: + : a

Mutation: Insertion 5 6 while ( b!= 0) a = a - b; else b = b + a; return a ; 5 6 7 while ( b!= 0) a = a - b; else b = b + a; a = a - b; return a ;

Mutation: Deletion statement sequence 0.0 condition while 0.0 0.0 return body op:!= : a branch : b constant: 0 : a condition if body op: > : b : a : a else body 0 bin op: : b : b : b Deletion bin op: + : a

Mutation: Deletion 5 6 while ( b!= 0) a = a - b; else b = b + a; return a ; while ( b!= 0) a = a - b; return a ;

Crossover Choose a cutoff point for each program Combine the first part of one program with the second part of another and vice versa Input: [P, P, P, P ] and [Q, Q, Q, Q ] with cutoff Child: [P, P, Q, Q ] and [Q, Q, P, P ]

Crossover a = a - b; else b = b - a; cutoff point at a = a + b; else b = b + a;

Crossover branch branch if-body condition else-body op: > bin op op: if-body condition op: > bin op op: else-body bin op op: + bin op op: +

Crossover branch branch if-body condition else-body op: > bin op op: if-body condition op: > bin op op: + else-body bin op op: + bin op op:

Crossover a = a - b; else b = b + a; a = a + b; else b = b - a;

Crossover

Crossover branch branch if-body condition else-body op: > bin op op: + if-body condition op: > bin op op: else-body bin op op: bin op op: +

Demonstrated GP approach Based on AST representation Mutate / Crossover algorithm Minimal code changes Experiments over 0 test cases Sizeable code bases Orthogonal errors present Reasonable solution found ( 50%) Efficacy to code maintenance Experiments using Amazon Cloud Equated to under $8 per bug on average Who wants to manually debug anyway!

Limitations and Assumptions Only as good as your test cases Not necessarily memory / computing time optimized Expects redundant code segments How well does it scale? by number of bugs... by number of revisions... by number of LOC... Will this technique work on another GP?