TL;DR
Static bug analyzers save software engineers from shipping catastrophic flaws, but on massive projects like the Linux kernel, over 90% of their warnings are false alarms. PathAgent teams up LLM agents with mathematical constraint solvers to trace execution paths step-by-step, filtering out nearly four-fifths of these false alarms without letting real bugs slip through the cracks.
What Problem Does This Paper Address?
If you have ever run a static analysis tool (like GitHub's CodeQL or Meta's Infer) on a massive codebase, you know the pain of alert fatigue. These tools hunt for bugs—like Null-Pointer-Dereferences or Use-After-Free errors—by looking for a path from a source (where a bad state, like a NULL assignment, begins) to a sink (where that state causes a crash).
The catch? Checking if a path can actually execute at runtime—known as path feasibility analysis—is brutally hard in complex code. In projects like the Linux kernel, a single function can span hundreds of lines with 50+ if-branches, and paths weave through deep chains of helper functions, macros, and compiler built-ins. Traditional formal methods (like symbolic execution) choke on "path explosion" when trying to map every branch. Meanwhile, recent attempts to use Large Language Models (LLMs) usually stuff entire functions and surrounding caller/callee contexts into a single massive prompt. Faced with walls of intricate code, LLMs lose the thread and fail to reason accurately.
Methods
Instead of asking an LLM to eyeball a giant hairball of code all at once, PathAgent acts as a neuro-symbolic reasoner, breaking inter-procedural call traces down function-by-function and condition-by-condition.
Within each function along a bug trace, PathAgent runs a two-phase loop:
- Feasible Path Constraint Extraction (The "Neuro" part): Using a standard Control Flow Graph (CFG), PathAgent isolates only the critical conditional branches (
if, loops, earlyreturn/gotojumps) that govern whether execution reaches the sink. Then, an LLM agent steps through these expressions one by one to infer the possible values ("symbolic ranges") of variables and function return values. Crucially, if a condition relies on an external helper function, the agent uses on-demand contextual exploration—adaptively fetching and analyzing nested function bodies (up to 5 layers deep) only when needed, caching results in a memory module so it never analyzes the same scenario twice. - Iterative Constraint Solving (The "Symbolic" part): Rather than trusting the LLM to do final boolean algebra in its head, PathAgent asks the LLM to translate each extracted condition into a Python script for Z3 (a battle-tested SMT mathematical solver). Constraints are merged and checked iteratively: the moment Z3 outputs
UNSAT(meaning the conditions contradict each other and the path is impossible), PathAgent halts early and flags the warning as a false positive. If a generated script crashes, Z3's error message is fed back to the LLM for up to 3 self-repair attempts.
Datasets
Existing benchmarks either rely on tiny synthetic programs (like the Juliet test suite) or only list confirmed bugs without real-world false alarms. To test their tool realistically, the authors spent ~150 person-hours manually labeling SAFP-Bench-C, a new dataset of 443 bug warnings (396 false positives and 47 real bugs). These warnings were generated by three major static analyzers (CodeQL, Infer, and CppCheck) across three massive C/C++ codebases: the Linux kernel (>18M lines of code), OpenSSL (>300K lines), and Libav (>600K lines), covering five critical bug types (Null-Pointer-Dereference, Use-After-Free, Buffer Overflow, Divide-by-Zero, and Use-Before-Initialization).
Key Insights and Ideas
- Synthetic benchmarks flatter static analyzers: CodeQL boasts 93.8% precision on the synthetic Juliet benchmark, yet its precision plummets to 12% on SAFP-Bench-C. Real-world system complexity is a completely different beast.
- Scale-invariant reasoning via decomposition: As function length grows past 200 lines or branch counts exceed 40, baseline LLM tools fall apart. Because PathAgent isolates critical branches and checks them one at a time, its accuracy holds steady (~0.91–0.92) regardless of function size.
- LLMs are surprisingly good Z3 translators—if paced: Manual inspection showed that 94% of PathAgent's iteratively built SMT scripts were semantically identical to human-written ones. Conversely, an ablation variant that tried to convert all constraints into a Z3 script in one go (
BatchSol) suffered massive solver failures, dropping false-positive recall from 0.71 to 0.30.
Key Results
- Crushing false alarms while keeping real bugs: Using GPT-4o-mini, PathAgent eliminated 79% of false positives (an improvement of 23% to 44% over state-of-the-art LLM baselines like LLM4SA, RepoAudit, IRIS, and LLMDFA), while catching 44 out of 47 real bugs (0.94 recall).
- Model-agnostic gains: PathAgent maintained strong performance across closed- and open-source backbones alike, including GPT-4o-mini, Claude 3.5 Sonnet, DeepSeek-V2, and Qwen2.5-Coder-32B.
- Practical offline speed: PathAgent takes an average of 28.9 seconds (and 6.3 LLM calls) per warning trace—about 20 seconds slower than simpler baselines, which is negligible for an offline post-processing step that saves hours of human debugging.
Limitations and Future Work
PathAgent isn't immune to LLM hiccups. In a manual review of 50 misclassified cases, 74% stemmed from LLM reasoning errors—hallucinations or over-approximations when simulating complex code behavior. Another 22% were caused by corner-case failures in the static parser used to extract conditional expressions (such as duplicate statements appearing in the same file), and 4% came from broken SMT scripts. Promising future directions are not explicitly discussed in the paper, though tightening the static parser and improving code-simulation fidelity stand out from their error analysis.
Summary updated