Papers
Topics
Authors
Recent
Gemini 2.5 Flash
Gemini 2.5 Flash
97 tokens/sec
GPT-4o
53 tokens/sec
Gemini 2.5 Pro Pro
44 tokens/sec
o3 Pro
5 tokens/sec
GPT-4.1 Pro
47 tokens/sec
DeepSeek R1 via Azure Pro
28 tokens/sec
2000 character limit reached

Getafix: Learning to Fix Bugs Automatically (1902.06111v5)

Published 16 Feb 2019 in cs.SE

Abstract: 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 a computationally 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.

User Edit Pencil Streamline Icon: https://streamlinehq.com
Authors (4)
  1. Johannes Bader (3 papers)
  2. Andrew Scott (8 papers)
  3. Michael Pradel (49 papers)
  4. Satish Chandra (32 papers)
Citations (231)

Summary

  • The paper introduces hierarchical clustering to learn code edit patterns for automated, human-like bug fixes.
  • It extracts fine-grained AST edits and ranks them statistically based on prevalence, location, and specialization.
  • Experimental results show top-1 accuracy up to 91% and a 42% acceptance rate in industrial settings at Facebook.

Essay on "Getafix: Learning to Fix Bugs Automatically"

The paper "Getafix: Learning to Fix Bugs Automatically" presents an innovative approach to automated bug fixing by learning from previous fixes. This approach departs from traditional methods by leveraging hierarchical clustering to learn edit patterns from historical code changes, particularly those associated with static analysis warnings. At its core, Getafix aims to produce human-like code fixes that integrate seamlessly into existing development workflows, focusing on specific bug categories identified by static analysis tools.

Overview of Getafix's Approach

Getafix is designed around three main components: extracting tree-based edits, clustering these edits into generalized patterns, and applying the resulting patterns to generate fix suggestions. Initially, the system analyzes changes at the Abstract Syntax Tree (AST) level, decomposing alterations into fine-grained edits that serve as the foundation for learning patterns. This granular view allows Getafix to capture the subtle nuances that characterize human-written fixes.

The novel contribution of this work lies in the hierarchical clustering of these edits. Unlike simpler, greedy methods, Getafix constructs a dendrogram of edit patterns that vary from specific to general. This hierarchy captures both the diversity of possible fixes within a bug category and the contextual information surrounding the changes. The pattern hierarchy enables Getafix to tailor fix suggestions to the given code context, improving the human-likeness of the proposed solutions.

Furthermore, Getafix employs a statistically driven ranking mechanism to select the best patterns for application. This ranking is informed by prevalence, location, and specialization scores derived from the training data, ensuring that the most likely human-like fixes are prioritized. This step is crucial for maintaining efficiency by minimizing the need for resource-intensive validation steps.

Experimental Evaluation

The paper provides a thorough evaluation of Getafix across various bug categories, such as null dereferences and incorrect API calls, using data from open-source repositories and an industrial deployment at Facebook. The results indicate that Getafix achieves a top-1 fix accuracy ranging from 12\% to 91\% across different bug types, with top-5 accuracies even higher, demonstrating its effectiveness in predicting human-like fixes.

A key aspect of the evaluation is the deployment of Getafix within Facebook's software development pipeline, where it contributes to the fixing of NullPointerException warnings generated by the Infer static analysis tool. This real-world application highlights the practical utility of Getafix, where it achieved a 42\% acceptance rate for its fix suggestions, showcasing its potential to save developer time in large-scale code bases.

Implications and Future Directions

The introduction of Getafix offers both theoretical and practical implications for the field of automated program repair. The hierarchical clustering approach provides a systematic way to capture recurring patterns across different instances of a bug, enabling the generation of more accurate and contextually valid fixes. Practically, the deployment of such a system in industrial settings demonstrates its potential to reduce the manual effort required for bug fixing, thereby enhancing developer productivity and software reliability.

Looking forward, there are several avenues for extending Getafix's capabilities. Improvements could include expanding the range of supported languages and bug categories, integrating with more development tools, and enhancing the learning model to capture more diverse patterns. Additionally, the exploration of machine learning techniques, such as embeddings and neural networks, could further refine the pattern generalization and ranking processes.

Conclusion

Getafix represents a significant advancement in automated bug fixing by learning from past code changes associated with specific bug categories. Its use of hierarchical clustering to learn edit patterns and its efficient ranking mechanism set it apart from traditional program repair methods. The successful deployment within Facebook underscores its practical value, making it a promising tool for enhancing software quality in both industrial and open-source contexts.