Getafix: learning to fix bugs automatically

By Andrew C. Scott, Johannes Bader, Satish Chandra. 2019

271 citations recorded by the source corpus.

Static analyzers help find bugs early by warning about recurring bug categories. While fixing these bugs still remains a mostly manual task in practice, we observe that fixes for a specific bug category often are repetitive. This paper addresses the problem of automatically fixing instances of common bugs by learning from past fixes. We present Getafix, an approach that produces human-like fixes while being fast enough to suggest fixes in time proportional to the amount of time needed to obtain static analysis results in the first place. Getafix is based on a novel hierarchical clustering algorithm that summarizes fix patterns into a hierarchy ranging from general to specific patterns. Instead of an expensive exploration of a potentially large space of candidate fixes, Getafix uses a simple yet effective ranking technique that uses the context of a code change to select the most appropriate fix for a given bug. Our evaluation applies Getafix to 1,268 bug fixes for six bug categories reported by popular static analyzers for Java, including null dereferences, incorrect API calls, and misuses of particular language constructs. The approach predicts exactly the human-written fix as the top-most suggestion between 12% and 91% of the time, depending on the bug category. The top-5 suggestions contain fixes for 526 of the 1,268 bugs. Moreover, we report on deploying the approach within Facebook, where it contributes to the reliability of software used by billions of people. To the best of our knowledge, Getafix is the first industrially-deployed automated bug-fixing tool that learns fix patterns from past, human-written fixes to produce human-like fixes.

Subfields: Information Systems, Software, Code Generation & Program Synthesis, Program Analysis & Verification, Signal Processing

How researchers see this paper

The researchers whose trusted networks rank it highest, strongest advocate first. Every researcher gets a different order.

In Information Systems

  1. Charles Sutton
  2. Uri Alon
  3. Eran Yahav
  4. Percy Liang
  5. Michihiro Yasunaga
  6. Miltiadis Allamanis
  7. Armando Solar-Lezama
  8. Gabriele Bavota

In Software

  1. Percy Liang
  2. Michihiro Yasunaga
  3. Charles Sutton
  4. Uri Alon
  5. Armando Solar-Lezama
  6. Eran Yahav
  7. Gabriele Bavota
  8. Denys Poshyvanyk

In Code Generation & Program Synthesis

  1. Charles Sutton
  2. Gabriele Bavota
  3. Denys Poshyvanyk
  4. Uri Alon
  5. Eran Yahav
  6. Armando Solar-Lezama
  7. Percy Liang
  8. Michihiro Yasunaga

In Program Analysis & Verification

  1. Eran Yahav
  2. Uri Alon
  3. Armando Solar-Lezama
  4. Lu Zhang
  5. Percy Liang
  6. Ke Wang
  7. Denys Poshyvanyk
  8. Daniel Tarlow

In Signal Processing

  1. Uri Alon
  2. Eran Yahav
  3. Michihiro Yasunaga
  4. Charles Sutton
  5. Armando Solar-Lezama
  6. Gabriele Bavota
  7. Denys Poshyvanyk
  8. Noam Yefet

Citations in the corpus