Better Debugging: Combining Static Analysis and LLMs for Explainable Crashing Fault Localization

Jiwei Yan, Jinhao Huang, Chunrong Fang, Jun Yan, Jian ZhangarXiv 2024 · DOI

Introduction

Modern Android development is characterized by deep integration with the Android framework. While this provides powerful functionality, it creates a significant challenge for debugging: when an application crashes, the root cause is often obscured. The "smoking gun"—the specific buggy method in the application code—is frequently missing from the stack trace because the error is triggered deep within framework internals after complex asynchronous calls or callbacks.

Existing Fault Localization (FL) tools struggle with three primary issues: incompleteness due to broken call graphs, heavy dependency on labeled historical datasets, and an "explainability gap." Most tools identify a potential location but fail to explain the underlying logic, leaving developers to decipher complex framework constraints on their own.

System Overview: CrashTracker

To address these challenges, researchers have developed CrashTracker, a hybrid tool that bridges the gap between raw data and developer intuition. CrashTracker utilizes a two-stage pipeline that combines the precision of framework-aware static analysis with the reasoning capabilities of Large Language Models (LLMs).

The high-level workflow of the CrashTracker system, illustrating the path from crash inputs to the final explanation report.

Methodology

1. Framework-Aware Static Analysis

Unlike traditional tools that analyze application code in isolation, CrashTracker performs a comprehensive, one-time static analysis of the Android framework. This process generates Exception-thrown Summaries (ETS). These summaries act as a formal "rulebook," detailing the specific variables, API states, and conditions that trigger framework exceptions (e.g., an IllegalStateException).

When a crash occurs, the tool matches the report to a corresponding ETS. It then performs backward data-flow tracking within the application code to identify "buggy candidates"—methods that likely violated the framework's internal constraints.

Detailed architecture of the ETS construction and candidate collection phases within the static analysis engine.

2. LLM-Powered Explanation and Verification

Once candidates are localized, CrashTracker employs an LLM (such as GPT-4) to generate human-readable explanations. The tool constructs a Candidate Information Summary (CIS), a structured prompt that includes code snippets, identified patterns (such as "transferring a wrong value"), and the framework constraints identified during the ETS phase.

To mitigate the risk of LLM "hallucinations," the system incorporates three distinct static verifiers:

  • Format Verifier: Ensures the output adheres to the required structure.
  • SourceCode Verifier: Confirms that the LLM only references methods and variables present in the actual codebase.
  • StaticAnalysis Verifier: Validates that the explanation aligns with the data-flow logic discovered in the first stage.

Evaluation and Key Results

CrashTracker was evaluated using a large-scale dataset of 580 crash reports across 569 Android apps and 11 SDKs, spanning ten versions of the Android framework (v2.3 to v12.0). The ETS database alone was built from over 76,000 framework-specific exception summaries.

  • Localization Precision: The tool achieved a Mean Reciprocal Rank (MRR) of 0.91, significantly outperforming previous state-of-the-art tools like Anchor. It improved Top-1, Top-5, and Top-10 candidate identification by 7.4% to 12.6%.
  • Developer Impact: In a user study, developers reported a 67.04% higher satisfaction score for CrashTracker’s reports compared to traditional static analysis. The explanations were cited as more readable, reasonable, and actionable for real-world bug fixing.
  • Efficiency: The entire pipeline, from localization to final explanation, averages less than 1.5 minutes per crash, making it suitable for integration into modern CI/CD workflows.

Conclusion

CrashTracker demonstrates that the key to effective Android debugging lies in modeling the framework's "intent." By combining static analysis to provide context and verification with LLMs to provide reasoning, the tool offers a scalable solution to the long-standing problem of explainable fault localization. Future work will focus on expanding support for native code (C/C++) and integrating constraint-solving techniques to further refine candidate pruning.

Summary updated

BibTeX
@misc{yan2024better,
  author = {Jiwei Yan and Jinhao Huang and Chunrong Fang and Jun Yan and Jian Zhang},
  title = {{Better Debugging: Combining Static Analysis and LLMs for Explainable Crashing Fault Localization}},
  year = {2024},
  eprint = {2408.12070},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2408.12070},
}
Figure