paperbot · PL 论文追踪

全部论文 待读 收藏

P2 Concrat: An Automatic C-to-Rust Lock API Translator for Concurrent Programs

Concrat:面向并发程序的自动 C-to-Rust 锁 API 翻译器
ICSE 2023 IEEE/ACM 45th International Conference on Software Engineering (ICSE)2023匹配度 3/10 · 论文属于静态分析与程序转换,方向为并发 C 程序的锁 API 到 Rust 的自动翻译,虽与程序分析/PL 相关,但不涉及用户核心关注的 PL→AI、AI→PL、浮点程序分析或贝叶斯程序分析,也未使用 LLM/Agent 或面向 ML/Agentic 程序。引用 31 inbox
Jaemin Hong, Sukyoung Ryu
crossref: 2026-09-12dblp: 2026-09-12arxiv: 2026-09-12

AI 速览

一句话:提出自动工具 Concrat,将并发 C 程序的锁 API 转换为 Rust 锁 API,由保持语义的代码转换器与精确锁摘要静态分析器组成。

并发程序中的数据竞争通常用锁消除,但 C 的锁 API 不校验锁使用是否正确,容易出错;Rust 的锁 API 则通过类型检查保证锁的正确获取与释放。将遗留 C 系统程序改写为 Rust 可提升安全性,但两者锁 API 的差异使手工翻译极为费力,现有自动 C-to-Rust 翻译器仍保留 C 锁 API。本文提出 Concrat,自动把 C 锁 API 替换为 Rust 锁 API。工具包含两部分:以锁摘要为输入、保持语义的 Rust 代码转换器,以及高效生成精确锁摘要的静态分析器。评估显示:转换器 2.6 秒处理 66 KLOC,成功处理 74% 的真实程序;分析器 4.3 秒分析 66 KLOC,兼具可扩展性与精度。

问题
C 与 Rust 的锁 API 不兼容,使遗留并发 C 程序难以自动翻译为 Rust;现有 C-to-Rust 翻译器仍保留 C 锁 API,需依赖人工替换。
方法
Concrat 由一个以锁摘要为输入、保持语义的 Rust 代码转换器,以及一个能高效生成精确锁摘要的静态分析器组成。
评估
在 66 KLOC 代码上,转换器 2.6 秒完成且成功处理 74% 的真实程序,分析器 4.3 秒完成分析,验证了工具的可扩展性、适用性与精度。
原文摘要(Abstract)

Concurrent programs suffer from data races. To prevent data races, programmers use locks. However, programs can eliminate data races only when they acquire and release correct locks at correct timing. The lock API of C, in which people have developed a large portion of legacy system programs, does not validate the correct use of locks. On the other hand, Rust, a recently developed system programming language, provides a lock API that guarantees the correct use of locks via type checking. This makes rewriting legacy system programs in Rust a promising way to retrofit safety into them. Unfortunately, manual C-to-Rust translation is extremely laborious due to the discrepancies between their lock APIs. Even the state-of-the-art automatic C-to-Rust translator retains the C lock API, expecting developers to replace them with the Rust lock API. In this work, we propose an automatic tool to replace the C lock API with the Rust lock API. It facilitates C-to-Rust translation of concurrent programs with less human effort than the current practice. Our tool consists of a Rust code transformer that takes a lock summary as an input and a static analyzer that efficiently generates precise lock summaries. We show that the transformer is scalable and widely applicable while preserving the semantics; it transforms 66 KLOC in 2.6 seconds and successfully handles 74% of real-world programs. We also show that the analyzer is scalable and precise; it analyzes 66 KLOC in 4.3 seconds.

链接与引用

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

BibTeX
@inproceedings{abs-2301-10943,
  title = {Concrat: An Automatic C-to-Rust Lock API Translator for Concurrent Programs},
  author = {Jaemin Hong and Sukyoung Ryu},
  booktitle = {ICSE},
  year = {2023},
  doi = {10.1109/icse48619.2023.00069}
}