arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2411.14174cs.SEcs.CRcs.PL
收藏

将 C 翻译为 Rust:来自一项用户研究的经验

Translating C To Rust: Lessons from a User Study

Ruishi Li, Bo Wang, Tianyu Li, Prateek Saxena, Ashish Kundu

AI总结:

通过人工将真实 C 程序翻译为 Rust 的用户研究,发现人类能生成安全代码并采用零成本静态抽象等多样策略,可为改进自动翻译工具提供启示。

摘要:

Rust 旨在为程序提供完整的内存安全,而不受约束的 C 程序并不享有这一保证。将现有 C 代码翻译为 Rust 究竟有多困难?为了获得与自动 C 到 Rust 翻译器互补的视角,我们报告了一项用户研究,要求人类将真实世界的 C 程序翻译为 Rust。我们的参与者能够生成安全的 Rust 翻译,而最先进的自动工具却无法做到这一点。我们的分析强调,用户采用的高层策略与所研究自动工具的策略存在显著差异。我们还发现,用户通常会选择零成本(静态)抽象来保证时间安全,这解决了其他完整内存安全防御中运行时成本的主要组成部分。用户提供的翻译展现了丰富的专门策略,可将同一个 C 程序以不同方式翻译为安全的 Rust,未来的自动翻译器可以对此加以考虑。

英文摘要:

Rust aims to offer full memory safety for programs, a guarantee that untamed C programs do not enjoy. How difficult is it to translate existing C code to Rust? To get a complementary view from that of automatic C to Rust translators, we report on a user study asking humans to translate real-world C programs to Rust. Our participants are able to produce safe Rust translations, whereas state-of-the-art automatic tools are not able to do so. Our analysis highlights that the high-level strategy taken by users departs significantly from those of automatic tools we study. We also find that users often choose zero-cost (static) abstractions for temporal safety, which addresses a predominant component of runtime costs in other full memory safety defenses. User-provided translations showcase a rich landscape of specialized strategies to translate the same C program in different ways to safe Rust, which future automatic translators can consider.

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

↑