TL;DR
Debugging often involves sifting through massive execution traces to find a single faulty line of code. This paper introduces BugAssist, a tool that reduces error localization to a Maximum Satisfiability (MAX-SAT) problem, pinpointing the minimal set of program statements that, if changed, would make a failing test pass.
What Problem Does This Paper Address?
When a program fails a test, developers are often left with a long execution trace but little clue as to why it failed. Traditional debugging is manual and time-consuming. While automated fault localization tools exist, many rely on comparing multiple successful and failing runs, which might not always be available or easy to generate.
The authors tackle the challenge of precisely identifying the root cause of a bug using only a single failing execution and a specification (like an assertion or a post-condition). Their goal is to move beyond just showing where a program crashed to explaining which specific lines of code are logically inconsistent with the desired outcome.
Methods
The core idea is to treat the program trace as a logic puzzle. The authors' algorithm, implemented in the tool BugAssist, follows three main steps:
- Symbolic Trace Construction: Using symbolic execution, the program path taken by a failing test is converted into a Boolean "trace formula." This formula is satisfiable if and only if that specific execution path is feasible.
- Formula Extension: This formula is conjoined with "hard" constraints: the specific input values from the failing test and the requirement that the final state must satisfy the program's correctness specification. Because the test originally failed, this extended formula is guaranteed to be unsatisfiable.
- MAX-SAT Solving: The tool feeds this unsatisfiable formula to a partial MAX-SAT solver. By marking the input and the specification as "hard" (unchangeable) and the program statements as "soft" (changeable), the solver finds a maximal set of program statements that can be satisfied together. The complement of this set—the statements that had to be "ignored" to reach satisfiability—represents the potential cause of the error.
The tool also includes clever extensions, such as using weights to prioritize earlier loop iterations and a heuristic to automatically suggest "off-by-one" fixes for common errors (see Figure 3 for the types of errors handled).
Datasets
The authors evaluated BugAssist using the Siemens test suite, a standard benchmark for software testing. Specifically, they used:
- TCAS: An aircraft collision avoidance system (173 lines of code) with 41 faulty versions and 1600 test cases.
- Larger Benchmarks: Programs like
totinfo,print_tokens, andschedule, which include more complex features like recursion, dynamic memory, and procedure calls.
Key Insights and Ideas
- The "Hard" vs. "Soft" Constraint Trick: By making the input and the assertion "hard" constraints, the MAX-SAT solver is forced to look for fixes within the program logic itself, rather than suggesting the user just "change the input" or "ignore the assertion."
- Clause Grouping: Since a single program statement can generate many Boolean clauses, BugAssist groups them using "selector variables." This ensures the solver treats a whole line of code as a single unit to be kept or discarded, keeping the problem size manageable.
- Beyond Localization to Repair: Because the tool identifies exactly what's "broken" in the logic, it can sometimes suggest a fix. For example, if a line with a constant is identified as a bug, BugAssist can try incrementing or decrementing that constant to see if it resolves the failure.
Key Results
- High Precision: On the TCAS benchmark, BugAssist pinpointed the exact human-verified bug location in 95% of the total runs (1367 out of 1440 failing test cases).
- Drastic Search Space Reduction: On average, the tool reduced the number of lines a programmer needs to check to just 8% of the total code.
- Scalability: While symbolic formulas can grow huge, the authors showed that combining BugAssist with standard techniques like program slicing and delta debugging allows it to handle larger programs. For instance, in the
totinfobenchmark, slicing reduced the number of assignments to analyze from 734 down to just 21 (see Figure 4).
Limitations and Future Work
- Code Omission Faults: The current approach cannot detect bugs where code is missing, as there are no clauses in the formula to represent non-existent statements.
- State Space Explosion: For very complex programs with many calls or loops, the Boolean formulas can become prohibitively large. The authors suggest that integrating BugAssist directly into an IDE could allow it to focus on smaller, developer-selected functions.
- Future Directions: The authors plan to explore mining software repositories for common bug patterns to improve the tool's ability to automatically suggest fixes for a wider variety of errors.
Summary updated