[go: up one dir, main page]
More Web Proxy on the site http://driver.im/ skip to main content
10.1145/3510454.3528640acmconferencesArticle/Chapter ViewAbstractPublication PagesicseConference Proceedingsconference-collections
poster

In rust we trust: a transpiler from unsafe C to safer rust

Published: 19 October 2022 Publication History

Abstract

Rust is a type-safe system programming language with a compiler checking memory and concurrency safety. For a smooth transition from existing C projects, a source-to-source transpiler can autotransform C programs into Rust using program transformation. However, existing C-to-Rust transformation tools (e.g. the open-source C2Rust transpiler1 project) have the drawback of preserving the unsafe semantics of C, while rewriting them in Rust's syntax. The work by Emre et el. [2] acknowledged these drawbacks, and used rustc compiler feedback to refactor one certain type of raw pointers to Rust references to improve overall safety and idiomaticness of C2Rust output. Focusing on improving API-safeness (i.e. lowering unsafe keyword usage in function signatures), we apply source-to-source transformation technique to auto-refactor C2Rust output using code structure pattern matching and transformation, which does not rely on rustc compiler feedback. And by relaxing the semantics-preserving constraints of transformations, we present CRustS2 a fully-automated source-to-source transformation approach that increases the ratio of the transformed code passing the safety checks of the rustc compiler. Our method uses 220 new TXL [1] source-to-source transformation rules, of which 198 are strictly semantics-preserving and 22 are semantics-approximating, thus reducing the scope of unsafe expressions and exposing more opportunities for safe Rust refactoring. Our method has been evaluated on both open-source and commercial C projects, and demonstrates significantly higher safe code ratios after the transformations, with function-level safe code ratios comparable to the average level of idiomatic Rust projects.

References

[1]
James R. Cordy. 2006. The TXL source transformation language. Science of Computer Programming 61, 3 (2006), 190--210.
[2]
Mehmet Emre, Ryan Schroeder, Kyle Dewey, and Ben Hardekopf. 2021. Translating C to Safer Rust. Proc. ACM Program. Lang. 5, OOPSLA, Article 121 (oct 2021).
[3]
Ralf Jung, Jacques-Henri Jourdan, Robbert Krebbers, and Derek Dreyer. 2021. Safe Systems Programming in Rust. Commun. ACM 64, 4 (March 2021), 144--152.
[4]
Nicholas D. Matsakis and Felix S. Klock. 2014. The Rust language. ACM SIGAda Ada Letters 34, 3 (Oct. 2014), 103--104.
[5]
Boqin Qin, Yilun Chen, Zeming Yu, Linhai Song, and Yiying Zhang. 2020. Understanding memory and thread safety practices and issues in real-world Rust programs. In Proceedings of the 41st ACM SIGPLAN Conf. on PLDI. London, UK.
[6]
Garming Sam, Nick Cameron, and Alex Potanin. 2017. Automated refactoring of Rust programs. In Proceedings of the Australasian Computer Science Week Multiconference (ACSW '17). ACM, Geelong, Australia, 1--9.

Cited By

View all
  • (2024)SolMover: Smart Contract Code Translation Based on ConceptsProceedings of the 1st ACM International Conference on AI-Powered Software10.1145/3664646.3664771(112-121)Online publication date: 10-Jul-2024
  • (2024)Don’t Write, but Return: Replacing Output Parameters with Algebraic Data Types in C-to-Rust TranslationProceedings of the ACM on Programming Languages10.1145/36564068:PLDI(716-740)Online publication date: 20-Jun-2024
  • (2024)On the Impact of Memory Safety on Fast Network I/O2024 IEEE 25th International Conference on High Performance Switching and Routing (HPSR)10.1109/HPSR62440.2024.10635971(161-166)Online publication date: 22-Jul-2024
  • Show More Cited By

Recommendations

Comments

Please enable JavaScript to view thecomments powered by Disqus.

Information & Contributors

Information

Published In

cover image ACM Conferences
ICSE '22: Proceedings of the ACM/IEEE 44th International Conference on Software Engineering: Companion Proceedings
May 2022
394 pages
ISBN:9781450392235
DOI:10.1145/3510454
Permission to make digital or hard copies of part or all of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for third-party components of this work must be honored. For all other uses, contact the Owner/Author.

Sponsors

In-Cooperation

  • IEEE CS

Publisher

Association for Computing Machinery

New York, NY, United States

Publication History

Published: 19 October 2022

Check for updates

Author Tags

  1. code transformation
  2. measurement
  3. refactoring
  4. safety
  5. transpiler

Qualifiers

  • Poster

Conference

ICSE '22
Sponsor:

Acceptance Rates

Overall Acceptance Rate 276 of 1,856 submissions, 15%

Upcoming Conference

ICSE 2025

Contributors

Other Metrics

Bibliometrics & Citations

Bibliometrics

Article Metrics

  • Downloads (Last 12 months)316
  • Downloads (Last 6 weeks)46
Reflects downloads up to 31 Dec 2024

Other Metrics

Citations

Cited By

View all
  • (2024)SolMover: Smart Contract Code Translation Based on ConceptsProceedings of the 1st ACM International Conference on AI-Powered Software10.1145/3664646.3664771(112-121)Online publication date: 10-Jul-2024
  • (2024)Don’t Write, but Return: Replacing Output Parameters with Algebraic Data Types in C-to-Rust TranslationProceedings of the ACM on Programming Languages10.1145/36564068:PLDI(716-740)Online publication date: 20-Jun-2024
  • (2024)On the Impact of Memory Safety on Fast Network I/O2024 IEEE 25th International Conference on High Performance Switching and Routing (HPSR)10.1109/HPSR62440.2024.10635971(161-166)Online publication date: 22-Jul-2024
  • (2024)A study of common bug fix patterns in RustEmpirical Software Engineering10.1007/s10664-023-10437-129:2Online publication date: 12-Feb-2024
  • (2023)Fuzz Testing for Rust Library Functions2023 IEEE 22nd International Conference on Trust, Security and Privacy in Computing and Communications (TrustCom)10.1109/TrustCom60117.2023.00139(990-997)Online publication date: 1-Nov-2023
  • (2023)Ownership Guided C to Rust TranslationComputer Aided Verification10.1007/978-3-031-37709-9_22(459-482)Online publication date: 17-Jul-2023
  • (2022)RUSTY: Effective C to Rust Conversion via Unstructured Control Specialization2022 IEEE 22nd International Conference on Software Quality, Reliability, and Security Companion (QRS-C)10.1109/QRS-C57518.2022.00122(760-761)Online publication date: Dec-2022
  • (2022)Safe Rust Code Recommendation Based on Siamese Graph Neural Network2022 IEEE 27th Pacific Rim International Symposium on Dependable Computing (PRDC)10.1109/PRDC55274.2022.00015(1-11)Online publication date: Nov-2022

View Options

Login options

View options

PDF

View or Download as a PDF file.

PDF

eReader

View online with eReader.

eReader

Media

Figures

Other

Tables

Share

Share

Share this Publication link

Share on social media