---
title: "Getafix: Learning to Fix Bugs Automatically (2019)"
description: "Static analyzers catch common defects in code early, but developers mostly still have to fix them by… 33 references, cited by 7 papers here."
authors: ["Johannes Bader", "Andrew Scott", "Michael Pradel", "Satish Chandra"]
year: 2019
venue: "arXiv:1902.06111"
source: "https://arxiv.org/abs/1902.06111"
doi: "10.48550/arxiv.1902.06111"
arxiv: "1902.06111"
licence: "CC BY-NC-SA 4.0 (arXiv)"
licence_url: "http://creativecommons.org/licenses/by-nc-sa/4.0/"
summary_licence: "Elamur Cosmic License"
canonical: "https://research.elamur.ai/free/en/papers/bader-2019-getafix-learning-fix-bugs-automatically/"
---
[Elamur Research](https://md.research.elamur.ai/free/en/) · [this page in HTML](https://research.elamur.ai/free/en/papers/bader-2019-getafix-learning-fix-bugs-automatically/)

[home](https://md.research.elamur.ai/free/en/) / [papers](https://md.research.elamur.ai/free/en/papers/) / [2019](https://md.research.elamur.ai/free/en/papers/2019/page/4/) / Getafix: Learning to Fix Bugs Automatically

# Getafix: Learning to Fix Bugs Automatically

**Authors:** Johannes Bader, Andrew Scott, Michael Pradel and [Satish Chandra](https://md.research.elamur.ai/free/en/authors/satish-chandra/) · **Year:** 2019 · **Venue:** [arXiv:1902.06111](https://md.research.elamur.ai/free/en/venues/proceedings-of-the-acm-on-programming-languages/) ([Proceedings of the ACM on Programming Languages 2019](https://md.research.elamur.ai/free/en/venues/proceedings-of-the-acm-on-programming-languages/2019/)) · **Publisher:** [Association for Computing Machinery](https://md.research.elamur.ai/free/en/publishers/association-for-computing-machinery/) · **Licence:** [CC BY-NC-SA 4.0 (arXiv)](http://creativecommons.org/licenses/by-nc-sa/4.0/)

**Links:** [Publisher's page](https://arxiv.org/abs/1902.06111) · [PDF](https://arxiv.org/pdf/1902.06111) · [DOI 10.48550/arxiv.1902.06111](https://doi.org/10.48550/arxiv.1902.06111) · [arXiv 1902.06111](https://arxiv.org/abs/1902.06111) · [OpenAlex](https://openalex.org/W2914161001)

**Citations:** 227 citations (OpenAlex, 2026-10-14) · [7](https://md.research.elamur.ai/free/en/papers/bader-2019-getafix-learning-fix-bugs-automatically/cited-by/) in our library, of the 149,439 papers whose bibliographies we read

## Summary
Static analyzers catch common defects in code early, but developers mostly still have to fix them by hand. The authors, from Facebook, noticed that fixes for a given category of warnings tend to resemble one another. On this observation they built Getafix, a system that learns from the history of human-written fixes and proposes new ones that are as close as possible to what a human would have written. The approach has three steps. First, the example fixes are broken down into individual AST-level edits. Next, a new hierarchical agglomerative clustering algorithm based on anti-unification groups these edits into patterns, from general ones to highly specific ones. Finally, for a new defect, the candidates are ordered by a simple statistical ranking that takes the surrounding code into account. The system does not search through many variants and does not run tests: the top suggestion is checked once with the same static analyzer. On 1,268 fixes across six defect categories in Java, the first suggestion exactly matched the human fix in 12–91% of cases. Getafix runs in production at Facebook, which shows that automated fixing can be fast and useful in a large industrial codebase.

## Key points
- Evaluation data: 1,268 real fixes for six warning categories from two widely used Java analyzers, Error Prone and Infer. The categories include possible null dereferences, incorrect reference comparisons and API misuse.
- Accuracy: depending on the category, the first candidate matches the human fix verbatim in 12–91% of cases, and one of the top five does in 19–92%. Overall, this covers 526 of the 1,268 defects. The authors regard these numbers as a lower bound, since other acceptable fixes are not counted here.
- Speed: a suggestion usually appears in about 10 seconds, which is comparable to the time the analyzer takes to report its result. No separate fault localization step is needed, because the analyzer itself points to the defect location.
- At Facebook, Getafix proposes fixes for Infer warnings in Android/Java code, and developers accept about 42% of the suggestions. The system is also integrated into SapFix as one of its patch generation strategies.
- The method differs from its predecessor Revisar in that it learns only from fixes for a specific defect category, so patterns do not have to be selected by hand. In addition, it uses hierarchical rather than greedy clustering, which preserves the context needed to apply a fix.

*Our summary of the paper, in our own words — not its text. The work belongs to its authors; read it at the links above.*

## Institutions

- [Meta](https://md.research.elamur.ai/free/en/companies/meta/) — Company, Menlo Park, United States · 224 works · 241,960 citations
- [Meta (United Kingdom)](https://md.research.elamur.ai/free/en/companies/meta-united-kingdom/) — Company, London, United Kingdom · 60 works · 19,677 citations

📚 Shelves (4): [🖥️ Computer Science](https://md.research.elamur.ai/free/en/shelves/computer-science/) · 19,503 works · [🤖 Artificial Intelligence](https://md.research.elamur.ai/free/en/shelves/computer-science/artificial-intelligence/) · 18,805 works · [🗄️ Information Systems](https://md.research.elamur.ai/free/en/shelves/computer-science/information-systems/) · 1,888 works · [💻 Software](https://md.research.elamur.ai/free/en/shelves/computer-science/software/) · 150 works

## Cite

Cite as: Johannes Bader, Andrew Scott, Michael Pradel and Satish Chandra. 2019. Getafix: Learning to Fix Bugs Automatically. arXiv:1902.06111.

The paper itself, not this page. BibTeX from the library's record of the work.

```bibtex
@misc{bader2019getafix,
  title = {{Getafix: Learning to Fix Bugs Automatically}},
  author = {Johannes Bader, Andrew Scott, Michael Pradel and Satish Chandra},
  year = {2019},
  doi = {10.48550/arxiv.1902.06111},
  eprint = {1902.06111},
  archivePrefix = {arXiv},
  url = {https://doi.org/10.48550/arxiv.1902.06111}
}
```

- [← previous Dialog State Tracking: A Neural Reading Comprehension Approach](https://md.research.elamur.ai/free/en/papers/gao-2019-dialog-state-tracking-neural-reading/)
- [next → AlBERTo: Italian BERT Language Understanding Model for NLP Challenging Tasks Based on Tweets](https://md.research.elamur.ai/free/en/papers/polignano-2019-alberto-italian-bert-language-understanding/)
- [↑ back to papers of 2019](https://md.research.elamur.ai/free/en/papers/2019/page/4/)

## References

33 references, 1 of them with a card of ours. ↗ leads to the work, «find» searches for one we have no id for yet.

1. Edward Aftandilian, Raluca Sauciuc, Siddharth Priya, and Sundaresan Krishnan. 2012. Building Useful Program Analysis Tools Using an Extensible Java Compiler. In 12th IEEE International Working Conference on Source Code Analysis and Manipulation, SCAM 2012, Riva del Garda, Italy, September 23-24, 201… [find](https://scholar.google.com/scholar?q=Edward+Aftandilian%2C+Raluca+Sauciuc%2C+Siddharth+Priya%2C+and+Sundaresan+Krishnan%2E+2012%2E+Building+Useful+Program+Analysis+Tools+Using+an+Extensible+Java+Compiler%2E+In+12th+IEEE+International+Working+Confere)
2. Miltiadis Allamanis, Earl T Barr, Premkumar Devanbu, and Charles Sutton. 2018. [A survey of machine learning for big code and naturalness](https://md.research.elamur.ai/free/en/papers/allamanis-2017-survey-machine-learning-big-code/). ACM Computing Surveys (CSUR) 51, 4 (2018), 81.
3. Jean-Paul Benzécri. 1982. Construction d’une classification ascendante hiérarchique par la recherche en chaîne des voisins réciproques. Cahiers de l’analyse des données 7, 2 (1982), 209–218. [http://www.numdam.org/item/CAD_1982__7_2_209_0](http://www.numdam.org/item/CAD_1982__7_2_209_0) [↗](http://www.numdam.org/item/CAD_1982__7_2_209_0)
4. David Bingham Brown, Michael Vaughn, Ben Liblit, and Thomas W. Reps. 2017. The care and feeding of wild-caught mutants. In Proceedings of the 2017 11th Joint Meeting on Foundations of Software Engineering, ESEC/FSE 2017, Paderborn, Germany, September 4-8, 2017. 511–522. [find](https://scholar.google.com/scholar?q=David+Bingham+Brown%2C+Michael+Vaughn%2C+Ben+Liblit%2C+and+Thomas+W%2E+Reps%2E+2017%2E+The+care+and+feeding+of+wild%2Dcaught+mutants%2E+In+Proceedings+of+the+2017+11th+Joint+Meeting+on+Foundations+of+Software+Enginee)
5. Cristiano Calcagno, Dino Distefano, Jérémy Dubreil, Dominik Gabi, Pieter Hooimeijer, Martino Luca, Peter O’Hearn, Irene Papakonstantinou, Jim Purbrick, and Dulma Rodriguez. 2015. Moving fast with software verification. In NASA Formal Methods Symposium. Springer, 3–11. [find](https://scholar.google.com/scholar?q=Cristiano+Calcagno%2C+Dino+Distefano%2C+J%C3%A9r%C3%A9my+Dubreil%2C+Dominik+Gabi%2C+Pieter+Hooimeijer%2C+Martino+Luca%2C+Peter+O%E2%80%99Hearn%2C+Irene+Papakonstantinou%2C+Jim+Purbrick%2C+and+Dulma+Rodriguez%2E+2015%2E+Moving+fast+with+soft)
6. Maria Christakis and Christian Bird. 2016. What developers want and need from program analysis: an empirical study. In Proceedings of the 31st IEEE/ACM International Conference on Automated Software Engineering, ASE 2016, Singapore, September 3-7, 2016. 332–343. https://doi.org/10.1145/2970276.29703… — [doi:10.1145/2970276.2970347](https://doi.org/10.1145/2970276.2970347) [↗](https://doi.org/10.1145/2970276.29703…)
7. Benoit Cornu, Thomas Durieux, Lionel Seinturier, and Martin Monperrus. 2015. Npefix: Automatic runtime repair of null pointer exceptions in java. arXiv preprint arXiv:1512.07423 (2015). — [arXiv:1512.07423](https://arxiv.org/abs/1512.07423) [find](https://scholar.google.com/scholar?q=Benoit+Cornu%2C+Thomas+Durieux%2C+Lionel+Seinturier%2C+and+Martin+Monperrus%2E+2015%2E+Npefix%3A+Automatic+runtime+repair+of+null+pointer+exceptions+in+java%2E+arXiv+preprint+arXiv%3A1512%2E07423+%282015%29%2E+%E2%80%94+%5BarXiv%3A1512%2E)
8. Jacob Devlin, Jonathan Uesato, Rishabh Singh, and Pushmeet Kohli. 2017. Semantic Code Repair using Neuro-Symbolic Transformation Networks. CoRR abs/1710.11054 (2017). arXiv:1710.11054 http://arxiv.org/abs/1710.11054 5 https://code.fb.com/developer-tools/sapienz-intelligent-automated-software-testing… — [arXiv:1710.11054](https://arxiv.org/abs/1710.11054) [↗](http://arxiv.org/abs/1710.11054)
9. Jean-Rémy Falleri, Floréal Morandat, Xavier Blanc, Matias Martinez, and Martin Monperrus. 2014. Fine-grained and Accurate Source Code Differencing. In Proceedings of the International Conference on Automated Software Engineering. Västeras, Sweden, 313–324. https://doi.org/10.1145/2642937.2642982 upd… [↗](https://doi.org/10.1145/2642937.2642982)
10. Claire Le Goues, ThanhVu Nguyen, Stephanie Forrest, and Westley Weimer. 2012. GenProg: A Generic Method for Automatic Software Repair. IEEE Transactions on Software Engineering 38 (2012), 54–72. [find](https://scholar.google.com/scholar?q=Claire+Le+Goues%2C+ThanhVu+Nguyen%2C+Stephanie+Forrest%2C+and+Westley+Weimer%2E+2012%2E+GenProg%3A+A+Generic+Method+for+Automatic+Software+Repair%2E+IEEE+Transactions+on+Software+Engineering+38+%282012%29%2C+54%E2%80%9372%2E)
11. Claire Le Goues, Michael Pradel, and Abhik Roychoudhury. 2019. [find](https://scholar.google.com/scholar?q=Claire+Le+Goues%2C+Michael+Pradel%2C+and+Abhik+Roychoudhury%2E+2019%2E)
12. Automated Program Repair. Commun. ACM (2019). To appear. [find](https://scholar.google.com/scholar?q=Automated+Program+Repair%2E+Commun%2E+ACM+%282019%29%2E+To+appear%2E)
13. Rahul Gupta, Soham Pal, Aditya Kanade, and Shirish Shevade. 2017. DeepFix: Fixing Common C Language Errors by Deep Learning. In AAAI. [find](https://scholar.google.com/scholar?q=Rahul+Gupta%2C+Soham+Pal%2C+Aditya+Kanade%2C+and+Shirish+Shevade%2E+2017%2E+DeepFix%3A+Fixing+Common+C+Language+Errors+by+Deep+Learning%2E+In+AAAI%2E)
14. Jinru Hua, Mengshi Zhang, Kaiyuan Wang, and Sarfraz Khurshid. 2018. Towards Practical Program Repair with On-demand Candidate Generation. 2018 IEEE/ACM 40th International Conference on Software Engineering (ICSE) (2018), 12–23. [find](https://scholar.google.com/scholar?q=Jinru+Hua%2C+Mengshi+Zhang%2C+Kaiyuan+Wang%2C+and+Sarfraz+Khurshid%2E+2018%2E+Towards+Practical+Program+Repair+with+On%2Ddemand+Candidate+Generation%2E+2018+IEEE%2FACM+40th+International+Conference+on+Software+Engine)
15. Dongsun Kim, Jaechang Nam, Jaewoo Song, and Sunghun Kim. 2013. Automatic patch generation learned from human-written patches. In Proceedings of the 2013 International Conference on Software Engineering. IEEE Press, 802–811. [find](https://scholar.google.com/scholar?q=Dongsun+Kim%2C+Jaechang+Nam%2C+Jaewoo+Song%2C+and+Sunghun+Kim%2E+2013%2E+Automatic+patch+generation+learned+from+human%2Dwritten+patches%2E+In+Proceedings+of+the+2013+International+Conference+on+Software+Engineerin)
16. Temur Kutsia, Jordi Levy, and Mateu Villaret. 2014. Anti-unification for Unranked Terms and Hedges. Journal of Automated Reasoning 52, 2 (01 Feb 2014), 155–190. https://doi.org/10.1007/s10817-013-9285-6 — [doi:10.1007/s10817-013-9285-6](https://doi.org/10.1007/s10817-013-9285-6) [↗](https://doi.org/10.1007/s10817-013-9285-6)
17. Xuan-Bach D. Le, David Lo, and Claire Le Goues. 2016. [find](https://scholar.google.com/scholar?q=Xuan%2DBach+D%2E+Le%2C+David+Lo%2C+and+Claire+Le+Goues%2E+2016%2E)
18. History Driven Program Repair. 2016 IEEE 23rd International Conference on Software Analysis, Evolution, and Reengineering (SANER) 1 (2016), 213–224. [find](https://scholar.google.com/scholar?q=History+Driven+Program+Repair%2E+2016+IEEE+23rd+International+Conference+on+Software+Analysis%2C+Evolution%2C+and+Reengineering+%28SANER%29+1+%282016%29%2C+213%E2%80%93224%2E)
19. Fan Long, Peter Amidon, and Martin Rinard. 2017. Automatic inference of code transforms for patch generation. In Proceedings of the 2017 11th Joint Meeting on Foundations of Software Engineering. ACM, 727–739. [find](https://scholar.google.com/scholar?q=Fan+Long%2C+Peter+Amidon%2C+and+Martin+Rinard%2E+2017%2E+Automatic+inference+of+code+transforms+for+patch+generation%2E+In+Proceedings+of+the+2017+11th+Joint+Meeting+on+Foundations+of+Software+Engineering%2E+ACM%2C)
20. Fan Long and Martin Rinard. 2016. Automatic Patch Generation by Learning Correct Code. In Proceedings of the 43rd Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL ’16). ACM, New York, NY, USA, 298–312. https://doi.org/10.1145/2837614.2837617 [↗](https://doi.org/10.1145/2837614.2837617)
21. Alexandru Marginean, Johannes Bader, Satish Chandra, Mark Harman, Yue Jia, Ke Mao, Alexander Mols, and Andrew Scott. 2019. SapFix: Automated End-to-End Repair at Scale (ICSE-SEIP ’19). [find](https://scholar.google.com/scholar?q=Alexandru+Marginean%2C+Johannes+Bader%2C+Satish+Chandra%2C+Mark+Harman%2C+Yue+Jia%2C+Ke+Mao%2C+Alexander+Mols%2C+and+Andrew+Scott%2E+2019%2E+SapFix%3A+Automated+End%2Dto%2DEnd+Repair+at+Scale+%28ICSE%2DSEIP+%E2%80%9919%29%2E)
22. Matias Martinez and Martin Monperrus. 2012. Mining repair actions for guiding automated program fixing. Ph.D. Dissertation. Inria. [find](https://scholar.google.com/scholar?q=Matias+Martinez+and+Martin+Monperrus%2E+2012%2E+Mining+repair+actions+for+guiding+automated+program+fixing%2E+Ph%2ED%2E+Dissertation%2E+Inria%2E)
23. Matias Martinez and Martin Monperrus. 2015. Mining Software Repair Models for Reasoning on the Search Space of Automated Program Fixing. Empirical Softw. Engg. 20, 1 (Feb. 2015), 176–205. https://doi.org/10.1007/s10664-013-9282-8 — [doi:10.1007/s10664-013-9282-8](https://doi.org/10.1007/s10664-013-9282-8) [↗](https://doi.org/10.1007/s10664-013-9282-8)
24. Matias Martinez and Martin Monperrus. 2018. Coming: a Tool for Mining Change Pattern Instances from Git Commits. arXiv:arXiv:1810.08532 — [arXiv:1810.08532](https://arxiv.org/abs/1810.08532) [find](https://scholar.google.com/scholar?q=Matias+Martinez+and+Martin+Monperrus%2E+2018%2E+Coming%3A+a+Tool+for+Mining+Change+Pattern+Instances+from+Git+Commits%2E+arXiv%3AarXiv%3A1810%2E08532+%E2%80%94+%5BarXiv%3A1810%2E08532%5D%28https%3A%2F%2Farxiv%2Eorg%2Fabs%2F1810%2E08532%29)
25. Oleksandr Polozov and Sumit Gulwani. 2015. FlashMeta: A Framework for Inductive Program Synthesis. In Proceedings of the 2015 ACM SIG-PLAN International Conference on Object-Oriented Programming, Systems, Languages, and Applications (OOPSLA 2015). ACM, New York, NY, USA, 107–126. https://doi.org/10.… — [doi:10.1145/2814270.2814310](https://doi.org/10.1145/2814270.2814310) [find](https://scholar.google.com/scholar?q=Oleksandr+Polozov+and+Sumit+Gulwani%2E+2015%2E+FlashMeta%3A+A+Framework+for+Inductive+Program+Synthesis%2E+In+Proceedings+of+the+2015+ACM+SIG%2DPLAN+International+Conference+on+Object%2DOriented+Programming%2C+Syst)
26. Michael Pradel and Koushik Sen. 2018. DeepBugs: A Learning Approach to Name-based Bug Detection. CoRR abs/1805.11683 (2018). arXiv:1805.11683 http://arxiv.org/abs/1805.11683 — [arXiv:1805.11683](https://arxiv.org/abs/1805.11683) [↗](http://arxiv.org/abs/1805.11683)
27. Reudismam Rolim, Gustavo Soares, Loris D’Antoni, Oleksandr Polozov, Sumit Gulwani, Rohit Gheyi, Ryo Suzuki, and Björn Hartmann. 2017. Learning Syntactic Program Transformations from Examples. In Proceedings of the 39th International Conference on Software Engineering (ICSE ’17). IEEE Press, Piscataw… [find](https://scholar.google.com/scholar?q=Reudismam+Rolim%2C+Gustavo+Soares%2C+Loris+D%E2%80%99Antoni%2C+Oleksandr+Polozov%2C+Sumit+Gulwani%2C+Rohit+Gheyi%2C+Ryo+Suzuki%2C+and+Bj%C3%B6rn+Hartmann%2E+2017%2E+Learning+Syntactic+Program+Transformations+from+Examples%2E+In+Proce)
28. Reudismam Rolim, Gustavo Soares, Rohit Gheyi, and Loris D’Antoni. 2018. Learning Quick Fixes from Code Repositories. CoRR abs/1803.03806 (2018). arXiv:1803.03806 http://arxiv.org/abs/1803.03806 — [arXiv:1803.03806](https://arxiv.org/abs/1803.03806) [↗](http://arxiv.org/abs/1803.03806)
29. M. Soto and C. Le Goues. 2018. Using a probabilistic model to predict bug fixes. In 2018 IEEE 25th International Conference on Software Analysis, Evolution and Reengineering (SANER), Vol. 00. 221–231. https://doi.org/10.1109/SANER.2018.8330211 — [doi:10.1109/saner.2018.8330211](https://doi.org/10.1109/saner.2018.8330211) [↗](https://doi.org/10.1109/SANER.2018.8330211)
30. Mauricio Soto, Ferdian Thung, Chu-Pan Wong, Claire Le Goues, and David Lo. 2016. A Deeper Look into Bug Fixes: Patterns, Replacements, Deletions, and Additions. In Proceedings of the 13th International Conference on Mining Software Repositories (MSR ’16). ACM, New York, NY, USA, 512–515. https://doi… — [doi:10.1145/2901739.2903495](https://doi.org/10.1145/2901739.2903495) [find](https://scholar.google.com/scholar?q=Mauricio+Soto%2C+Ferdian+Thung%2C+Chu%2DPan+Wong%2C+Claire+Le+Goues%2C+and+David+Lo%2E+2016%2E+A+Deeper+Look+into+Bug+Fixes%3A+Patterns%2C+Replacements%2C+Deletions%2C+and+Additions%2E+In+Proceedings+of+the+13th+Internationa)
31. Ke Wang, Rishabh Singh, and Zhendong Su. 2018. Search, align, and repair: data-driven feedback generation for introductory programming exercises. In Proceedings of the 39th ACM SIGPLAN Conference on Programming Language Design and Implementation, PLDI 2018, Philadelphia, PA, USA, June 18-22, 2018. 4… [find](https://scholar.google.com/scholar?q=Ke+Wang%2C+Rishabh+Singh%2C+and+Zhendong+Su%2E+2018%2E+Search%2C+align%2C+and+repair%3A+data%2Ddriven+feedback+generation+for+introductory+programming+exercises%2E+In+Proceedings+of+the+39th+ACM+SIGPLAN+Conference+on+P)
32. Ming Wen, Junjie Chen, Rongxin Wu, Dan Hao, and Shing-Chi Cheung. 2018. Context-Aware Patch Generation for Better Automated Program Repair. 2018 IEEE/ACM 40th International Conference on Software Engineering (ICSE) (2018), 1–11. [find](https://scholar.google.com/scholar?q=Ming+Wen%2C+Junjie+Chen%2C+Rongxin+Wu%2C+Dan+Hao%2C+and+Shing%2DChi+Cheung%2E+2018%2E+Context%2DAware+Patch+Generation+for+Better+Automated+Program+Repair%2E+2018+IEEE%2FACM+40th+International+Conference+on+Software+Engi)
33. Pengcheng Yin, Graham Neubig, Marc Brockschmidt Miltiadis Allamanis and, and Alexander L. Gaunt. 2018. Learning to Represent Edits. CoRR 1810.13337 (2018). [find](https://scholar.google.com/scholar?q=Pengcheng+Yin%2C+Graham+Neubig%2C+Marc+Brockschmidt+Miltiadis+Allamanis+and%2C+and+Alexander+L%2E+Gaunt%2E+2018%2E+Learning+to+Represent+Edits%2E+CoRR+1810%2E13337+%282018%29%2E)

*Updated 3 November 2026*
