Source-linked AI summary

Neural Program Repair by Jointly Learning to Localize and Repair

Marko Vasic, Aditya Kanade, Petros Maniatis, David Bieber, Rishabh Singh

arXiv:1904.01720v1cs.LGstat.ML

TL;DR

Enumerative variable-misuse repair makes predictions for possible bug locations, but can lose shared context and encounter a training/test mismatch. This paper uses multi-headed pointers to jointly classify, localize, and repair variable misuses. The joint model outperforms enumerative repair, with reported gains in localization and localization-plus-repair accuracy.

  • Problem

    Enumerative repair makes separate predictions for variable-use slots, losing shared context and creating a training/test mismatch that can reduce accuracy.

    Source: §1 · p. 2
  • Method

    A multi-headed pointer model jointly classifies a program, localizes a variable-misuse bug, and points to a repair location.

    Source: §1 · p. 2
  • Results

    The joint model reaches 71% localization accuracy and 65.7% localization+repair accuracy, improving about 6.4% and 9.9%, respectively, over the enumerative approach.

    Source: §4.1 · p. 7
  • Takeaways & Limitations

    Jointly learning localization and repair significantly outperforms enumerative repair using a pointer model that predicts repairs for candidate bug locations.

    Source: §5 · p. 10

    The pointer-versus-graph comparison is limited to syntactic inputs; comparisons with semantics and joint prediction at unknown bug locations remain future work.

    Source: §1 · p. 3

Abstract

from arXiv · show

Due to its potential to improve programmer productivity and software quality, automated program repair has been an active topic of research. Newer techniques harness neural networks to learn directly from examples of buggy programs and their fixes. In this work, we consider a recently identified class of bugs called variable-misuse bugs. The state-of-the-art solution for variable misuse enumerates potential fixes for all possible bug locations in a program, before selecting the best prediction. We show that it is beneficial to train a model that jointly and directly localizes and repairs variable-misuse bugs. We present multi-headed pointer networks for this purpose, with one head each for localization and repair. The experimental results show that the joint model significantly outperforms an enumerative solution that uses a pointer based model for repair alone.

1 INTRODUCTION

The paper replaces enumerative variable-misuse repair with a model that jointly classifies, localizes, and repairs faults. It reports higher classification, localization, and repair accuracy than the enumerative approach, while its comparison with a graph model is limited to syntactic inputs.

1 INTRODUCTION

  • Variable misuse occurs when a variable use has the wrong variable, a bug class studied alongside neural program representations for repair, optimization, and synthesis.Prior neural representations include token sequences, parse trees, program traces, and graphs.Source: §1 · p. 1
  • Enumerating one repair prediction per variable-use slot loses shared context, creates a training/test mismatch, and requires thresholding many predictions.The paper reports a 4% to 14% accuracy drop from the mismatch even when the bug location is provided; threshold choice also trades false positives against false negatives.Source: §1 · p. 2
  • The model jointly classifies a program as faulty or correct, localizes a fault when present, and repairs the localized variable misuse using pointer networks over program tokens.The paper presents extensive evaluation across multiple large program datasets.Source: §1 · pp. 2–3
  • A variable token can be the faulty use, a location containing the correct variable for repair, or neither, enabling pointers to reuse repair ingredients elsewhere in the program.The problem includes mistakes such as failing to rename a variable after copying code or confusing names within one scope.Source: §1 · pp. 1–2
  • The joint model achieves higher classification, localization, and repair accuracy, and a high true-positive score, than the enumerative approach.The paper also reports a 7-percentage-point advantage over a graph neural network on repair given a known bug location, but that comparison uses syntactic inputs only.Source: §1 · p. 2
  • The pointer model exceeds the graph neural network by 7 percentage points for repair with a known bug location, but this comparison is limited to syntactic inputs.The graph model uses syntax and semantics; comparison with semantics and joint prediction at unknown locations are left for future work.Source: §1 · pp. 2–3

2 RELATED WORK

Related work ranges from enumerative neural repair and expression-level bug detection to syntax repair and specification-guided automated repair. This paper contrasts those approaches with direct joint classification, localization, and repair of variable misuse.

2 RELATED WORK

  • Allamanis et al. (2018) enumerate variable-use predictions with a graph neural network using syntax and semantics, while Devlin et al. (2017b) enumerate repair candidates and score them.The paper notes that both approaches face a training/test mismatch; its own multi-headed pointers jointly classify, localize, and repair.Source: §2 · p. 3
  • DeepFix and SynFix target syntax errors, while this work localizes and repairs semantic variable misuses.DeepFix generates a replacement line after localization; SynFix uses compiler-identified locations and constraint-based search.Source: §2 · p. 3
  • DeepBugs (Pradel & Sen, 2018) classifies expressions for three name-based bug types, whereas this model embeds the full program and points to variable-use repairs.The pointer can select variables outside the buggy expression.Source: §2 · p. 3
  • The Sk p encoder-decoder repairs statements, but predicting full statements may make variable-misuse repairs requiring variables defined multiple lines earlier difficult.The paper contrasts this with its pointer mechanism for selecting variable uses.Source: §2 · p. 3
  • Traditional specification-guided repair relies on correctness specifications and hand-designed search, whereas learning-based repair learns common error types from source examples and can classify, localize, and repair them.The paper distinguishes those common-error benchmarks from test-based benchmarks whose bugs are specific to individual programs.Source: §2 · pp. 3–4

3 POINTER MODELS FOR LOCALIZATION AND REPAIR OF VARMISUSE

The model uses pointer networks to jointly identify a variable-misuse location and select a repair variable already present in the program. It defines the task, describes a multi-headed architecture, and trains it on synthetic buggy and bug-free examples.

3.2 MULTI-HEADED POINTER MODELS

  • The model encodes program tokens with an LSTM and uses two pointer distributions to predict the bug location and repair-variable location.The pointers are trained end-to-end; the paper focuses on localizing a single bug and notes that more pointer heads can support multiple bugs.Source: §3 · p. 4, §3.2 · p. 5

3.1 PROBLEM DEFINITION

  • VARMISUSEREPAIR asks whether a program is correct or, if faulty, which variable-use location is wrong and which existing variable occurrence can repair it.The repair variable must be one defined in the program; variable-use scope may be defined differently, and the comparison with Allamanis et al. uses their broader load-or-store definition.Source: §3.1 · p. 4

3.3 TRAINING THE MODEL

  • Training examples come from program definitions and include synthetic buggy examples formed by replacing a chosen variable with an incorrect one.The training set also includes non-buggy examples, balanced 50-50 with buggy examples; correct-variable repair targets can mark all occurrences of the intended variable.Source: §3.3 · pp. 5–6
  • The joint model minimizes the sum of location and repair losses, while the enumerative baseline uses a repair-only pointer model.An alternative repair loss uses the maximum of the probabilities of repair pointers instead of their addition.Source: §3.3 · p. 6

4 EVALUATION

The evaluation compares joint prediction with enumerative repair, tests sensitivity to incorrect slot placement, compares pointer and graph repair, and evaluates the model on industrial histories.

4 EVALUATION

  • Evaluation uses ETH-Py150 Python functions and MSR-VarMisuse C# files; the ETH enumerative comparison uses a filtered test set of 12,218 examples.The ETH set creates buggy and bug-free examples for training, while its evaluation set samples one slot per function.Source: §4 · pp. 6–7

4.1 JOINT MODEL VS. ENUMERATIVE APPROACH

  • The joint model reaches 71% localization accuracy and 65.7% localization+repair accuracy, improving on the enumerative approach while maintaining 84.5% true-positive and 82.4% classification accuracy.The reported localization and repair improvements over the enumerative approach's lowest-threshold, highest-k setting are about 6.4% and 9.9%, respectively.Source: §4.1 · p. 7, Table 1 · p. 8

4.2 EFFECT OF INCORRECT SLOT PLACEMENT

  • Incorrect slot placement drops repair accuracy by about 4.3 percentage points for Any at τ = 0.5 and by 8 to 14.6 points for the more adversarial Near setting.Near injects a bug within two variable-use locations of the slot and in the first 30 program tokens.Source: §4.2 · p. 8, Figure 3 · p. 9

4.3 COMPARISON OF GRAPH AND POINTER NETWORKS

  • On the MSR-VarMisuse seen test, pointer-based repair reaches 62.3% accuracy versus 55.3% for the graph-based model's syntax-only ablation, a 7-point advantage.The comparison is limited to syntactic inputs; the graph model uses syntax and semantics, and the pointer model's training dataset is about 30% smaller.Source: §4.3 · p. 9

4.4 EVALUATION ON VARIABLE MISUSE IN PRACTICE

  • On 4,592 industrial snapshot pairs, the joint model achieves 67.3% true positive rate, 66.7% classification accuracy, 21.9% localization accuracy, and 15.8% localization+repair accuracy, outperforming enumeration on each.The enumerative approach scores 41.7%, 47.2%, 6.1%, and 4.5% on those respective metrics; the joint model localizes and repairs 727 instances in aggregate.Source: Table 2 · p. 10, §4.4 · p. 10

5 CONCLUSION

The paper jointly learns to localize and repair variable-misuse bugs, using the insight that both the bug and its repair must exist in the original program; the approach significantly outperforms an enumerative model.

  • The joint model significantly outperforms an enumerative approach for variable-misuse repair.Source: §5 · p. 10
  • The model uses the insight that both the bug and its repair must exist in the original program.Source: §5 · p. 10
  • Future work will explore joint localization and repair with graph models, pointer-graph combinations, and more semantic program information.Source: §5 · p. 10

A TRAINING DATA GENERATION

The training examples use variable reads with multiple in-scope repair candidates, and include both generated buggy examples and assumed-correct examples.

  • ETH-Py150 slots are variable uses in load contexts, and repair candidates are in-scope variables, including locals, globals, and formal arguments.Source: A TRAINING DATA GENERATION · p. 12
  • Examples are generated only for slots with at least two repair candidates; each eligible slot gets a buggy example and a bug-free example, with correct functions duplicated across examples.Source: A TRAINING DATA GENERATION · p. 12
  • MSR-VarMisuse contains 25 C# projects split into train, validation, seen-test, and unseen-test partitions; its slots include load and store uses with type-compatible candidates.Source: A TRAINING DATA GENERATION · p. 12
Loading 1904.01720v1…