Cerberus: Multi-Agent Reasoning and Coverage-Guided Exploration for Static Detection of Runtime Errors
Hridya Dhulipala, Xiaokai Rong, Tien N. Nguyen
TL;DR
Cerberus addresses the challenge of detecting runtime errors in non-executable or incomplete code by introducing an execution-free, coverage-guided testing framework that uses a pair of LLM agents for test-case generation and predictive execution. It employs a two-phase, condition-based prompting strategy to first maximize coverage and then focus on error detection, guided by a predictive executor that estimates coverage and potential exceptions. Across Java and Python, Cerberus demonstrates superior error discovery efficiency and accuracy compared with traditional fuzzers and prior LLM-based methods, including strong performance on incomplete code and real StackOverflow snippets. These results suggest significant potential for pre-execution error detection in code snippets sourced from online forums and educational platforms, with implications for developer tooling and code reliability.
Abstract
In several software development scenarios, it is desirable to detect runtime errors and exceptions in code snippets without actual execution. A typical example is to detect runtime exceptions in online code snippets before integrating them into a codebase. In this paper, we propose Cerberus, a novel predictive, execution-free coverage-guided testing framework. Cerberus uses LLMs to generate the inputs that trigger runtime errors and to perform code coverage prediction and error detection without code execution. With a two-phase feedback loop, Cerberus first aims to both increasing code coverage and detecting runtime errors, then shifts to focus only detecting runtime errors when the coverage reaches 100% or its maximum, enabling it to perform better than prompting the LLMs for both purposes. Our empirical evaluation demonstrates that Cerberus performs better than conventional and learning-based testing frameworks for (in)complete code snippets by generating high-coverage test cases more efficiently, leading to the discovery of more runtime errors.
