TL;DR
This paper introduces ManySStuBs4J, a large dataset of single-statement bug fixes in Java, annotated with 16 common bug patterns. The authors found that a significant portion (around 33%) of these simple bugs can be categorized by these patterns, suggesting that targeted repair techniques could be highly effective. This dataset aims to bridge the gap in understanding the frequency of such bugs, crucial for developing more precise and recall-efficient automated program repair tools.
What Problem Does This Paper Address?
Automated program repair (APR) tools aim to fix bugs automatically, but a major challenge is balancing precision (not introducing new bugs) with recall (finding and fixing a good percentage of actual bugs). Many APR approaches focus on "simple" bugs, like those fixable with a single statement or fitting specific patterns, because they are easier to handle. However, there's a significant lack of data on how often these simple bugs actually occur in real-world software. Without this information, it's hard to evaluate how effective template-based or single-statement repair techniques truly are. This paper addresses this gap by creating a large, annotated dataset to quantify the prevalence of single-statement bugs and their common patterns.
Methods
The authors developed a methodology to mine bug-fixing commits from popular open-source Java projects.
- Project Selection: They selected projects based on popularity (using GitHub stars and forks) and buildability (using Maven). Two dataset versions were created: a smaller one from 100 projects and a larger one from 1,000 projects.
- Bug-Fixing Commit Identification: A heuristic based on commit messages (looking for keywords like "bug," "fix," "error") was used to identify potential bug-fixing commits.
- Single-Statement Change Filtering: Commits were filtered to include only those that involved single-statement modifications. This involved analyzing the Abstract Syntax Tree (AST) differences to ensure only one statement was changed at a time, even if it spanned multiple lines due to formatting. Refactoring changes were also filtered out.
- SStuB Pattern Matching: For each identified single-statement bug fix, the ASTs of the code before and after the fix were compared. They then checked if the change matched any of 16 predefined "Simple Stupid Bug" (SStuB) patterns, inspired by common bug types targeted by program repair research.
Datasets
The paper introduces the ManySStuBs4J dataset, which consists of:
- A smaller version with 25,539 single-statement bug-fix changes from 100 popular Java Maven projects.
- A larger version with 153,652 single-statement bug-fix changes from 1,000 popular Java Maven projects.
Both versions are annotated to indicate whether a bug fix matches any of the 16 SStuB patterns. The dataset is publicly available on Zenodo, and the mining tools are on GitHub. This dataset is related to existing bug datasets like Defects4J and Bugs.jar but focuses specifically on single-statement bugs and their categorization into patterns.
Key Insights and Ideas
- Simple Bugs are Common and Categorizable: A significant portion (around 33%) of single-statement bug fixes can be classified into a relatively small set of 16 common bug patterns. This suggests that targeted repair strategies focusing on these patterns could be highly effective.
- Frequency of SStuBs: The paper provides an estimate of how often these simple bugs occur, suggesting they appear roughly once every 1,600 to 2,500 lines of code. This quantifies the potential impact and relevance of studying and repairing these bugs.
- Limitations of Static Analysis: The study found that popular static analysis tools like SpotBugs could only detect a small fraction (around 12%) of these SStuBs, highlighting the need for specialized tools or techniques for identifying and fixing such bugs.
Key Results
- The ManySStuBs4J dataset contains 10,231 (smaller version) and 63,923 (larger version) SStuB instances.
- Approximately 33.04% (smaller version) and 33.47% (larger version) of all mined single-statement bug fixes matched at least one SStuB template.
- The most frequent SStuB patterns identified were "Change Identifier Used," "Wrong Function Name," and "Change Numeric Literal."
- The estimated frequency of SStuBs is about 1 per 1,600 lines of code in the larger dataset and 1 per 2,500 lines of code in the smaller dataset.
Limitations and Future Work
- Tangled Changes: The authors acknowledge that their SZZ-like methodology might occasionally extract unrelated statement pairs as a single change, though they took steps to filter out refactorings.
- Scope: The dataset is limited to Java and single-statement bugs. Evaluating the effectiveness of repair systems for larger bugs is not possible with this dataset.
- Future Work: The authors suggest replicating this methodology for other programming languages, exploring different sets of SStuB patterns, and using the dataset to evaluate machine learning models for bug localization and repair. They also note that the dataset could be used to study empirical software engineering questions, such as the relationship between code coverage and failures.
Summary updated