Lune

OOPSLA2020顶会

How do programmers use unsafe rust?

Vytautas Astrauskas, Christoph Matheja, Federico Poli, Peter Müller, Alexander J. Summers

摘要

Rust’s ownership type system enforces a strict discipline on how memory locations are accessed and shared. This discipline allows the compiler to statically prevent memory errors, data races, inadvertent side effects through aliasing, and other errors that frequently occur in conventional imperative programs. However, the restrictions imposed by Rust’s type system make it difficult or impossible to implement certain designs, such as data structures that require aliasing (e.g. doubly-linked lists and shared caches). To work around this limitation, Rust allows code blocks to be declared as unsafe and thereby exempted from certain restrictions of the type system, for instance, to manipulate C-style raw pointers. Ensuring the safety of unsafe code is the responsibility of the programmer. However, an important assumption of the Rust language, which we dub the Rust hypothesis , is that programmers use Rust by following three main principles: use unsafe code sparingly, make it easy to review, and hide it behind a safe abstraction such that client code can be written in safe Rust. Understanding how Rust programmers use unsafe code and, in particular, whether the Rust hypothesis holds is essential for Rust developers and testers, language and library designers, as well as tool developers. This paper studies empirically how unsafe code is used in practice by analysing a large corpus of Rust projects to assess the validity of the Rust hypothesis and to classify the purpose of unsafe code. We identify queries that can be answered by automatically inspecting the program’s source code, its intermediate representation MIR, as well as type information provided by the Rust compiler; we complement the results by manual code inspection. Our study supports the Rust hypothesis partially: While most unsafe code is simple and well-encapsulated, unsafe features are used extensively, especially for interoperability with other languages.

问 Lune

几分钟读透这篇 Paper,不用再花一下午。

Lune 能读完全文,也能读引用它的顶会 Paper,讲清它的结论、证据和局限,每一点都注明出自哪篇 Paper。不用硬啃,也不靠猜。

已有 27 篇顶会 Paper 引用了它。别等审稿人问起,先弄清它们发现了什么。

可以从这些问题问起

Lune 可以查阅

全文 · 引用它的顶会 Paper · 相关的 Paper

获取答案

免费开始,无需绑卡

脉络

  • An Empirical Study of Rust-for-Linux: The Success, Dissatisfaction, and Compromise 引用了 Rudra: Finding Memory Safety Bugs in Rust at the Ecosystem Scale
  • An Empirical Study of Rust-for-Linux: The Success, Dissatisfaction, and Compromise 引用了 Understanding memory and thread safety practices and issues in real-world Rust programs
  • An Empirical Study of Rust-for-Linux: The Success, Dissatisfaction, and Compromise 引用了 Is rust used safely by software developers?
  • An Empirical Study of Rust-for-Linux: The Success, Dissatisfaction, and Compromise 引用了 Learning and Programming Challenges of Rust: A Mixed-Methods Study
  • Rudra: Finding Memory Safety Bugs in Rust at the Ecosystem Scale 引用了 Understanding memory and thread safety practices and issues in real-world Rust programs
  • Rudra: Finding Memory Safety Bugs in Rust at the Ecosystem Scale 引用了 Is rust used safely by software developers?
  • Learning and Programming Challenges of Rust: A Mixed-Methods Study 引用了 Understanding memory and thread safety practices and issues in real-world Rust programs
  • Learning and Programming Challenges of Rust: A Mixed-Methods Study 引用了 Is rust used safely by software developers?
  • Translating C to safer Rust 引用了 Understanding memory and thread safety practices and issues in real-world Rust programs
  • Translating C to safer Rust 引用了 Is rust used safely by software developers?
它引用的引用它的从左到右按年份排列,引用越多,位置越高。

引用它的顶会 Paper27

  1. Using Lightweight Formal Methods to Validate a Key-Value Storage Node in Amazon S3James Bornholt, Rajeev Joshi, Vytautas Astrauskas, Brendan Cully 等SOSP 2021 · 63 次引用
  2. Rudra: Finding Memory Safety Bugs in Rust at the Ecosystem ScaleYechan Bae, Youngsuk Kim, Ammar Askar, Jungwon Lim 等SOSP 2021 · 61 次引用
  3. Translating C to safer RustMehmet Emre, Ryan Schroeder, Kyle Dewey, Ben HardekopfOOPSLA 2021 · 60 次引用
  4. An Empirical Study of Rust-for-Linux: The Success, Dissatisfaction, and CompromiseHongyu Li, Liwei Guo, Yexuan Yang, Shangguang Wang 等USENIX ATC 2024 · 29 次引用
  5. Learning and Programming Challenges of Rust: A Mixed-Methods StudyShuofei Zhu, Ziyi Zhang, Boqin Qin, Aiping Xiong 等ICSE 2022 · 27 次引用

它引用的 Paper2

  1. Understanding memory and thread safety practices and issues in real-world Rust programsBoqin Qin, Yilun Chen, Zeming Yu, Linhai Song 等PLDI 2020 · 112 次引用
  2. Is rust used safely by software developers?Ana Nora Evans, Bradford Campbell, Mary Lou SoffaICSE 2020 · 57 次引用

相关 Paper

  1. "I wouldn't want my unsafe code to run my pacemaker": An Interview Study on the Use, Comprehension, and Perceived Risks of Unsafe RustSandra Höltervennhoff, Philip Klostermeyer, Noah Wöhler, Yasemin Acar 等USENIX Security 2023
  2. Aliasing Limits on Translating C to Safe RustMehmet Emre, Peter Boyland, Aesha Parekh, Ryan Schroeder 等OOPSLA 2023 · 32 次引用
  3. RustSan: Retrofitting AddressSanitizer for Efficient Sanitization of RustKyuwon Cho, Jongyoon Kim, Kha Dinh Duy, Hajeong Lim 等USENIX Security 2024 · 7 次引用
  4. Tree BorrowsNeven Villani, Johannes Hostert, Derek Dreyer, Ralf JungPLDI 2025 · 8 次引用
  5. TRust: A Compilation Framework for In-process Isolation to Protect Safe Rust against Untrusted CodeInyoung Bang, Martin Kayondo, Hyungon Moon, Yunheung PaekUSENIX Security 2023
黄昏的海面,两侧是细线勾勒的悬崖