paperbot · PL 论文追踪

全部论文 待读 收藏

P2 SmartC2Rust: Iterative, Feedback-Driven C-to-Rust Translation via Large Language Models for Safety and Equivalence

SmartC2Rust:面向安全性与等价性的、基于大语言模型的迭代反馈驱动 C 到 Rust 翻译
ICSE Proceedings of the 2026 IEEE/ACM 48th International Conference on Software Engineering2026匹配度 4/10 · 论文属于 LLM 辅助代码翻译(C→Rust),涉及内存安全与语义等价,与 PL+AI 有交集;但其核心不是静态分析、形式化验证或 Agentic 程序分析,而是用反馈迭代改进翻译质量,与用户当前追的问题不直接匹配。引用 15 inbox
Momoko Shiraishi, Yinzhi Cao, Takahiro Shinagawa
crossref: 2026-09-12arxiv: 2026-09-12

AI 速览

一句话:提出迭代反馈驱动的 LLM 自动 C→Rust 翻译系统,通过多类反馈逐步提升生成代码的内存安全与语义等价。

内存安全漏洞在现有软件中依然普遍,将遗留 C 代码迁移到 Rust 等内存安全语言是重要缓解手段,而基于大语言模型(LLM)的自动翻译已显示出潜力,却仍面临生成代码无法编译、unsafe 语句过多以及语义功能偏离等问题,这源于 LLM 的 token 长度限制与输出不稳定等固有缺陷。本文设计并实现了自动化 C 到 Rust 翻译系统 SmartC2Rust,其核心思想是对 C 代码进行分段并转换为 Rust,同时利用额外反馈对输出进行迭代精化,反馈包括编译错误、分段上下文、语义差异以及内存不安全语句。这些反馈逐步提升所生成 Rust 代码的质量,从而缓解不安全、不一致与语义问题。评估表明,SmartC2Rust 显著减少了 unsafe 语句,并在安全性与语义等价性上优于先前工作。

问题
遗留 C 代码存在内存安全漏洞,而直接用 LLM 翻译到 Rust 时常常无法编译、保留大量 unsafe 语句且难以保持语义等价。
方法
将 C 代码分段转换为 Rust,并利用编译错误、分段上下文、语义差异和不安全语句等多源反馈对生成结果进行迭代精化。
评估
通过实验与先前工作对比,考察 unsafe 语句数量、安全性和语义等价性,结果显示 SmartC2Rust 显著减少 unsafe 语句并取得更优表现。
原文摘要(Abstract)

Memory safety vulnerabilities remain prevalent in today’s software systems and one promising solution to mitigate them is to adopt memory-safe languages such as Rust. Due to legacy code written in memory unsafe C, there is strong motivation to translate legacy C code into Rust. Prior works have already shown promise in using Large Language Models (LLMs) for such translations. However, significant challenges persist for LLM-based translation: the translated code often fails to compile, let alone reduce unsafe statements and maintain the semantic functionalities due to inherent limitations of LLMs such as limited token size and inconsistent outputs. In this paper, we design an automated C-to-Rust translation system, called SmartC2Rust, to segment and convert the C code to Rust with memory safety and semantic equivalence. The key insight is to iteratively refine the output Rust code with additional feedback, e.g., compilation errors, segmentation contexts, semantic discrepancies, and memory unsafe statements. Such feedback will gradually improve the quality of generated Rust code, thus mitigating unsafety, inconsistency, and semantic issues. Our evaluation shows that SmartC2Rust significantly decreases the unsafe statements and outperforms prior works in security and semantic equivalence.

链接与引用

DOI 原文 · arXiv ·

BibTeX
@inproceedings{paperbot11725,
  title = {SmartC2Rust: Iterative, Feedback-Driven C-to-Rust Translation via Large Language Models for Safety and Equivalence},
  author = {Momoko Shiraishi and Yinzhi Cao and Takahiro Shinagawa},
  booktitle = {ICSE},
  year = {2026},
  doi = {10.1145/3744916.3773259}
}