Rust-twins: Automatic Rust Compiler Testing through Program Mutation and Dual Macros Generation
Rust is a relatively new programming language known for its memory safety and numerous advanced features. It has been widely used in system software in recent years. Thus, ensuring the reliability and robustness of the only implementation of the Rust compiler, Rustc, is critical. However, compiler testing, as one of the most effective techniques to detect bugs, faces difficulties in generating valid Rust programs with sufficient diversity due to its stringent memory safety mechanisms. Furthermore, existing research primarily focuses on testing Rustc to trigger crash errors, neglecting incorrect compilation results - miscompilation. Detecting miscompilation remains a challenge in the absence of multiple implementations of the Rust compiler to serve as a test oracle.
This paper tackles these challenges by introducing Rust-twins, a novel and effective approach to performing automated differential testing for Rustc to detect both crashes and miscompilations. We devise four Rust-specific mutators and adapt fourteen general mutators for Rust, each intends to produce a syntax and semantic valid Rust program to trigger Rustc crashes. Additionally, we develop a macroize approach to rewrite a regular Rust program into dual macros with equivalent behaviors but in different implementations. Furthermore, we design an assessment component to check the equivalence by comparing the expansion results with a simple macro input. Finally, Rust-twins attempts to expand the two macros with numerous complex inputs to detect differences. Due to the macro expansion mechanism, the root causes of differences can arise not only from the macro expansion part but also from any other mis-implemented compiler code.
We have evaluated Rust-twins on the latest version of Rustc. Our experimental results indicate that Rust-twins achieves twice the total line coverage and identifies more crashes and differences than the best baseline technique, RustSmith, after 24 hours of testing. In total, Rust-twins triggered 10 Rustc crashes, and 229 of the generated macros exposed Rustc differences. We analyzed and reported 12 previously unknown bugs, of which 8 have already been confirmed and fixed.
Tue 29 OctDisplayed time zone: Pacific Time (US & Canada) change
10:30 - 12:00 | |||
10:30 15mTalk | Shoot Yourself in the Foot — Efficient Code Causes Inefficiency in Compiler Optimizations Research Papers Fengjuan Gao Nanjing University of Science and Technology, Hongyu Chen Nanjing University, Yuewei Zhou Rice University, Ke Wang Visa Research | ||
10:45 15mTalk | Rust-twins: Automatic Rust Compiler Testing through Program Mutation and Dual Macros Generation Research Papers Wenzhang Yang University of Science and Technology of China, Cuifeng Gao University of Science and Technology of China, Xiaoyuan Liu University of Science and Technology of China, Yuekang Li UNSW, Yinxing Xue University of Science and Technology of China | ||
11:00 15mTalk | Compiler Bug Isolation via Enhanced Test Program Mutation Research Papers Yujie Liu Peking University, Mingxuan Zhu Peking University, Jinhao Dong Peking University, Junzhe Yu Peking University, Dan Hao Peking University | ||
11:15 15mTalk | Incremental Context-free Grammar Inference in Black Box Settings Research Papers Feifei Li Tsinghua Shenzhen International Graduate School, Xiao Chen University of Newcastle, Xi Xiao Tsinghua Shenzhen International Graduate School, Tsinghua University, Xiaoyu Sun Australian National University, Australia, Chuan Chen Key Laboratory of Computing Power Network and Information Security, Ministry of Education, Shandong Computer Science Center (National Supercomputer Center in Jinan), Qilu University of Technology (Shandong Academy of Sciences), Jinan, China, Shaohua Wang Central University of Finance and Economics, Jitao Han Central University of Finance and Economics | ||
11:30 15mTalk | Typed and Confused: Studying the Unexpected Dangers of Gradual Typing Research Papers Dominic Troppmann CISPA Helmholtz Center for Information Security, Aurore Fass CISPA Helmholtz Center for Information Security, Cristian-Alexandru Staicu CISPA Helmholtz Center for Information Security | ||
11:45 15mTalk | Refinement Types for Visualization Research Papers Jingtao Xia University of California, Santa Barbara, Junrui Liu University of California, Santa Barbara, Nicholas Brown University of California, Santa Barbara, Yanju Chen University of California at Santa Barbara, Yu Feng University of California at Santa Barbara |