paperbot · PL 论文追踪

全部论文 待读 收藏

P2 Aliasing Limits on Translating C to Safe Rust

将 C 翻译为安全 Rust 的别名限制
OOPSLA 7(OOPSLA1)2023匹配度 3/10 · 论文属于程序分析与编译方向,研究 C 到安全 Rust 翻译中的别名分析限制与精度改进,与用户核心关注的 LLM/Agent 与静态分析交叉、浮点程序分析或贝叶斯程序分析无直接关系;仅在静态分析精度与评测方法论层面有间接参考价值。引用 30 inbox
Mehmet Emre, Peter Boyland, Aesha Parekh, Ryan Schroeder, Kyle Dewey, Ben Hardekopf
crossref: 2026-09-10

AI 速览

一句话:研究 C 到安全 Rust 翻译中别名分析的限制,并提出编码更精确分析结果的方法,使安全指针引用提升 75%。

本文研究将 C 代码(翻译后含 unsafe 裸指针的 Rust 程序)自动转换为使用安全 Rust 引用的方法及其局限。作者通过新颖评估方法考察基于所有权与生命周期推断的裸指针到安全引用翻译。结果发现,现有方法受 Rust 编译器安全检查器精度不足的严重限制,许多安全指针操作被误判为可能不安全,并推翻此前研究结论。为改进翻译,作者提出把更精确分析的结果编码为未修改 Rust 编译器可理解的形式,并实现其中一种方法;该实现使可转换为安全 Rust 引用的指针比例从基线的 12% 提升至 21%,相对提高 75%。

问题
如何自动将 C 代码翻译为使用安全 Rust 引用的 Rust 程序,以及现有基于所有权与生命周期推断的翻译方法在别名指针上的有效性与局限。
方法
提出新的评估方法来检验现有 C 到安全 Rust 翻译技术;分析 Rust 编译器安全检查器的精度问题,并提出将更精确分析结果编码以供未修改编译器理解的改进方法,且实现其中一种。
评估
通过新评估方法对比现有翻译技术,发现其因安全检查器精度不足而严重受限;实现的原型将可安全转换的指针数量较基线提升 75%(从 12% 到 21%)。
原文摘要(Abstract)

The Rust language was created to provide safe low-level systems programming. There is both industrial and academic interest in the problem of (semi-)automatically translating C code to Rust in order to exploit Rust's safety guarantees. We study the effectiveness and limitations of existing techniques for automatically translating unsafe raw pointers (in Rust programs translated from C) into safe Rust references via ownership and lifetime inference. Our novel evaluation methodology enables our study to extend beyond prior studies, and to discover new information contradicting the conclusions of prior studies. We find that existing translation methods are severely limited by a lack of precision in the Rust compiler's safety checker, causing many safe pointer manipulations to be labeled as potentially unsafe. Leveraging this information, we propose methods for improving translation, based on encoding the results of a more precise analysis in a manner that is understandable to an unmodified Rust compiler. We implement one of our proposed methods, increasing the number of pointers that can be translated to safe Rust references by 75% over the baseline (from 12% to 21% of all pointers).

链接与引用

DOI 原文 · PDF(开放获取) ·

BibTeX
@article{paperbot2021,
  title = {Aliasing Limits on Translating C to Safe Rust},
  author = {Mehmet Emre and Peter Boyland and Aesha Parekh and Ryan Schroeder and Kyle Dewey and Ben Hardekopf},
  journal = {Proceedings of the ACM on Programming Languages},
  volume = {7},
  number = {OOPSLA1},
  year = {2023},
  doi = {10.1145/3586046}
}