Towards Fixing Panic Bugs for Real-world Rust Programs

Overview of the proposed infrastructure.

Abstract

The Rust programming language has garnered significant attention due to its robust safety features and memory management capabilities. Despite its guaranteed memory safety, Rust programs still suffer from runtime errors that are unmanageable, i.e., panic errors. Notably, over half of the bugs in rustc, Rust’s own compiler, are attributable to crash errors stemming from panic errors. However, understanding root causes and resolving these panics often requires substantial effort due to the limited information provided, and the stack backtrace could be intricate, often omitting the actual fault locations. Although numerous automated program repair techniques exist, we observe that the prevailing fix patterns do not readily apply to Rust programs due to natural differences in language mechanisms. To tackle the above challenges, this paper introduces a systematic study aimed at fixing Rust panic bugs. We commence by assembling a dataset, namely Panic4R, of real panic bugs and their corresponding fixes from the top 100 downloaded open-source crates. Utilizing this dataset, we then identify common fix patterns in panic bug resolution, which could guide the understanding and pattern-based rectification of such issues. Finally, we design and implement the first automated fixing tool PanicKiller for Rust panic bugs, which effectively generates correct patches on the real-world large-scale dataset, and has already assisted in the resolution of four panic bugs in open-source crates. All resolved issues have been validated by the developers and merged into the respective codebases.

Yunbo Ni
Yunbo Ni
Junior of Software Engineering at Nanjing University, China

My research interests include programming language and compilers, especially the Rust Compiler.