J Shanghai Jiaotong Univ Sci ›› 2023, Vol. 28 ›› Issue (6): 738-752.doi: 10.1007/s12204-022-2514-6

• Computing & Computer Technologies • Previous Articles     Next Articles

Random Search and Code Similarity-Based Automatic Program Repair

基于随机搜索和代码相似性的程序自动修复

CAO Helinga,b (曹鹤玲),LIU Fangzhenga (刘方正),SHI Jianshua (石建树),CHU Yonghea (楚永贺),DENG Miaoleia* (邓淼磊)   

  1. (a. College of Information Science and Engineering; b. Henan International Joint Laboratory of Grain Information Processing, Henan University of Technology, Zhengzhou 450001, China)
  2. (河南工业大学 a. 信息科学与工程学院;b. 河南省粮食信息处理国际联合实验室,郑州450001)
  • Accepted:2022-03-20 Online:2023-11-28 Published:2023-12-04

Abstract: In recent years, automatic program repair approaches have developed rapidly in the field of software engineering. However, the existing program repair techniques based on genetic programming suffer from requiring verification of a large number of candidate patches, which consume a lot of computational resources. In this paper, we propose a random search and code similarity based automatic program repair (RSCSRepair). First, to reduce the verification computation effort for candidate patches, we introduce test filtering to reduce the number of test cases and use test case prioritization techniques to reconstruct a new set of test cases. Second, we use a combination of code similarity and random search for patch generation. Finally, we use a patch overfitting detection method to improve the quality of patches. In order to verify the performance of our approach, we conducted the experiments on the Defects4J benchmark. The experimental results show that RSCSRepair correctly repairs up to 54 bugs, with improvements of 14.3%, 8.5%, 14.3% and 10.3% for our approach compared with jKali, Nopol, CapGen and SimFix, respectively

Key words: program repair, random search, test case prioritization, overfitting detection

摘要: 近年来,自动程序修复方法在软件工程领域发展迅速。然而,现有基于遗传编程的程序修复技术需要验证大量候选补丁,这会消耗大量的计算资源。本文提出了一种基于随机搜索和代码相似性的自动程序修复方法(RSCSRepair)。首先,为了减少候选补丁的验证计算工作量,引入测试过滤来减少测试用例的数量,并使用测试用例优先级排序技术来重组新的测试用例。其次,结合代码相似性和随机搜索来生成补丁。最后,使用补丁过拟合检测方法来提高补丁的质量。为了验证该方法的性能,在 Defects4J 基准评测库上进行了实验。实验结果表明:RSCSRepair 正确修复了54个错误,与 jKali、Nopol、CapGen和SimFix相比,该方法分别提高了14.3%、8.5%、14.3%、10.3%的正确率。

关键词: 程序修复,随机搜索,测试用例优先级,过拟合检测

CLC Number: