Debugging software remains a labor-intensive and time-consuming process despite advances in testing and verification. Learning-based automated program repair (APR) has shown promise in reducing the effort of manually fixing bugs. However, existing techniques face several challenges, including language-dependent strategies, limited bug context utilization, and difficulties in handling bugs that span multiple locations in the code. This paper presents MultiMend, a multilingual learning-based APR approach designed to improve repair performance through language-independent context augmentation and multi-hunk patch generation. MultiMend fine-tunes a pre-trained code language model to generate bug-fixing patches. It embeds source code lines and applies retrieval-augmented generation to augment the usual function-based buggy context with relevant lines during patch generation. The approach also systematically constructs patches for multi-hunk bugs to extend the capabilities of single-hunk models and reduce the needed patch validations. We evaluate MultiMend on six benchmarks with 5,501 bugs covering four programming languages and compare it with state-of-the-art methods. Results show that MultiMend achieves competitive effectiveness and efficiency, fixing 2,227 bugs, of which 1,545 are identical to the developer's patch, and 121 are for multi-hunk bugs. Both context augmentation and multi-hunk patch generation contribute positively to these results. Overall, MultiMend's contributions are promising and offer practical and effective techniques to enhance APR performance for real-world software maintenance.
翻译:尽管测试与验证技术取得了进展,软件调试仍然是一个劳动密集型且耗时的过程。基于学习的自动化程序修复(APR)在减少人工修复错误的工作量方面显示出潜力。然而,现有技术面临若干挑战,包括语言依赖策略、错误上下文利用有限以及难以处理跨代码多个位置的错误。本文提出MultiMend,一种基于学习的多语言APR方法,旨在通过语言无关的上下文增强和多代码块补丁生成来提高修复性能。MultiMend通过微调预训练的代码语言模型来生成错误修复补丁。它嵌入源代码行,并在补丁生成过程中应用检索增强生成技术,用相关代码行增强通常基于函数的错误上下文。该方法还系统地为多代码块错误构建补丁,以扩展单代码块模型的能力并减少所需的补丁验证次数。我们在涵盖四种编程语言的六个基准数据集(共5,501个错误)上评估MultiMend,并与最先进的方法进行比较。结果表明,MultiMend实现了具有竞争力的有效性和效率,修复了2,227个错误,其中1,545个与开发者的补丁完全相同,121个为多代码块错误。上下文增强和多代码块补丁生成均对这些结果产生了积极贡献。总体而言,MultiMend的贡献具有前景,并为增强现实世界软件维护中的APR性能提供了实用且有效的技术。