Learning to Generate Corrective Patches using Neural Machine Translation
arXiv:1812.07170
Abstract
Bug fixing is generally a manually-intensive task. However, recent work has proposed the idea of automated program repair, which aims to repair (at least a subset of) bugs in different ways such as code mutation, etc. Following in the same line of work as automated bug repair, in this paper we aim to leverage past fixes to propose fixes of current/future bugs. Specifically, we propose Ratchet, a corrective patch generation system using neural machine translation. By learning corresponding pre-correction and post-correction code in past fixes with a neural sequence-to-sequence model, Ratchet is able to generate a fix code for a given bug-prone code query. We perform an empirical study with five open source projects, namely Ambari, Camel, Hadoop, Jetty and Wicket, to evaluate the effectiveness of Ratchet. Our findings show that Ratchet can generate syntactically valid statements 98.7% of the time, and achieve an F1-measure between 0.29 - 0.83 with respect to the actual fixes adopted in the code base. In addition, we perform a qualitative validation using 20 participants to see whether the generated statements can be helpful in correcting bugs. Our survey showed that Ratchet's output was considered to be helpful in fixing the bugs on many occasions, even if fix was not 100% correct.
arXiv comment20 pages
References in corpus (17)
- Adam: A Method for Stochastic Optimization
- Sequence to Sequence Learning with Neural Networks
- TensorFlow: Large-Scale Machine Learning on Heterogeneous Distributed Systems
- Google's Neural Machine Translation System: Bridging the Gap between Human and Machine Translation
- Nopol: Automatic Repair of Conditional Statement Bugs in Java Programs
- SequenceR: Sequence-to-Sequence Learning for End-to-End Program Repair
- Learning Natural Coding Conventions
- DyNet: The Dynamic Neural Network Toolkit
- Elixir: Effective object-oriented program repair
- Mining Idioms from Source Code
- Automated Fixing of Programs with Contracts
- Structured Generative Models of Natural Source Code
- Neural Machine Translation and Sequence-to-sequence Models: A Tutorial
- Latent Predictor Networks for Code Generation
- Automated Correction for Syntax Errors in Programming Assignments using Recurrent Neural Networks
- How Different Are Different diff Algorithms in Git?
- Neural Machine Translation with Supervised Attention
Cited by in corpus (6)
- SequenceR: Sequence-to-Sequence Learning for End-to-End Program Repair
- Can We Generate Shellcodes via Natural Language? An Empirical Study
- Learning the Relation between Code Features and Code Transforms with Structured Prediction
- Program Repair with Minimal Edits Using CodeT5
- Toward Imitating Visual Attention of Experts in Software Development Tasks
- A Controlled Experiment of Different Code Representations for Learning-Based Bug Repair