Forcrat: Automatic I/O API Translation from C to Rust via Origin and Capability Analysis
Jaemin Hong, Sukyoung Ryu
摘要
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.
问 Lune
几分钟读透这篇 Paper,不用再花一下午。
Lune 能读完全文,也能读引用它的顶会 Paper,讲清它的结论、证据和局限,每一点都注明出自哪篇 Paper。不用硬啃,也不靠猜。
已有 3 篇顶会 Paper 引用了它。别等审稿人问起,先弄清它们发现了什么。
脉络
- Project-Level C-to-Rust Translation via Pointer Knowledge Graphs 引用了 Ownership Guided C to Rust Translation
- Project-Level C-to-Rust Translation via Pointer Knowledge Graphs 引用了 Aliasing Limits on Translating C to Safe Rust
- Project-Level C-to-Rust Translation via Pointer Knowledge Graphs 引用了 Don't Write, but Return: Replacing Output Parameters with Algebraic Data Types in C-to-Rust Translation
- Project-Level C-to-Rust Translation via Pointer Knowledge Graphs 引用了 Translating C to safer Rust
- Ownership Guided C to Rust Translation 引用了 Translating C to safer Rust
- Aliasing Limits on Translating C to Safe Rust 引用了 Translating C to safer Rust
- Hayroll: A Modular Wrapper for Translating C Macros and Conditional Compilation to Rust 引用了 Project-Level C-to-Rust Translation via Pointer Knowledge Graphs
- Hayroll: A Modular Wrapper for Translating C Macros and Conditional Compilation to Rust 引用了 Ownership Guided C to Rust Translation
- Hayroll: A Modular Wrapper for Translating C Macros and Conditional Compilation to Rust 引用了 Aliasing Limits on Translating C to Safe Rust
- Hayroll: A Modular Wrapper for Translating C Macros and Conditional Compilation to Rust 引用了 Concrat: An Automatic C-to-Rust Lock API Translator for Concurrent Programs
- Hayroll: A Modular Wrapper for Translating C Macros and Conditional Compilation to Rust 引用了 Don't Write, but Return: Replacing Output Parameters with Algebraic Data Types in C-to-Rust Translation
- Hayroll: A Modular Wrapper for Translating C Macros and Conditional Compilation to Rust 引用了 Translating C to safer Rust
- Concrat: An Automatic C-to-Rust Lock API Translator for Concurrent Programs 引用了 Translating C to safer Rust
- Rust’s Type Checker Implementation Is Unsound: An Empirical Study on Soundness Bugs in rustc 引用了 Ownership Guided C to Rust Translation
- Rust’s Type Checker Implementation Is Unsound: An Empirical Study on Soundness Bugs in rustc 引用了 Aliasing Limits on Translating C to Safe Rust
- Rust’s Type Checker Implementation Is Unsound: An Empirical Study on Soundness Bugs in rustc 引用了 Concrat: An Automatic C-to-Rust Lock API Translator for Concurrent Programs
- Rust’s Type Checker Implementation Is Unsound: An Empirical Study on Soundness Bugs in rustc 引用了 Don't Write, but Return: Replacing Output Parameters with Algebraic Data Types in C-to-Rust Translation
- Rust’s Type Checker Implementation Is Unsound: An Empirical Study on Soundness Bugs in rustc 引用了 Translating C to safer Rust
引用它的顶会 Paper3
- Hayroll: A Modular Wrapper for Translating C Macros and Conditional Compilation to RustHaoran Peng, Baris Kasikci, Gilbert Louis Bernstein, Michael D. ErnstPLDI 2026 · 1 次引用
- Project-Level C-to-Rust Translation via Pointer Knowledge GraphsZhiqiang Yuan, Wenjun Mao, Zhuo Chen, Xiyue Shang 等FSE 2026
- Rust’s Type Checker Implementation Is Unsound: An Empirical Study on Soundness Bugs in rustcYusung Sim, Sukyoung Ryu, Jaemin HongISSTA 2026
它引用的 Paper8
- Translating C to safer RustMehmet Emre, Ryan Schroeder, Kyle Dewey, Ben HardekopfOOPSLA 2021 · 60 次引用
- Ownership Guided C to Rust TranslationHanliang Zhang, Cristina David, Yijun Yu, Meng WangCAV 2023 · 37 次引用
- Aliasing Limits on Translating C to Safe RustMehmet Emre, Peter Boyland, Aesha Parekh, Ryan Schroeder 等OOPSLA 2023 · 32 次引用
- Concrat: An Automatic C-to-Rust Lock API Translator for Concurrent ProgramsJaemin Hong, Sukyoung RyuICSE 2023 · 17 次引用
- Don't Write, but Return: Replacing Output Parameters with Algebraic Data Types in C-to-Rust TranslationJaemin Hong, Sukyoung RyuPLDI 2024 · 17 次引用
相关 Paper
- To Tag, or Not to Tag: Translating C's Unions to Rust's Tagged UnionsJaemin Hong, Sukyoung RyuASE 2024 · 6 次引用
- &inator: Correct, Precise C-to-Rust Interface TranslationVictor Chen, Ayden Coughlin, Michael D. BondPLDI 2026 · 1 次引用
- Scylla: Translating an Applicative Subset of C to Safe RustAymeric Fromherz, Jonathan ProtzenkoOOPSLA 2026 · 6 次引用
- GenC2Rust: Towards Generating Generic Rust Code from CXiafa Wu, Brian DemskyICSE 2025 · 4 次引用
- Raw Pointer Rewriting with LLMs for Translating C to Safer RustYifei Gao, Chengpeng Wang, Pengxiang Huang, Xuwei Liu 等ACL Findings 2026 · 3 次引用
