arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2605.00413cs.SE
收藏

ClozeMaster:利用LLMs填充掩码真实程序以模糊Rust编译器

ClozeMaster: Fuzzing Rust Compiler by Harnessing LLMs for Infilling Masked Real Programs

State Key Laboratory for Novel Software Technology, Nanjing University(南京大学 软件新技术国家重点实验室)

Hongyan Gao, Yibiao Yang, Maolin Sun, Jiangchang Wu, Yuming Zhou, Baowen Xu

AI总结:

本文提出ClozeMaster,通过利用LLMs填充掩码的真实程序,生成有效测试用例,发现Rust编译器27个已确认的bug,优于现有模糊测试工具。

摘要:

确保Rust编译器的可靠性至关重要,鉴于Rust在关键系统开发中的日益普及,因其强调内存和线程安全性。然而,生成有效的Rust编译器测试程序存在重大挑战,由于Rust的复杂语法和严格要求。随着大型语言模型(LLMs)的流行,软件测试领域已探索利用LLMs生成测试用例。然而,直接使用LLMs生成Rust程序通常会产生大量无效测试用例。现有研究指出,触发历史编译器bug的测试用例可协助软件测试。我们的Rust编译器bug研究支持这一观察。受现有工作和实证研究的启发,我们引入了一种基于括号的掩码和填充策略,称为clozeMask。clozeMask策略涉及从历史问题报告中提取测试代码,识别并掩码具有特定结构的代码片段,并使用LLM填充掩码部分以合成新测试程序。该方法利用LLMs的生成能力,同时保留触发Rust编译器bug的能力。它使能够全面测试编译器的行为,特别是探索边缘情况。我们实现了这一方法作为原型CLOZEMASTER。CLOZEMASTER已识别出27个已确认的rustc和mrustc bug,其中10个已由开发者修复。此外,我们的实验结果表明,CLOZEMASTER在代码覆盖率和有效性方面优于现有模糊器。

英文摘要:

Ensuring the reliability of the Rust compiler is of paramount importance, given increasing adoption of Rust for critical systems development, due to its emphasis on memory and thread safety. However, generating valid test programs for the Rust compiler poses significant challenges, given Rust's complex syntax and strict requirements. With the growing popularity of large language models (LLMs), much research in software testing has explored using LLMs to generate test cases. Still, directly using LLMs to generate Rust programs often results in a large number of invalid test cases. Existing studies have indicated that test cases triggering historical compiler bugs can assist in software testing. Our investigation into Rust compiler bug issues supports this observation. Inspired by existing work and our empirical research, we introduce a bracket-based masking and filling strategy called clozeMask. The clozeMask strategy involves extracting test code from historical issue reports, identifying and masking code snippets with specific structures, and using an LLM to fill in the masked portions for synthesizing new test programs. This approach harnesses the generative capabilities of LLMs while retaining the ability to trigger Rust compiler bugs. It enables comprehensive testing of the compiler's behavior, particularly exploring edge cases. We implemented our approach as a prototype CLOZEMASTER. CLOZEMASTER has identified 27 confirmed bugs for rustc and mrustc, of which 10 have been fixed by developers. Furthermore, our experimental results indicate that CLOZEMASTER outperforms existing fuzzers in terms of code coverage and effectiveness.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑