Fault Localization from the Semantic Code Search Perspective
Top Cited Papers
Open Access
- 24 April 2026
- journal article
- Published by Association for Computing Machinery (ACM) in ACM Transactions on Software Engineering and Methodology
- Vol. 35 (5) , 1-32
Abstract
The software development process is characterized by an iterative cycle of continuous functionality implementation and debugging, essential for the enhancement of software quality and adaptability to changing requirements. This process incorporates two isolatedly studied tasks: Code Search (CS), which retrieves reference code from a code corpus to aid in code implementation, and Fault Localization (FL), which identifies code entities responsible for bugs within the software project to boost software debugging. The basic observation of this study is that these two tasks exhibit similarities since they both address search problems. Notably, CS techniques have demonstrated greater effectiveness than FL ones, possibly because of the precise semantic details of the required code offered by natural language queries, which are not readily accessible to FL methods. Drawing inspiration from this, we hypothesize that a fault localizer could achieve greater proficiency if semantic information about the buggy methods were made available. Based on this idea, we propose \(\texttt{CosFL}\) , an FL approach that decomposes the FL task into two steps: query generation , which describes the functionality of the problematic code in natural language, and fault retrieval , which uses CS to find program elements semantically related to the query, allowing for finishing the FL task from a CS perspective. Specifically, to depict the buggy functionalities and generate high-quality queries, \(\texttt{CosFL}\) extensively harnesses the code analysis, semantic comprehension, text generation, and decision-making capabilities of LLMs. Moreover, to enhance the accuracy of CS, \(\texttt{CosFL}\) captures varying levels of context information and employs a multi-granularity CS strategy, which facilitates a more precise identification of buggy methods from a holistic view. The evaluation on 835 real bugs from 23 Java projects shows that \(\texttt{CosFL}\) successfully localizes 324 bugs within Top-1, which significantly outperforms the state-of-the-art approaches by 26.6%–57.3%. The ablation study and sensitivity analysis further validate the importance of different components and the robustness of \(\texttt{CosFL}\) across different backend models.
Keywords
All Related Versions
Funding Information
- National Natural Science Foundation of China (62402506, No. 62474196)
- Research Foundation from NUDT (ZK24-05)
This publication has 44 references indexed in Scilit:
- CoCoSoDa: Effective Contrastive Learning for Code Search2023
- Software Fault Localization: an Overview of Research, Techniques, and Tools2023
- Beyond word embeddings: A surveyInformation Fusion, 2022
- From Louvain to Leiden: guaranteeing well-connected communitiesScientific Reports, 2019
- Community detection in social networksWIREs Data Mining and Knowledge Discovery, 2016
- Improving bug localization using structured information retrieval2013
- Metallaxis‐FL: mutation‐based fault localizationSoftware Testing, Verification and Reliability, 2013
- Where should the bugs be fixed? More accurate information retrieval-based bug localization based on bug reports2012
- The original Borda count and partial votingSocial Choice and Welfare, 2011
- Comparison and evaluation of code clone detection techniques and tools: A qualitative approachScience of Computer Programming, 2009