paperbot · PL 论文追踪

全部论文 待读 收藏

P2 Forcrat: Automatic I/O API Translation from C to Rust via Origin and Capability Analysis

Forcrat:基于来源与能力分析的 C 到 Rust 自动 I/O API 翻译
ASE 2025 40th IEEE/ACM International Conference on Automated Software Engineering (ASE)2025匹配度 2/10 · 该论文属于传统静态分析与程序转换,目标是C到Rust的I/O API自动迁移,未涉及LLM/Agent、浮点程序分析或贝叶斯程序分析,与用户画像的核心交叉方向基本无关;仅在静态分析技术方法论上有很弱的参考价值。引用 2 inbox
Jaemin Hong, Sukyoung Ryu
crossref: 2026-09-12

AI 速览

一句话:提出 Forcrat,用来源/能力与错误源静态分析将 C2Rust 生成代码中的 libc I/O 调用自动替换为 Rust std 调用。

将 C 遗留系统迁移到 Rust 可提升可靠性,但 C2Rust 仍保留 libc 调用而非替换为 Rust 标准库。本文聚焦 I/O API 替换,其难点在于两边 API 的类型设计不同:libc 与 Rust std 用不同类型表示流的来源(标准输入、文件)与能力(读、写),且错误检查机制不同(libc 内部指示器 vs Rust std 返回值)。为此提出两种静态分析:来源与能力分析、错误源分析,并据此自动替换 I/O API。评估显示方法正确(32 个带测试套件程序变换后全部通过)、高效(14 秒分析并变换 422k LOC)、适用性广(替换 82% I/O API 调用)。

问题
C2Rust 生成的 Rust 代码仍调用 libc 函数,未利用 Rust 标准库,影响可移植性与可靠性;其中 I/O API 因类型与错误检查语义差异难以自动替换。
方法
提出来源与能力分析识别流的来源/能力类型,并提出错误源分析处理 libc 内部错误指示器到 Rust 返回值的转换,基于结果替换 I/O API 调用。
评估
在 32 个带测试套件的程序上验证正确性,分析并变换 422k LOC 耗时 14 秒,并替换 82% 的 I/O API 调用。
原文摘要(Abstract)

Translating C to Rust is a promising way to enhance the reliability of legacy system programs. Although the industry has developed an automatic C-to-Rust translator, C2Rust, its translation remains unsatisfactory. One major reason is that C2Rust retains C standard library (libc) function calls instead of replacing them with functions from the Rust standard library (Rust std). However, little work has been done on replacing library functions in C2Rust-generated code. In this work, we focus on replacing the I/O API, an important subset of library functions. This poses challenges due to the semantically different designs of I/O APIs in libc and Rust std. First, the two APIs offer different sets of types that represent the origins (e.g., standard input, files) and capabilities (e.g., read, write) of streams used for I/O. Second, they use different error-checking mechanisms: libc uses internal indicators, while Rust std uses return values. To address these challenges, we propose two static analysis techniques, origin and capability analysis and error source analysis, and use their results to replace the I/O API. Our evaluation shows that the proposed approach is (1) correct, with all 32 programs that have test suites passing the tests after transformation, (2) efficient, analyzing and transforming 422k LOC in 14 seconds, and (3) widely applicable, replacing 82% of I/O API calls.

链接与引用

DOI 原文 ·

BibTeX
@inproceedings{paperbot9497,
  title = {Forcrat: Automatic I/O API Translation from C to Rust via Origin and Capability Analysis},
  author = {Jaemin Hong and Sukyoung Ryu},
  booktitle = {ASE},
  year = {2025},
  doi = {10.1109/ase63991.2025.00130}
}