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
- Charles Sutton
- Uri Alon
- Eran Yahav
- Percy Liang
- Michihiro Yasunaga
- Miltiadis Allamanis
- Armando Solar-Lezama
- Gabriele Bavota
In Software
- Percy Liang
- Michihiro Yasunaga
- Charles Sutton
- Uri Alon
- Armando Solar-Lezama
- Eran Yahav
- Gabriele Bavota
- Denys Poshyvanyk
In Code Generation & Program Synthesis
- Charles Sutton
- Gabriele Bavota
- Denys Poshyvanyk
- Uri Alon
- Eran Yahav
- Armando Solar-Lezama
- Percy Liang
- Michihiro Yasunaga
In Program Analysis & Verification
- Eran Yahav
- Uri Alon
- Armando Solar-Lezama
- Lu Zhang
- Percy Liang
- Ke Wang
- Denys Poshyvanyk
- Daniel Tarlow
In Signal Processing
- Uri Alon
- Eran Yahav
- Michihiro Yasunaga
- Charles Sutton
- Armando Solar-Lezama
- Gabriele Bavota
- Denys Poshyvanyk
- Noam Yefet
Citations in the corpus
- Break-It-Fix-It: Unsupervised Learning for Program Repair (2021, background): “Several works learn to repair code from labeled datasets of source code edits made by programmers, e.g., error resolution records (Just et al., 2014; Chen et al., 2019; Mesbah et al., 2019; Bader et al., 2019; Tarlow et al., 2020; Ding et al., 2020).”
- Graph-based, Self-Supervised Program Repair from Diagnostic Feedback (2020, background): “Bader et al. (2019) present a hierarchical clustering algorithm to learn program repair patterns.”
- Learning to Fix Build Errors with Graph2Diff Neural Networks (2019, background): “Similarly, Getafix also only focuses on a few kinds of errors [30].”
- Hoppity: Learning Graph Transformations to Detect and Fix Bugs in Programs (2020, background): “, 2018) uses sequence-to-sequence model to translate a buggy code segment into correct one; Getafix (Scott et al., 2019) produces human-like bug fixes by learning from past fixes.”
- RepairAgent: An Autonomous, LLM-Based Agent for Program Repair (2024, unknown): “…the challenge of automatically fixing bugs [1], including techniques based on manually designed [2], [3] and (semi-)automatically extracted [4], [5], [6] fix patterns, based on symbolic constraints [7], [8], [9], and various machine learning-based approaches [10], [11], [12], [13], [14], [15],…”
- Studying the Usage of Text-To-Text Transfer Transformer to Support Code-Related Tasks (2021, background): “Several of them [27]–[35] rely on the redundancy assumption, claiming that large programs contain the seeds of their own repair.”
- A syntax-guided edit decoder for neural program repair (2021, methodology): “APR has been approached using different techniques, such as heuristics or random search [33, 35, 45, 54], semantic analysis [7, 12, 22, 27, 39, 46ś48], manually defined or automatically mined repair patterns [2, 14, 23, 24, 31, 42, 52, 59], and learning from source code [24, 43, 69ś72].”
- Adversarial examples for models of code (2019, background): “More generally, bypassing a bug detection model [Pradel and Sen 2018; Rice et al. 2017; Scott et al. 2019] can allow a malicious developer inside an organization or inside an open-source project to intentionally introduce bugs.”
- Demystifying GPT Self-Repair for Code Generation (2023, background): “In the first example friends can go to $[2, 2, 3, 3]$.”
- AutoCodeRover: Autonomous Program Improvement (2024, unknown): “The above APR techniques rely on a high-quality test suite which is not always available in the real world and they do not leverage the valuable natural language specification from the original problem description.”