SimFix

Published:

I. Introduction

SimFix is an automatic program repair technique, which leverages exisiting patches from other projects and similar code snippets in the same project to generate patches. The following figure is the workflow of our approach.

Mining Stage

1. mine repair patterns from existing open-source projects, after which we can obtain a set of frequent repair patterns. Those patterns can be reused for other repairing scenarios as well.

Repairing Stage

1. Fault Localization : obtain a ranking list of candidate faulty statements and extract corresponding code snippets.
2. Donor Snippet Identification : identify the similarity between faulty code snippet and each candidate similar code snippet by leveraging three similarity metrics, according to which we obtain a list of candidate similar snippets with decending order of similarity value.
3. Variable Mapping : establish the mapping relationship between variables in faulty and similar code snippets by leveraging similarity metrics and then obtain a mapping table, based on which the variables in the donor code snippet will be replaced with the corresponding variables.
4. Modification Extraction and Intersection : extract code modifications to faulty code snippet via AST (Abstract Syntax Tree) matching and differencing against the donor snippet, and then the frequent patterns from the mining stage will be used to take intersection with those modifications to further ruled out invalid ones.
5. Patch Generation & Validation : generate repair patches by applying extracted code modifications to the faulty code snippet with combining and ranking whose modifications, then using the test suite to validate the correctness of candidate patches until a correct patch found or timeout.

if you want to use this project, please cite our technical paper published at ISSTA’18.

@inproceedings{Simfix:2018,
author   = {Jiang, Jiajun and Xiong, Yingfei and Zhang, Hongyu and
Gao, Qing and Chen, Xiangqun},
title    = {Shaping Program Repair Space with Existing Patches and Similar Code},
series   = {ISSTA},
year     = {2018},
location = {Amsterdam, Netherlands},
doi      = {10.1145/3213846.3213871},
}


II. Evaluation Result

Totally, SimFix successfully repair 34 bugs among 357 bugs in Defects4j v1.0 benchmark with generating 22 plausible but incorrect patches. The following table and venn diagram are comparison with existing approaches.

The comparison with existing approaches.Intersections.

View More Details on Github