NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Entropy Guided Spectrum Based Bug Localization Using Statistical Language Model

Saikat Chakraborty, Yujian Li, Matt Irvine, Ripon Saha, Baishakhi RayarXiv 2018

Introduction

Locating the exact line of code responsible for a software bug is a critical but labor-intensive task in software maintenance. Traditional Spectrum-Based Bug Localization (SBBL) relies on dynamic test coverage data, which often falters when test suites are inadequate or have low coverage. This paper introduces EnSpec, a hybrid approach that enhances SBBL by incorporating the "naturalness" of code, measured through statistical language models. By identifying code that appears statistically "surprising" or "unnatural," EnSpec provides a robust orthogonal signal for pinpointing defects at a fine-grained level.

The EnSpec Methodology

EnSpec operates through a four-stage pipeline that integrates static code analysis with dynamic execution data to produce a ranked list of suspicious lines.

The four-step workflow of EnSpec, integrating entropy generation and SBBL feature extraction.
  1. Entropy Generation: Using a statistical language model (specifically a $gram model), EnSpec calculates the "entropy" of every line. High entropy indicates that a line is statistically rare given its context, suggesting it may be "unnatural" and thus more likely to be buggy. These scores are normalized by the line's AST syntax type.
  2. Feature Extraction: The system extracts 25 distinct SBBL suspiciousness scores (e.g., Ochiai, Tarantula) based on the program's test suite execution.
  3. Model Training: A Random Forest classifier is trained on these features. To address the scarcity of buggy lines, the model is trained using evolutionary bug data mined from version control histories.
  4. Ranking: Finally, EnSpec produces a ranked list of suspicious lines for developer inspection based on a hybrid suspiciousness score.

Evaluation and Insights

The researchers evaluated EnSpec using the Defects4J (Java) and ManyBugs (C) benchmarks, covering over 500 reproducible bugs. A central finding is that buggy code consistently exhibits higher entropy than healthy code, containing unusual token sequences that language models find improbable. In the Random Forest models, "Average Entropy" emerged as the most significant feature for prediction, even outperforming classic metrics like Ochiai. This suggests that entropy serves as an effective "tie-breaker" when multiple lines appear equally suspicious based on test results alone.

Experimental Results

EnSpec demonstrates significant improvements over standard SBBL methods across both Java and C projects, proving that the "naturalness" of code is a universal property across programming languages.

Cost-effectiveness curve comparing the performance of EnSpec (Real) against the baseline and optimal theoretical performance.

On average, EnSpec achieved a 6.6% gain in the Area Under the Cost-Effectiveness Curve (AUCEC). Its advantages are most pronounced in "low-budget" scenarios: when inspecting only the top 20% of suspicious lines, EnSpec successfully located 98.63% of bugs, compared to 80.08% for SBBL alone—a relative improvement of over 33%.

Conclusion

By leveraging the statistical properties of programming languages, EnSpec overcomes the limitations of test-suite-dependent bug localization. While currently focused on modification bugs, future work aims to address "bugs of omission" and utilize more advanced semantic models to further refine the entropy signal for automated program repair tools.

Summary updated

BibTeX
@misc{chakraborty2018entropy,
  author = {Saikat Chakraborty and Yujian Li and Matt Irvine and Ripon Saha and Baishakhi Ray},
  title = {{Entropy Guided Spectrum Based Bug Localization Using Statistical Language Model}},
  year = {2018},
  eprint = {1802.06947},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1802.06947},
}
Figure