Abstract
Token-Inconsistency Bugs (TIBs) are subtle semantic errors where a programmer uses an incorrect variable or function call in a syntactically valid manner. These "silent killers" often evade traditional static analysis and fuzzing. We present LineBreaker, a cascaded bug-detection system that utilizes small, efficient, code-specific LLMs to filter code before performing deep analysis with GPT-4. This approach discovered 123 new real-world flaws in popular GitHub repositories with high precision and low operational cost, leading to 41 confirmed or merged fixes.
1. Introduction
Software reliability is frequently compromised by bugs that do not trigger immediate crashes or syntax errors. Token-Inconsistency Bugs (TIBs) occur when code logic is flawed despite being syntactically correct—for instance, passing a query string where params is expected. While Large Language Models (LLMs) possess the semantic intuition to identify these errors, deploying them at scale is prohibitively expensive and prone to false positives due to "distraction" from irrelevant context.
2. The LineBreaker Architecture
To address the scalability and precision challenges of using LLMs for bug detection, we developed LineBreaker. The system employs a cascaded pipeline that filters out the vast majority of correct code using lightweight models before engaging a state-of-the-art (SOTA) LLM for final verification.
The pipeline consists of:
- Lexical Analysis: Identifying candidate tokens (variables, functions, operators).
- Lightweight Filtering: Using local models like CodeLlama to perform infilling tasks.
- Consistency Check: A custom algorithm that compares model predictions against the original code.
- SOTA Analysis: GPT-4 analyzes only the "suspicious" tokens identified by the filters, using Chain-of-Thought prompting and cross-examination.
3. Detecting Token Inconsistencies
The core of LineBreaker's efficiency lies in its ability to detect inconsistencies using small models. By masking a token and asking a code-specific model to predict the most likely replacement, the system can identify discrepancies between the programmer's intent and the actual implementation.
If the model's top prediction differs significantly from the original token, the position is marked as suspicious. This "density amplification" ensures that the expensive SOTA model focuses only on high-probability bug candidates, reducing both cost and false positives.
4. Evaluation and Results
LineBreaker was evaluated on 154 high-star Python and C repositories. It achieved a precision of 23.5% to 36.3%, significantly outperforming previous state-of-the-art methods which typically hover around 12%.
Key findings include:
- Bug Discovery: 123 new, previously unknown bugs were identified, including 45% that were security-critical (e.g., buffer overflows).
- Developer Adoption: Out of 69 submitted fixes, 41 have already been merged or confirmed by maintainers.
- Cost-Efficiency: The large-scale evaluation cost only $92 in API fees, a fraction of the cost of a direct GPT-4 approach.
5. Conclusion
LineBreaker demonstrates that a cascaded LLM architecture can effectively find subtle semantic bugs that traditional tools miss. By focusing high-capacity models on pre-filtered suspicious code, the system achieves a balance of semantic depth, precision, and scalability. Future work will explore multi-token infilling and enhanced cross-file context to capture even more complex logic errors.
Summary updated