Aliasing Limits on Translating C to Safe Rust
Open Access
- 6 April 2023
- journal article
- research article
- Published by Association for Computing Machinery (ACM) in Proceedings of the ACM on Programming Languages
- Vol. 7 (OOPSLA1) , 551-579
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).Keywords
This publication has 23 references indexed in Scilit:
- Hybrid context-sensitivity for points-to analysis2013
- Efficient field-sensitive pointer analysis of CACM Transactions on Programming Languages and Systems, 2007
- Context-Sensitive Points-to Analysis: Is It Worth It?2006
- CCured: type-safe retrofitting of legacy softwareACM Transactions on Programming Languages and Systems, 2005
- Client-Driven Pointer Analysis2003
- Ownership types for safe programming2002
- Ultra-fast aliasing analysis using CLA2001
- Introduction to set constraint-based program analysisScience of Computer Programming, 1999
- The effects of the precision of pointer analysis1997
- Graphs in Statistical AnalysisThe American Statistician, 1973