RustAssure:面向LLM转译C到Rust代码的差分符号测试
RustAssure: Differential Symbolic Testing for LLM-Transpiled C-to-Rust Code
AI总结:
RustAssure利用LLM自动将C代码转译为Rust,并通过差分符号测试验证语义等价性,在真实应用中为89.8%的C函数生成可编译Rust代码,其中69.9%符号返回值等价。
摘要:
Rust是一种内存安全的编程语言,能显著提升软件安全性。现有的用不安全内存语言(如C)编写的代码库,必须首先转译为Rust,才能利用Rust改进的安全保证。RustAssure提出了一种系统,利用大型语言模型(LLMs)自动将现有的C代码库转译为Rust。RustAssure采用提示工程技术,以最大化LLM生成地道且安全的Rust代码的可能性。此外,由于LLM生成的代码常常带有细微的缺陷,这些缺陷在传统的单元测试或模糊测试下可能被遗漏,RustAssure执行差分符号测试,以建立原始C代码与LLM转译的Rust代码之间的语义相似性。我们使用五个真实世界的应用程序和库对RustAssure进行了评估,结果表明,我们的系统能够为所有C函数中的89.8%生成可编译的Rust函数,其中69.9%的函数在C和Rust版本中产生了等价的符号返回值。
英文摘要:
Rust is a memory-safe programming language that significantly improves software security. Existing codebases written in unsafe memory languages, such as C, must first be transpiled to Rust to take advantage of Rust's improved safety guarantees. RustAssure presents a system that uses Large Language Models (LLMs) to automatically transpile existing C codebases to Rust. RustAssure uses prompt engineering techniques to maximize the chances of the LLM generating idiomatic and safe Rust code. Moreover, because LLMs often generate code with subtle bugs that can be missed under traditional unit or fuzz testing, RustAssure performs differential symbolic testing to establish the semantic similarity between the original C and LLM-transpiled Rust code. We evaluated RustAssure with five real-world applications and libraries, and showed that our system is able to generate compilable Rust functions for 89.8% of all C functions, of which 69.9% produced equivalent symbolic return values for both the C and Rust functions.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。