Abstract
Automated Program Repair (APR) aims to fix software bugs autonomously, yet traditional "path-insensitive" methods often produce "plausible" patches that fail to generalize—a phenomenon known as overfitting. This paper presents PathFix, a novel APR framework that leverages "expected execution paths" to generate logically sound patches. By integrating path-sensitive symbolic execution with the semantic reasoning capabilities of Large Language Models (LLMs), PathFix effectively navigates complex search spaces in loops and recursion. Our evaluation on the QuixBugs benchmark and real-world open-source projects shows that PathFix significantly outperforms existing tools, achieving high repair rates with zero overfitting.
Introduction
The primary challenge in Automated Program Repair (APR) is the gap between passing test cases and achieving correct program logic. Most current APR tools are path-insensitive; they focus solely on whether an input produces the correct output. This leads to two major issues: a redundant search space of incorrect patch candidates and overfitting, where a patch "cheats" the test suite without fixing the underlying bug.
PathFix proposes a paradigm shift: to fix a program, one must understand the execution trajectory it should have followed. For every buggy input, there exists an "expected path" (EP) that leads to the correct result.
By identifying and satisfying the constraints of this path, APR can produce more robust and accurate fixes.
The PathFix Framework
PathFix operates through a structured four-stage pipeline designed to transition execution from a faulty path to a correct one.
- Fault Path Identification: The process begins by using symbolic execution and a reference program (or a comprehensive test suite) to pinpoint the exact execution paths that result in incorrect outputs.
- Specification Inference (Expected Path Construction): The tool analyzes the program's Control Flow Graph (CFG) to identify potential "Expected Paths" (EPs) that could lead to the desired output.
- Patch Synthesis: Using Component-Based Synthesis (CBS) and the Z3 solver, PathFix generates code expressions that satisfy the logical constraints of the chosen expected path.
- Patch Verification: Finally, the generated patch is validated against both previously failing and successful test cases to ensure global correctness.
Leveraging LLMs for Path Pruning and Synthesis
A key innovation in PathFix is its use of a Large Language Model (LLM), specifically GPT-4o, as a strategic "plug-in." While symbolic execution provides rigorous logic, it often suffers from "state explosion" in complex code. PathFix uses the LLM to:
- Prune Invalid Paths: Quickly discarding logically impossible "expected path" candidates.
- Summarize Constraints: Distilling complex loop invariants into manageable logical summaries.
- Synthesize Complex Patches: Generating intricate code structures (like ternary operators or built-in function calls) that traditional synthesizers often miss.
Evaluation and Results
The effectiveness of PathFix was evaluated using the QuixBugs benchmark (40 classic algorithms) and 10 real-world bugs harvested from widely-used open-source projects, specifically Busybox and GNU Coreutils.
- Superior Accuracy: On the QuixBugs benchmark, PathFix (with LLM) fixed 37 out of 40 programs. In comparison, the previous leading tool (SemGraft) fixed only 18, and a pure LLM approach fixed 31.
- Zero Overfitting: Remarkably, PathFix with LLM achieved 0 overfitting cases on QuixBugs, whereas the pure LLM approach suffered from 7.
- Real-World Efficiency: PathFix successfully repaired all 10 real-world bugs from Busybox/Coreutils in just 27 minutes, whereas SemGraft took 45 minutes and required traversing significantly more paths.
- Handling Complexity: PathFix showed a particular strength in fixing bugs located inside loop bodies and recursive functions—areas where traditional APR tools almost always fail.
Conclusion
PathFix demonstrates that path sensitivity is a powerful antidote to overfitting in APR. By combining the formal rigor of symbolic execution with the semantic intuition of LLMs, the framework provides a scalable and accurate solution for repairing complex software bugs. Future work will focus on exploring the use of LLMs to automatically generate reference programs and improving loop invariant coverage to extend path coverage.
Summary updated