paperbot · PL 论文追踪

全部论文 待读 收藏

P2 Is rust used safely by software developers?

Rust 是否被软件开发者安全地使用?
ICSE Proceedings of the ACM/IEEE 42nd International Conference on Software Engineering2020匹配度 2/10 · 论文关注 Unsafe Rust 的使用比例及不安全传播,属于编程语言与软件工程中的实证研究,虽与静态分析和内存安全相关,但未涉及 LLM/Agent、ML 系统静态分析、浮点程序分析或贝叶斯程序分析,因此与用户核心研究方向匹配度较低。引用 60 inbox
Ana Nora Evans, Bradford Campbell, Mary Lou Soffa
crossref: 2026-09-12

AI 速览

一句话:一项大规模实证研究揭示 Unsafe Rust 的使用比例及不安全性的传播,质疑 Rust 的内存安全承诺。

Rust 以强类型系统承诺内存安全与无数据竞争,但内嵌的 Unsafe Rust 允许 C 风格指针、可变全局变量等难以静态检查的操作,使用时编译器无法静态保证安全。本文对真实 Rust 库与应用开展大规模实证研究,考察开发者如何使用 Unsafe Rust。结果显示,不到 30% 的库直接使用 unsafe 关键字,但超过半数因调用链中隐藏的 Unsafe Rust 而无法被编译器完全静态检查。作者认为,unsafe 使用虽有限,不安全性的传播却挑战了 Rust 的内存安全宣称,并建议改进编译器和中心仓库接口以提醒开发者代码何时不安全。

问题
Rust 宣称通过类型系统保证内存安全与无数据竞争,但 Unsafe Rust 允许难以静态检查的操作,使这一保证在真实代码中可能失效;论文关注开发者实际如何使用 Unsafe Rust。
方法
对真实世界的 Rust 库和应用进行大规模实证研究,度量 unsafe 关键字的使用及其在调用链中的传播。
评估
基于真实 Rust 库/应用的统计结果:不到 30% 的库直接使用 unsafe,但超过半数因隐藏的 Unsafe Rust 无法被编译器完全静态检查;据此提出编译器与仓库接口改进建议。
原文摘要(Abstract)

Rust, an emerging programming language with explosive growth, provides a robust type system that enables programmers to write memory-safe and data-race free code. To allow access to a machine's hardware and to support low-level performance optimizations, a second language, Unsafe Rust, is embedded in Rust. It contains support for operations that are difficult to statically check, such as C-style pointers for access to arbitrary memory locations and mutable global variables. When a program uses these features, the compiler is unable to statically guarantee the safety properties Rust promotes. In this work, we perform a large-scale empirical study to explore how software developers are using Unsafe Rust in real-world Rust libraries and applications. Our results indicate that software engineers use the keyword unsafe in less than 30% of Rust libraries, but more than half cannot be entirely statically checked by the Rust compiler because of Unsafe Rust hidden somewhere in a library's call chain. We conclude that although the use of the keyword unsafe is limited, the propagation of unsafeness offers a challenge to the claim of Rust as a memory-safe language. Furthermore, we recommend changes to the Rust compiler and to the central Rust repository's interface to help Rust software developers be aware of when their Rust code is unsafe.

链接与引用

DOI 原文 · PDF(开放获取) ·

BibTeX
@inproceedings{paperbot5647,
  title = {Is rust used safely by software developers?},
  author = {Ana Nora Evans and Bradford Campbell and Mary Lou Soffa},
  booktitle = {ICSE},
  year = {2020},
  doi = {10.1145/3377811.3380413}
}