arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2309.09308cs.SE
收藏

GAMMA:通过掩码预测重新审视基于模板的自动程序修复

GAMMA: Revisiting Template-based Automated Program Repair via Mask Prediction

Quanjun Zhang, Chunrong Fang, Tongke Zhang, Bowen Yu, Weisong Sun, Zhenyu Chen

AI总结:

本文提出GAMMA,将模板修复模式转化为掩码预测任务,利用预训练语言模型直接生成供体代码,在Defects4J等基准上显著超越TBar和Recoder,并展示了良好的泛化性与可扩展性。

摘要:

自动程序修复(APR)旨在无需人工干预即可修复软件缺陷,基于模板的APR已被广泛研究并取得了有前景的结果。然而,基于模板的APR在选择合适的供体代码方面面临挑战,而供体代码是生成候选补丁的重要修复成分。不合适的供体代码即使使用正确的修复模式,也可能导致看似合理但错误的补丁生成,从而限制修复性能。\n在本文中,我们旨在重新审视基于模板的APR,并提出GAMMA,以直接利用大型预训练语言模型进行供体代码生成。我们的主要见解是,与其在本地有缺陷的文件中检索供体代码,不如通过完形填空任务,基于上下文代码片段和修复模式直接预测正确的代码标记。具体而言,(1)GAMMA从最先进的基于模板的APR技术(即TBar)中修订了多种修复模板,并将其转换为掩码模式。(2)GAMMA采用预训练语言模型,将掩码代码的正确代码预测作为填空任务。实验结果表明,GAMMA在Defects4J-v1.2上正确修复了82个缺陷,与先前最先进的基于模板的方法TBar和基于学习的方法Recoder相比,分别实现了20.59%(14个缺陷)和26.15%(17个缺陷)的提升。此外,GAMMA在额外的Defects4J-v2.0和QuixBugs上分别修复了45个和22个缺陷,表明GAMMA在解决数据集过拟合问题方面具有泛化能力。我们还证明,采用其他预训练语言模型可以带来实质性进步,例如,基于CodeBERT和基于ChatGPT的GAMMA能够在Defects4J-v1.2上分别修复80个和67个缺陷,表明GAMMA的可扩展性。总体而言,我们的研究突显了在修复模式之上采用预训练模型生成正确补丁的光明前景。

英文摘要:

Automated program repair (APR) aims to fix software bugs without human intervention and template-based APR has been widely investigated with promising results. However, it is challenging for template-based APR to select the appropriate donor code, which is an important repair ingredient for generating candidate patches. Inappropriate donor code may cause plausible but incorrect patch generation even with correct fix patterns, limiting the repair performance. In this paper, we aim to revisit template-based APR, and propose GAMMA, to directly leverage large pre-trained language models for donor code generation. Our main insight is that instead of retrieving donor code in the local buggy file, we can directly predict the correct code tokens based on the context code snippets and repair patterns by a cloze task. Specifically, (1) GAMMA revises a variety of fix templates from state-of-the-art template-based APR techniques (i.e., TBar) and transforms them into mask patterns. (2) GAMMA adopts a pre-trained language model to predict the correct code for masked code as a fill-in-the-blank task. The experimental results demonstrate that GAMMA correctly repairs 82 bugs on Defects4J-v1.2, which achieves 20.59\% (14 bugs) and 26.15\% (17 bugs) improvement over the previous state-of-the-art template-based approach TBar and learning-based one Recoder. Furthermore, GAMMA repairs 45 bugs and 22 bugs from the additional Defects4J-v2.0 and QuixBugs, indicating the generalizability of GAMMA in addressing the dataset overfitting issue. We also prove that adopting other pre-trained language models can provide substantial advancement, e.g., CodeBERT-based and ChatGPT-based GAMMA is able to fix 80 and 67 bugs on Defects4J-v1.2, indicating the scalability of GAMMA. Overall, our study highlights the promising future of adopting pre-trained models to generate correct patches on top of fix patterns.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑