一句话:提出 Mulpor,联合语句、表达式与 token 三个粒度生成补丁并启发式重排序,显著提升自动程序修复效果。
自动程序修复旨在自动纠正缺陷、减轻人工调试负担。已有学习式修复方法主要将修复视为翻译任务或完形填空任务,分别侧重语句级与 token 级修复;然而真实补丁可能处于语句、表达式或 token 等不同粒度,单一粒度生成难以应对多样缺陷。为此,本文提出多粒度补丁生成方法 Mulpor,包含语句级、表达式级与 token 级三个生成器,各自在对应粒度上预训练,先分别生成候选补丁,再依据启发式规则进行重排序以优先选择更可能正确的补丁。在 Defects4J-v1.2 上,Mulpor 正确修复 92 个缺陷,较 NMT 风格的 Rap-Gen 与 Cloze 风格的 GAMMA 分别提升 27.0%(20 个)与 12.2%(10 个);在漏洞修复任务中,正确修复补丁数较当前最优方法提升 51%,表明多粒度策略能实现更有效且多样的修复。
Automated program repair aims to automate bug correction and alleviate the burden of manual debugging, which plays a crucial role in software development and maintenance. Recent studies reveal that learning-based approaches have outperformed conventional APR techniques (e.g., search-based APR). Existing learning-based APR techniques mainly center on treating program repair either as a translation task or a cloze task. The former primarily emphasizes statement-level repair, while the latter concentrates on token-level repair, as per our observations. In practice, however, patches may manifest at various repair granularity, including statement, expression, or token levels. Consequently, merely generating patches from a single granularity would be ineffective to tackle real-world defects. Motivated by this observation, we propose Mulpor, a multi-granularity patch generation approach designed to address the diverse nature of real-world bugs. Mulpor comprises three components: statement-level, expression-level, and token-level generator, each is pre-trained to generate correct patches at its respective granularity. The approach involves generating candidate patches from various granularities, followed by a re-ranking process based on a heuristic to prioritize patches. Experimental results on the Defects4J dataset demonstrate that Mulpor correctly repair 92 bugs on Defects4J-v1.2, which achieves 27.0% (20 bugs) and 12.2% (10 bugs) improvement over the previous state-of-the-art NMT-style Rap-Gen and Cloze-style GAMMA. We also studied the generalizability of Mulpor in repairing vulnerabilities, revealing a notable 51% increase in the number of correctly-fixed patches compared with state-of-the-art vulnerability repair approaches. This paper underscores the importance of considering multiple granularities in program repair techniques for a comprehensive strategy to address the diverse nature of real-world software defects. Mulpor, as proposed herein, exhibits promising results in achieving effective and diverse bug fixes across various program repair scenarios.
DOI 原文 ·
@inproceedings{paperbot8455,
title = {One Size Does Not Fit All: Multi-granularity Patch Generation for Better Automated Program Repair},
author = {Bo Lin and Shangwen Wang and Ming Wen and Liqian Chen and Xiaoguang Mao},
booktitle = {ISSTA},
year = {2024},
doi = {10.1145/3650212.3680381}
}