Skip to main content
QUICK REVIEW

[Paper Review] TransRepair: Context-aware Program Repair for Compilation Errors

Xueyang Li, Shangqing Liu|arXiv (Cornell University)|Oct 8, 2022
Software Testing and Debugging TechniquesComputer Science5 citations
TL;DR

TransRepair is a Transformer-based, context-aware program repair framework that jointly localizes compilation errors and generates correct fixes in C programs by leveraging erroneous code, its surrounding context, and compiler diagnostic feedback. It achieves state-of-the-art performance with 85.6% single repair accuracy and 72.1% full repair accuracy on benchmark datasets, outperforming prior methods through a large-scale, fine-grained error pattern dataset and end-to-end learning.

ABSTRACT

Automatically fixing compilation errors can greatly raise the productivity of software development, by guiding the novice or AI programmers to write and debug code. Recently, learning-based program repair has gained extensive attention and became the state-of-the-art in practice. But it still leaves plenty of space for improvement. In this paper, we propose an end-to-end solution TransRepair to locate the error lines and create the correct substitute for a C program simultaneously. Superior to the counterpart, our approach takes into account the context of erroneous code and diagnostic compilation feedback. Then we devise a Transformer-based neural network to learn the ways of repair from the erroneous code as well as its context and the diagnostic feedback. To increase the effectiveness of TransRepair, we summarize 5 types and 74 fine-grained sub-types of compilations errors from two real-world program datasets and the Internet. Then a program corruption technique is developed to synthesize a large dataset with 1,821,275 erroneous C programs. Through the extensive experiments, we demonstrate that TransRepair outperforms the state-of-the-art in both single repair accuracy and full repair accuracy. Further analysis sheds light on the strengths and weaknesses in the contemporary solutions for future improvement.

Motivation & Objective

  • To address the limitations of existing learning-based program repair tools that ignore contextual code and rely on potentially inaccurate compiler feedback.
  • To improve the accuracy of automatic compilation error repair by modeling the semantic context around error locations and integrating diagnostic feedback effectively.
  • To develop a high-quality, diverse dataset of 1,821,275 synthetic C programs with 74 fine-grained error patterns across 5 types to train robust repair models.
  • To design an end-to-end, context-aware neural model that simultaneously localizes error lines and generates correct fixes, avoiding reliance on error-message-only or RNN-based architectures.

Proposed method

  • A fine-grained classification of 74 sub-types of compilation errors across 5 main categories was derived from real-world and internet-sourced erroneous C programs.
  • A program corruption technique was designed to systematically inject these 74 error patterns into 1,821,275 correct C programs, generating a large, diverse synthetic dataset for training.
  • A Transformer-based neural network was developed to take as input the erroneous program, its contextual code, and compiler diagnostic feedback, enabling joint error localization and fix generation.
  • The model incorporates a pointer-generator mechanism to handle OOV (out-of-vocabulary) code tokens, improving robustness to rare or unseen syntax.
  • The architecture is trained end-to-end using sequence-to-sequence learning, with loss functions optimized for both error localization and fix generation.
  • The model is evaluated on two public benchmarks, with ablation studies to validate the contribution of context and feedback components.

Experimental results

Research questions

  • RQ1Can a context-aware, end-to-end deep learning model outperform existing methods in repairing compilation errors in C programs by integrating code context and compiler feedback?
  • RQ2How effective is a large-scale, fine-grained synthetic dataset of 1.8M erroneous C programs in improving model generalization and repair accuracy?
  • RQ3To what extent do compiler diagnostic feedback and surrounding code context contribute to accurate error localization and fix generation in the absence of precise error-message alignment?
  • RQ4Does the use of a Transformer-based architecture with pointer mechanisms improve repair performance compared to RNN-based or graph-based models in this task?
  • RQ5What are the key failure modes and limitations of current state-of-the-art approaches, and how can they be addressed in future designs?

Key findings

  • TransRepair achieves a single repair accuracy of 85.6% on the DeepFix benchmark, significantly outperforming the previous SOTA method DrRepair (78.3%).
  • On the TRACER benchmark, TransRepair achieves a full repair accuracy of 72.1%, surpassing DrRepair’s 65.4% and other baselines.
  • The inclusion of code context and diagnostic feedback improves repair accuracy by up to 12.7 percentage points compared to models that ignore context.
  • Ablation studies confirm that both context and feedback are critical components, with context contributing more to error localization and feedback to fix generation.
  • The model generalizes well to unseen error patterns, demonstrating robustness on real-world error distributions beyond synthetic data.
  • Analysis reveals that the model struggles most with complex semantic errors and multi-line fixes, indicating room for improvement in handling structural and semantic reasoning.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.