Open Access iconOpen Access

ARTICLE

Integrating Attention Mechanism with Code Structural Affinity and Execution Context Correlation for Automated Bug Repair

Jinfeng Ji1, Geunseok Yang2,*

1 Department of Computer Applied Mathematics, Hankyong National University, Anseong-si, 17579, Gyeonggi-do, Republic of Korea
2 Department of Computer Applied Mathematics (Computer System Institute), Hankyong National University, Anseong-si, 17579, Gyeonggi-do, Republic of Korea

* Corresponding Author: Geunseok Yang. Email: email

(This article belongs to the Special Issue: Attention Mechanism-based Complex System Pattern Intelligent Recognition and Accurate Prediction)

Computers, Materials & Continua 2026, 86(3), 73 https://doi.org/10.32604/cmc.2025.071733

Abstract

Automated Program Repair (APR) techniques have shown significant potential in mitigating the cost and complexity associated with debugging by automatically generating corrective patches for software defects. Despite considerable progress in APR methodologies, existing approaches frequently lack contextual awareness of runtime behaviors and structural intricacies inherent in buggy source code. In this paper, we propose a novel APR approach that integrates attention mechanisms within an autoencoder-based framework, explicitly utilizing structural code affinity and execution context correlation derived from stack trace analysis. Our approach begins with an innovative preprocessing pipeline, where code segments and stack traces are transformed into tokenized representations. Subsequently, the BM25 ranking algorithm is employed to quantitatively measure structural code affinity and execution context correlation, identifying syntactically and semantically analogous buggy code snippets and relevant runtime error contexts from extensive repositories. These extracted features are then encoded via an attention-enhanced autoencoder model, specifically designed to capture significant patterns and correlations essential for effective patch generation. To assess the efficacy and generalizability of our proposed method, we conducted rigorous experimental comparisons against DeepFix, a state-of-the-art APR system, using a substantial dataset comprising 53,478 student-developed C programs. Experimental outcomes indicate that our model achieves a notable bug repair success rate of approximately 62.36%, representing a statistically significant performance improvement of over 6% compared to the baseline. Furthermore, a thorough K-fold cross-validation reinforced the consistency, robustness, and reliability of our method across diverse subsets of the dataset. Our findings present the critical advantage of integrating attention-based learning with code structural and execution context features in APR tasks, leading to improved accuracy and practical applicability. Future work aims to extend the model’s applicability across different programming languages, systematically optimize hyperparameters, and explore alternative feature representation methods to further enhance debugging efficiency and effectiveness.

Keywords

Automated bug repair; autoencoder algorithm; buggy code analysis; stack trace similarity; machine learning for debugging

Cite This Article

APA Style
Ji, J., Yang, G. (2026). Integrating Attention Mechanism with Code Structural Affinity and Execution Context Correlation for Automated Bug Repair. Computers, Materials & Continua, 86(3), 73. https://doi.org/10.32604/cmc.2025.071733
Vancouver Style
Ji J, Yang G. Integrating Attention Mechanism with Code Structural Affinity and Execution Context Correlation for Automated Bug Repair. Comput Mater Contin. 2026;86(3):73. https://doi.org/10.32604/cmc.2025.071733
IEEE Style
J. Ji and G. Yang, “Integrating Attention Mechanism with Code Structural Affinity and Execution Context Correlation for Automated Bug Repair,” Comput. Mater. Contin., vol. 86, no. 3, pp. 73, 2026. https://doi.org/10.32604/cmc.2025.071733



cc Copyright © 2026 The Author(s). Published by Tech Science Press.
This work is licensed under a Creative Commons Attribution 4.0 International License , which permits unrestricted use, distribution, and reproduction in any medium, provided the original work is properly cited.
  • 395

    View

  • 107

    Download

  • 0

    Like

Share Link