Affiliation:
1. Victoria University of Wellington, Wellington, New Zealand
Abstract
Rust is a relatively new programming language that has gained significant traction since its v1.0 release in 2015. Rust aims to be a systems language that competes with C/C++. A claimed advantage of Rust is a strong focus on memory safety without garbage collection. This is primarily achieved through two concepts, namely,
reference lifetimes
and
borrowing
. Both of these are well-known ideas stemming from the literature on
region-based memory management
and
linearity
/
uniqueness
. Rust brings both of these ideas together to form a coherent programming model. Furthermore, Rust has a strong focus on stack-allocated data and, like C/C++ but unlike Java, permits references to local variables.
Type checking in Rust can be viewed as a two-phase process: First, a traditional type checker operates in a flow-insensitive fashion; second, a
borrow checker
enforces an ownership invariant using a flow-sensitive analysis. In this article, we present a lightweight formalism that captures these two phases using a flow-sensitive type system that enforces “
type and borrow safety
.” In particular, programs that are type and borrow safe will not attempt to dereference dangling pointers. Our calculus core captures many aspects of Rust, including copy- and move-semantics, mutable borrowing, reborrowing, partial moves, and lifetimes. In particular, it remains sufficiently lightweight to be easily digested and understood and, we argue, still captures the salient aspects of reference lifetimes and borrowing. Furthermore, extensions to the core can easily add more complex features (e.g., control-flow, tuples, method invocation). We provide a soundness proof to verify our key claims of the calculus. We also provide a reference implementation in Java with which we have model checked our calculus using over 500B input programs. We have also fuzz tested the Rust compiler using our calculus against 2B programs and, to date, found one confirmed compiler bug and several other possible issues.
Publisher
Association for Computing Machinery (ACM)
Cited by
13 articles.
订阅此论文施引文献
订阅此论文施引文献,注册后可以免费订阅5篇论文的施引文献,订阅后可以查看论文全部施引文献
1. Descend: A Safe GPU Systems Programming Language;Proceedings of the ACM on Programming Languages;2024-06-20
2. Understanding and Detecting Real-World Safety Issues in Rust;IEEE Transactions on Software Engineering;2024-06
3. Functional Ownership through Fractional Uniqueness;Proceedings of the ACM on Programming Languages;2024-04-29
4. Rust-lancet: Automated Ownership-Rule-Violation Fixing with Behavior Preservation;Proceedings of the IEEE/ACM 46th International Conference on Software Engineering;2024-04-12
5. RPG: Rust Library Fuzzing with Pool-based Fuzz Target Generation and Generic Support;Proceedings of the IEEE/ACM 46th International Conference on Software Engineering;2024-04-12