Abstract
Detecting tricky bugs in plausible programs—those that pass existing test suites yet still contain logical flaws—remains a significant challenge in software testing. We propose TrickCatcher, an LLM-powered approach to generating test cases for uncovering these bugs. TrickCatcher operates in three stages: generating program variants based on the program under test (PUT) and its specification, constructing an input generator script from the specification, and executing these inputs on both the PUT and its variants to detect inconsistencies. Evaluated on the TrickyBugs and EvalPlus datasets, TrickCatcher achieves recall, precision, and F1 scores that are 1.80×, 2.65×, and 1.66× those of state-of-the-art baselines, respectively.
1. Introduction
In modern software development, a program is deemed "plausible" if it passes its current test suite. However, plausibility does not equate to correctness. Many programs, whether human-written or AI-generated, contain subtle logical flaws known as "tricky bugs" that only manifest under specific, untested edge cases. Traditional automated testing tools often struggle with these bugs because they cannot easily parse natural language specifications or generate complex, valid inputs that satisfy strict constraints.
2. Methodology: The TrickCatcher Framework
TrickCatcher addresses these limitations through a three-stage pipeline designed to identify discrepancies between a program's intended behavior and its actual implementation.
2.1 PUT-Guided Program Variant Generation
Instead of generating programs from scratch, TrickCatcher provides an LLM with both the specification and the Program Under Test (PUT). The LLM identifies potential flaws and generates "repaired" variants. These variants are filtered against the existing test suite; only those that pass all current tests are retained as high-quality plausible alternatives.
2.2 Generator-Based Input Generation
Directly prompting an LLM to generate test data often results in invalid formats or constraint violations. TrickCatcher instead prompts the LLM to write a Python script (a generator) based on the input constraints. This offloads the logical reasoning of input construction to the execution of code, ensuring that the generated test cases are valid and diverse.
2.3 Diversity-Driven Differential Testing
Standard differential testing often relies on majority voting, which can fail if multiple variants inherit the same bug from the PUT. TrickCatcher prioritizes diversity: if any plausible variant produces an output different from the PUT, that variant's output is treated as a potential oracle to flag a bug. This approach is based on the insight that even a buggy variant might handle a specific edge case correctly that the original PUT misses.
3. Experimental Evaluation
TrickCatcher was evaluated on two primary datasets:
- TrickyBugs: 366 human-written programs (C++ and Python) from online judge platforms that were initially marked correct but contained corner-case bugs.
- EvalPlus: 151 AI-generated programs that pass base test cases but fail more rigorous extra test cases.
4. Results and Key Insights
TrickCatcher demonstrated a significant performance leap over existing methods like DirectChat and Differential Prompting Plus (DPP). It achieved F1 scores of 41.31% on TrickyBugs C++, 42.35% on TrickyBugs Python, and 51.34% on EvalPlus.
A critical factor in this success is the reduction of false positives. As shown in the evaluation, TrickCatcher produced up to 16x fewer false alarms than other LLM-based methods. This is largely attributed to the generator-based input stage, which ensures that test inputs are valid and adhere to the problem specification, whereas baseline methods frequently generated invalid inputs that triggered false bug reports.
5. Conclusion
TrickCatcher represents a significant advancement in automated bug detection for plausible programs. By leveraging LLMs to generate both program variants and input-generating scripts, it effectively bridges the gap between natural language specifications and rigorous code testing. Future work will explore scaling these techniques to more complex non-functional bugs and optimizing the computational cost of variant generation.
Summary updated