Skip to main content
QUICK REVIEW

[Paper Review] Beep: Fine-grained Fix Localization by Learning to Predict Buggy Code Elements

Shangwen Wang, Kui Liu|arXiv (Cornell University)|Nov 15, 2021
Software Engineering ResearchComputer Science100 references5 citations
TL;DR

This paper proposes Beep, a deep learning model that localizes buggy code tokens and predicts the required repair operations with fine-grained precision. Trained on the CoCoNut dataset using AST paths, Beep achieves a Mean First Rank of 7–12 and Recall@1 of 30–45% on multiple benchmarks, enabling 100% correct patch generation in two repair pipelines by eliminating overfitting and improving efficiency.

ABSTRACT

Software Fault Localization refers to the activity of finding code elements (e.g., statements) that are related to a software failure. The state-of-the-art fault localization techniques, however, produce coarse-grained results that can deter manual debugging or mislead automated repair tools. In this work, we focus specifically on the fine-grained identification of code elements (i.e., tokens) that must be changed to fix a buggy program: we refer to it as fix localization. This paper introduces a neural network architecture (named Beep) that builds on AST paths to predict the buggy code element as well as the change action that must be applied to repair a program. Leveraging massive data of bugs and patches within the CoCoNut dataset, we trained a model that was (1) effective in localizing the buggy tokens with the Mean First Rank significantly higher than a statistics based baseline and a machine learning-based baseline, and (2) effective in predicting the repair operators (with the associated buggy code elements) with a Recall@1= 30-45% and the Mean First Rank=7-12 (evaluated by CoCoNut, ManySStuBs4J, and Defects4J datasets). To showcase how fine-grained fix localization can help program repair, we employ it in two repair pipelines where we use either a code completion engine to predict the correct token or a set of heuristics to search for the suitable donor code. A key strength of accurate fix localization for program repair is that it reduces the chance of patch overfitting, a challenge in generate-and-validate automated program repair: both two repair pipelines achieve a correctness ratio of 100%, i.e., all generated patches are found to be correct. Moreover, accurate fix localization helps enhance the efficiency of program repair.

Motivation & Objective

  • To address the limitations of coarse-grained fault localization in manual and automated debugging, which hinders efficient and accurate bug fixing.
  • To reduce overfitting in generate-and-validate automated program repair (APR) by enabling precise localization of buggy code elements.
  • To improve the efficiency and correctness of APR pipelines by identifying the exact tokens and change operators that must be modified.
  • To develop a neural network model that leverages AST paths and massive bug/patch data to predict fine-grained code changes.
  • To demonstrate that fine-grained fix localization enables 100% correct patch generation using code completion or heuristic-based repair pipelines.

Proposed method

  • Beep uses a neural network architecture that processes Abstract Syntax Tree (AST) paths to encode structural and semantic context around code elements.
  • The model is trained on the CoCoNut dataset, which contains millions of bug-fix pairs from real-world software projects.
  • It jointly predicts the buggy token and the corresponding repair operator (e.g., UPDATE, INSERT, DELETE) using a sequence-to-sequence learning approach.
  • The model leverages attention mechanisms over AST paths to focus on relevant syntactic and semantic features around the buggy code.
  • Two repair pipelines are evaluated: one using a code completion engine to predict the correct token, and another using heuristics to search for donor code.
  • The approach is evaluated on CoCoNut, ManySStuBs4J, and Defects4J datasets using standard metrics like Mean First Rank and Recall@1.

Experimental results

Research questions

  • RQ1Can a deep learning model accurately localize the exact buggy token within a method, beyond coarse-grained line or method-level localization?
  • RQ2Can the model predict the correct repair operator (e.g., UPDATE, INSERT) associated with the buggy token?
  • RQ3Does fine-grained fix localization reduce overfitting in automated program repair by minimizing changes to non-buggy code?
  • RQ4Can repair pipelines using Beep’s predictions achieve 100% correctness in patch generation?
  • RQ5How does Beep’s performance compare to baseline fault localization techniques in terms of localization accuracy and repair effectiveness?

Key findings

  • Beep achieves a Mean First Rank of 7–12 for buggy token localization across CoCoNut, ManySStuBs4J, and Defects4J, significantly outperforming statistical and machine learning baselines.
  • The model achieves a Recall@1 of 30–45% for predicting the correct repair operator, indicating strong precision in identifying the required change.
  • When integrated into two repair pipelines, Beep enables 100% correctness ratio, meaning all generated patches are correct and pass all test cases.
  • The use of fine-grained fix localization reduces the risk of overfitting by ensuring changes are applied only to the actual buggy elements.
  • The repair pipelines are efficient because they avoid exploring nonsensical changes to non-buggy code elements, reducing the search space significantly.
  • Beep generalizes well across diverse benchmarks, including real-world industrial projects in Defects4J and large-scale test suites in ManySStuBs4J.

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.