arXiv:2611.01292cs.SEOct 2026

Manuscript Offprint

arXiv:2611.01292

Causality-Based Fault Localization

Melane Navaratnarajah, Aidan Dakhama, Tom Yaacov, David A. Kelly, Karine Even-Mendoza, Hana Chockler

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Melane Navaratnarajah¹[0009-0001-8987-6134], Aidan Dakhama²[0009-0002-7318-7964], Tom Yaacov¹[0000-0002-0565-6506], David A. Kelly¹[0000-0002-5368-6769], Karine Even-Mendoza¹[0000-0002-3099-1189], and Hana Chockler¹[0000-0003-1219-0713]

¹ King's College London, London, UK {melane.navaratnarajah,tom.yaacov,david.a.kelly, karine.even_mendoza,hana.chockler}@kcl.ac.uk ² University of Edinburgh, Edinburgh, UK aidandakhama@ed.ac.uk

Abstract. We introduce Causality-Based Fault Localization (CBFL), a novel approach to fault localization grounded in the theory of actual causality. We use the notion of causal responsibility to formalize and define the contribution of a given location in the source code under the context of a failing test. We also utilize a distance metric to prioritize minimal fixes and penalize broken tests, leading to more interpretable and fixable fault localization. We implemented CBFL in a tool, softrex, and our evaluation results demonstrate that softrex outperforms state-of-the-art Mutation-Based Fault Localization (MBFL) tools based on Mean Reciprocal Rank (MRR) and Top-1 by 16% on both metrics, when using the same set of mutants. We also propose a sophisticated mutation generation strategy based on the structure and representation of the program to improve the accuracy of our ranked list, which outperforms state-of-the-art methods by 2.6× in terms of required mutants evaluated while remaining competitive in performance.

Keywords: Causality, Software Engineering, Fault Localization, Testing

1 Introduction

Motivation. Software debugging remains one of the most challenging and costly activities in software engineering [40]. As software systems continue to grow in scale and complexity, and with the increase in LLM-generated commits, the hard problem of identifying the root causes of failures is only becoming increasingly difficult. Finding the error is often harder than fixing: establishing where errors originate often dominates the effort required to correct the problem [22]. Fault Localization (FL), the task of identifying the program elements responsible for a failure, is widely recognized as one of the most time-consuming and expensive stages of debugging and has consequently been the subject of extensive research for more than two decades. Despite decades of research and substantial progress in automated FL, accurately identifying the source of an observed failure remains

M. Navaratnarajah et al.

a major challenge. Recent studies continue to highlight the effort associated with FL and the limitations of existing techniques, motivating ongoing work on more effective debugging support [40,22].

State of the art. Among automated FL techniques, Spectrum-Based Fault Localization (SBFL) has emerged as one of the most widely studied and influential paradigms [1]. SBFL analyzes program spectra—information about which program elements are executed during a particular run, such as statement or branch coverage collected from passing and failing executions—and assigns each element a suspiciousness score based on its statistical association with observed failures [19,4]. Numerous ranking metrics have been proposed, including Tarantula [19], Muse [28], and DStar [39], with empirical studies demonstrating that SBFL substantially reduces the search space developers must inspect during debugging. More recently, Mutation-Based Fault Localization (MBFL) has extended this approach by replacing observation with active intervention, generating mutants and analyzing their impact on test outcomes to infer fault relevance. Techniques such as Metallaxis [32] have shown that mutation information can improve localization accuracy over traditional spectrum-based approaches, while frameworks such as Major [20] enabled efficient large-scale mutation analysis.

Limitations of SBFL and MBFL. Despite their practical effectiveness, both MBFL and SBFL remain fundamentally associational: program elements are ranked according to correlations with failures across executions rather than their causal contribution to the observed failure. But the question being asked is causal: what and where is the cause of the failure? As a result of its associational nature, highly ranked program elements that are not necessarily causes of the failure remain under investigation. In addition to this wasted effort, current methods struggle to distinguish between cases that only causal methods can address: over-determination (multiple faults each sufficient to produce a failure), pre-emption (one fault causing an observed failure before another fault occurs), and error masking (the effects of a fault being hidden or corrected before reaching the output). This raises a fundamental question: to what extent can FL benefit from causal reasoning, rather than statistical association alone?

Contribution. In this paper, we formalize FL as a causal analysis problem. We use the theory of actual causality [18] to construct Structural Causal Models (SCMs) reflecting the underlying structure of the program. In our formulation, the states of individual code elements act as variables, and mutations serve as targeted interventions. By observing the test suite executions of a program under these interventions, we are able to quantify the causal contribution or degree of responsibility [9] of any code element toward a test failure. Crucially, our SCM allows us to navigate masked and overdetermined faults by evaluating interventions, while still admitting efficient computation and more accuracy.

To make this theoretical framework computationally tractable on real-world software, we introduce softRex, a causality-based FL technique. Rather than relying on exhaustive, brute force mutation generation, softRex allows for some sampling of mutants or employs a hierarchical search over the Concrete Syntax Tree (CST) to dynamically iterate over potential minimal sets of code elements to mutate-contingency sets. To ensure practical accuracy, softREX regularizes its base causal responsibility scores by penalizing interventions that break originally passing tests, passing-to-failing (P2F) penalization, and weighing them against the syntactic or semantic distance of the mutation.

We evaluate softREX on the Defects4J benchmark [21], a standard benchmark for reproducible bugs, against 8 state-of-the-art MBFL techniques. Our empirical results demonstrate that shifting from correlation to causal responsibility fundamentally improves FL accuracy. Specifically, softREX improves Mean Reciprocal Rank (MRR) by 16% and successfully locates 31 more bugs in the Top-10 position compared to traditional baselines like BLMu. In summary, this paper makes the following contributions:

  1. Theoretical Framework: We formalize CBFL – an extension of MBFL as an actual causality problem.
  2. Heuristics: We introduce heuristics to compute the approximate degree of responsibility for faults using distance weights and P2F penalization.
  3. Algorithm: We present an algorithm and its implementation in a tool softREX, a scalable, adaptive, hierarchical, iterative search-based algorithm that generates mutants to approximate actual causality.
  4. Empirical Evaluation: We provide a comprehensive evaluation of softREX on real-world Java bugs demonstrating the superiority of our approach over traditional statistical suspiciousness metrics.

Availability. All softREX's code and experimental results are available at [6].

References (40)