Fault Localization Using Failure-Related Contexts for Automatic Program Repair

Ang Li, Xiaoguang Mao, Yan Lei, Tao JiIEICE 2015

Abstract

Fault localization is essential for conducting effective program repair. However, preliminary studies have shown that existing fault localization approaches do not take the requirements of automatic repair into account, and therefore restrict the repair performance. To address this issue, this paper presents the first study on designing fault localization approaches for automatic program repair, that is, we propose a fault localization approach using failure-related contexts in order to improve automatic program repair. The proposed approach first utilizes program slicing technique to construct a failure-related context, then evaluates the suspiciousness of each element in this context, and finally transfers the result of evaluation to automatic program repair techniques for performing repair on faulty programs. The experimental results demonstrate that the proposed approach is effective to improve automatic repair performance.

Introduction

Fixing software bugs is a massive drain on resources, often accounting for up to 90% of a project's cost. While automatic program repair (APR) tools like GenProg aim to solve this by evolving patches using genetic algorithms, they are notoriously resource-hungry. A single successful repair can take over 90 minutes and consume significant cloud computing power.

The bottleneck is often Fault Localization (FL). Most existing FL techniques are designed for humans; they provide a ranked list of "suspicious" lines of code but lack context. A human developer can look at a ranked line and understand its relationship to the crash, but a machine lacks that intuition. Consequently, APR tools waste a huge amount of time trying to "fix" lines of code that have nothing to do with the actual failure, leading to a mountain of invalid patches and slow performance.

The FLFC Approach

The researchers propose a three-step approach called FLFC (Fault Localization using Failure-Related Contexts) to bridge the gap between raw rankings and actionable context for machines:

  1. Construct a Failure-Related Context: Instead of looking at the whole program, the tool uses backward program slicing. Starting from a failed output, it identifies every statement in the code that could have influenced that specific value. This creates a "slice" of the program containing only code relevant to the failure.
  2. Evaluate Suspiciousness: Within this narrowed-down slice, the researchers apply Spectrum-based Fault Localization (SFL) using the Jaccard formula to calculate a suspiciousness score for each statement.
  3. Integration with Repair: This prioritized, context-aware list is fed into GenProg. The repair engine then focuses its mutation operations (changing, deleting, or moving code) only on these highly relevant statements.

Experimental Setup and Datasets

The study evaluated FLFC using 10 real-world bugs from four major open-source C projects, which are standard benchmarks in the APR community. These projects range from 77,000 to over 2.8 million lines of code (LOC).

Table 1: Characteristics of the programs and bug versions used in the evaluation.

Key Results and Insights

The researchers compared GenProg equipped with FLFC against a standard version of GenProg using a basic Jaccard-based FL module. The results were significant:

  • Efficiency: The average repair time decreased by 39.74%.
  • Effectiveness: The Number of Candidate Patches (NCP)—the number of "wrong" fixes tried before finding the right one—decreased by 38.37%.
Figure 2: Boxplots comparing repair time across different bug versions, showing significant improvements with the proposed approach.

Statistical analysis using the Wilcoxon-Signed-Rank Test confirmed that FLFC performed "BETTER" across all 10 bug versions tested. The core insight is that APR tools are essentially "blind" searchers; by providing a failure-related context via slicing, researchers aren't just telling the machine where the bug might be, they are telling it where the bug cannot be.

Conclusion

FLFC demonstrates that fault localization for machines should prioritize a "clean context" over a simple high rank. By pruning the search space, FLFC allows repair tools to find correct fixes much faster and with fewer invalid attempts. While the study is limited by a small sample size and dependency on specific slicing tools, it provides a foundational framework for context-aware automated debugging.

Summary updated

BibTeX
@inproceedings{li2015fault,
  author = {Ang Li and Xiaoguang Mao and Yan Lei and Tao Ji},
  title = {{Fault Localization Using Failure-Related Contexts for Automatic Program Repair}},
  booktitle = {IEICE},
  year = {2015},
  doi = {10.1587/transinf.2014edl8189},
}
Figure