License: Creative Commons Attribution 3.0 Unported license (CC BY 3.0)
When quoting this document, please refer to the following
DOI: 10.4230/LIPIcs.ECOOP.2020.30
URN: urn:nbn:de:0030-drops-131878
URL: http://dagstuhl.sunsite.rwth-aachen.de/volltexte/2020/13187/
Fallin, Chris
Safe, Flexible Aliasing with Deferred Borrows
Abstract
In recent years, programming-language support for static memory safety has developed significantly. In particular, borrowing and ownership systems, such as the one pioneered by the Rust language, require the programmer to abide by certain aliasing restrictions but in return guarantee that no unsafe aliasing can ever occur. This allows parallel code to be written, or existing code to be parallelized, safely and easily, and the aliasing restrictions also statically prevent a whole class of bugs such as iterator invalidation. Borrowing is easy to reason about because it matches the intuitive ownership-passing conventions often used in systems languages.
Unfortunately, a borrowing-based system can sometimes be too restrictive. Because borrows enforce aliasing rules for their entire lifetimes, they cannot be used to implement some common patterns that pointers would allow. Programs often use pseudo-pointers, such as indices into an array of nodes or objects, instead, which can be error-prone: the program is still memory-safe by construction, but it is not logically memory-safe, because an object access may reach the wrong object.
In this work, we propose deferred borrows, which provide the type-safety benefits of borrows without the constraints on usage patterns that they otherwise impose. Deferred borrows work by encapsulating enough state at creation time to perform the actual borrow later, while statically guaranteeing that the eventual borrow will reach the same object it would have otherwise. The static guarantee is made with a path-dependent type tying the deferred borrow to the container (struct, vector, etc.) of the borrowed object. This combines the type-safety of borrowing with the flexibility of traditional pointers, while retaining logical memory-safety.
BibTeX - Entry
@InProceedings{fallin:LIPIcs:2020:13187,
author = {Chris Fallin},
title = {{Safe, Flexible Aliasing with Deferred Borrows}},
booktitle = {34th European Conference on Object-Oriented Programming (ECOOP 2020)},
pages = {30:1--30:26},
series = {Leibniz International Proceedings in Informatics (LIPIcs)},
ISBN = {978-3-95977-154-2},
ISSN = {1868-8969},
year = {2020},
volume = {166},
editor = {Robert Hirschfeld and Tobias Pape},
publisher = {Schloss Dagstuhl--Leibniz-Zentrum f{\"u}r Informatik},
address = {Dagstuhl, Germany},
URL = {https://drops.dagstuhl.de/opus/volltexte/2020/13187},
URN = {urn:nbn:de:0030-drops-131878},
doi = {10.4230/LIPIcs.ECOOP.2020.30},
annote = {Keywords: Rust, type systems, ownership types, borrowing}
}
Keywords: |
|
Rust, type systems, ownership types, borrowing |
Collection: |
|
34th European Conference on Object-Oriented Programming (ECOOP 2020) |
Issue Date: |
|
2020 |
Date of publication: |
|
06.11.2020 |