What Matters Besides Borrow Checking? Toward Understanding Bugs in the Rust Compiler

The overview of our bug collection and analysis process.

Abstract

Rust, a statically typed programming language, is gaining popularity for its well-known memory safety guarantees and high performance, making it notably distinct from C/C++ and JVM family of languages. The rustc compiler, Rust’s front-end compiler, implements unique Rust type system mechanisms, including trait solving, borrow checking, and specific optimizations to ensure and deliver such benefits. Therefore, the reliability and robustness of rustc significantly impact the benefits Rust programmers hope to enjoy. It is thus important to solidify and improve the Rust ecosystem starting from its compiler, rustc, by testing, analyzing, and optimizing it. To this end, a comprehensive and systematic study of bugs in rustc is needed, which this work undertakes. In particular, we examine all issues and fixes in rustc since 2021 and conduct a manual review of 1,428 valid issues that form the basis of our study. We analyze the diverse manifestations of bug symptoms, root causes, syntactic features that trigger bugs, and the affected complication stages. We further investigate the capabilities and limitations of the state-of-the-art testing tools for rustc to understand the challenges and opportunities for future research. Our key findings include: (1) versus borrow checking and optimization, bugs are more likely to occur in modules associated with High Intermediate Representation (HIR), such as type checking and trait solving; and (2) tests that trigger rustc bugs often do not require complex logic or borrowing relationships, while the combination of traits, generics, and associated functions contributes to the highest proportion of rustc bugs being triggered. The results of our study highlight the need and significant challenges in developing effective techniques for generating valid test programs leveraging Rust-specific features and optimizations

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

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