Abstract
Software reliability traditionally hinges on developers anticipating every possible failure mode through static error handling. However, unanticipated runtime errors remain a significant cause of system crashes. This paper presents HEALER, the first framework to utilize Large Language Models (LLMs) as adaptive, real-time error handlers. HEALER intercepts unhandled exceptions, collects execution context, and prompts an LLM to generate recovery code that rectifies the program's state mid-execution. Our evaluation demonstrates that HEALER can recover from crashes with a success rate of up to 72.8% using GPT-4, providing a dynamic "last resort" defense mechanism for modern software.
Introduction
The "Heartbleed" bug and similar critical vulnerabilities underscore a fundamental limitation in software engineering: developers cannot write try-catch blocks for errors they do not anticipate. While existing self-healing systems attempt to mitigate crashes using rollbacks or hard-coded heuristics, they lack the flexibility to handle novel, complex failures. HEALER addresses this gap by treating runtime recovery as a dynamic code-completion task, effectively placing an "on-call" developer inside the execution environment.
The HEALER Framework
HEALER operates as a sophisticated feedback loop integrated into the program runtime. When an unhandled exception is detected, the framework performs four key steps:
- Context Collection: It captures the source code, the error message, the failure location, and the current program state (variable values).
- Prompt Generation: This context is formatted into a structured prompt for an LLM, defining the goal: survive the error while maintaining original functionality.
- Isolated Execution: The LLM-generated "handling code" is executed within a sandboxed environment to ensure safety and verify that it resolves the exception.
- State Rectification: If successful, the modified program state is merged back into the main process, allowing execution to resume seamlessly from the next line.
Experimental Evaluation
The researchers evaluated HEALER across 1,185 test cases from four benchmarks: CodeNet (human-written), HumanEval+ and MBPP+ (LLM-generated), and DebugBench (intentionally bugged). To enhance the performance of smaller, open-source models, the authors also introduced a new instruction-tuning dataset comprising 586 specialized recovery pairs.
Analysis and Results
A key finding of this research is the distinction between healing and patching. Unlike Automated Program Repair (APR), which seeks to permanently fix source code, HEALER focuses on rectifying the runtime state to ensure the current task completes successfully.
Performance Metrics
- Recovery Success: Using GPT-4, HEALER allowed 72.8% of programs to proceed to completion, with 39.6% producing the correct output.
- Impact of Fine-Tuning: Fine-tuning significantly leveled the playing field. The open-source CodeQwen-7B model saw a 65.8% improvement in correctness after instruction tuning, nearly matching the efficacy of much larger proprietary models.
- Efficiency: The system introduces negligible overhead (<1ms) during normal operation. During an error event, recovery takes between 1.6 and 3.1 seconds—a trade-off the authors deem acceptable compared to a total system failure.
Discussion and Future Directions
While HEALER represents a major step toward autonomous self-healing systems, several challenges remain. Executing LLM-generated code at runtime necessitates rigorous security sandboxing. Furthermore, while the current implementation targets Python due to its dynamic nature, extending HEALER to compiled languages like C++ or Java will require deeper integration into language runtimes. Future work will focus on reducing API costs through quantized on-device models and improving the "trustworthiness" of generated recovery logic.
Conclusion
HEALER demonstrates that LLMs can serve as powerful, adaptive reasoning engines for software resilience. By shifting the focus from static prevention to dynamic recovery, this framework provides a promising pathway toward software systems that can autonomously survive and learn from unanticipated errors.
This paper summary is based on research by Zhensu Sun, Haotian Zhu, Bowen Xu, Xiaoning Du, Li Li, and David Lo.
Summary updated