Abstract
Logic errors represent a significant challenge in Automated Program Repair (APR) because they do not trigger compiler warnings, yet they lead to incorrect program behavior. This research introduces a novel approach that leverages pseudocode as a semantic guide. By constructing a graph that aligns source code tokens with their corresponding pseudocode descriptions and applying a Graph Neural Network (GNN) integrated with an LSTM, the proposed model achieves a near-perfect localization accuracy of 99.39%, significantly outperforming traditional sequence-based models.
Introduction
In the domain of Automated Program Repair, syntax errors have historically received the most attention due to the explicit feedback provided by compilers. Logic errors, however, are "silent killers": the code is syntactically correct and runs, but the output is wrong. Detecting and fixing these errors requires understanding the programmer's intent, which is often captured in high-level specifications or pseudocode. This study addresses the scarcity of logic error datasets and the limitations of existing tools by introducing the Logic-Err dataset and a specialized hybrid architecture.
Methodology: Bridging Intent and Implementation
The core of the proposed solution is a hybrid architecture that combines Long Short-Term Memory (LSTM) networks with Graph Attention Networks. The model treats the relationship between code and its specification as a graph problem rather than a simple sequence-to-sequence task.
Code-Pseudocode Graph
The researchers developed a graph structure where nodes represent tokens in the source code and lines in the pseudocode. Edges are drawn between corresponding elements, allowing the model to "trace" the implementation back to the original logic. This alignment serves as a Rosetta Stone, helping the model identify where the code deviates from the intended behavior.
Model Architecture
The system employs a seq2seq structure. The encoder processes both source code and pseudocode, utilizing a graph attention layer to weigh the importance of neighboring nodes. This allows the model to focus on relevant context across distant lines of code. The decoder then performs two tasks: it predicts the probability distribution of the erroneous line (localization) and generates a corrected patch for that line (repair).
The Logic-Err Dataset
To train and evaluate the model, the authors created the Logic-Err dataset. Built upon the SPoC (Search-based Pseudocode to Code) dataset, it contains 871 logic errors isolated from 500 programs. These errors were generated by using the DrRepair tool to fix syntax errors until only logic flaws remained. Each entry is comprehensive, including source code, line-by-line pseudocode, and test cases for verification.
Key Results
The experimental results demonstrate the power of incorporating graph-based structural information. The "LSTM+Graph" model was compared against a standard LSTM and DrRepair, a state-of-the-art syntax repair tool.
The results show a dramatic leap in performance:
- Localization Accuracy: The LSTM+Graph model reached 99.39%, while the pure LSTM managed only 31.22%. DrRepair, designed for syntax, failed almost entirely with 0.21%.
- Repair Accuracy: While more challenging, the graph-based approach still outperformed the baseline, achieving 19.20% compared to the LSTM's 11.10%.
Conclusion and Future Work
The study proves that pseudocode is a vital asset for logic error repair. By transforming the problem into a graph-based alignment task, the model can pinpoint errors with nearly 100% accuracy. However, generating the correct fix remains difficult, with a repair accuracy of under 20%. Future research will focus on expanding the dataset, supporting multiple programming languages, and improving the decoder's ability to generate functionally correct patches.
Summary updated