arXivDaily arXiv每日学术速递 周一至周五更新
感恩节,周五至周末无更新,大家顺遂。周一再来吧
arXiv 2405.08372cs.PLcs.LO
收藏

使用库定义的能力(Capabilities)对 Rust 中的内部可变性进行推理

Reasoning about Interior Mutability in Rust using Library-Defined Capabilities

Federico Poli, Xavier Denis, Peter Müller, Alexander J. Summers

AI总结:

针对Rust内部可变性场景下现有验证技术不可靠或不完备的问题,提出基于库定义隐式能力的自动验证方法,设计对应注解与一阶逻辑编码,在Mendel验证器中实现,可零客户端注解验证多种标准库内部可变类型的使用安全性。

摘要:

现有的安全 Rust 代码自动化验证技术依赖强类型系统特性来对程序进行推理,尤其是推断哪些内存位置在函数调用过程中不会改变(即被帧保留)。然而,在存在内部可变性的情况下(例如与任何并发数据结构交互时),这些类型保证并不成立。因此,Prusti、Creusot 等现有的安全代码验证技术若应用于该场景,要么不可靠,要么从根本上是不完备的。\n在本研究中,我们提出了首个能够自动验证现有内部可变类型的安全客户端的技术。我们方法的核心是识别出一种新颖的隐式能力概念:无法用 Rust 类型表达的库定义属性。我们提出了新的注解来规范这些能力,并设计了适用于程序验证的一阶逻辑编码。\n我们在名为 Mendel 的验证器中实现了该技术,并用它证明了使用 Rc、Arc、Cell、RefCell、AtomicI32、Mutex 和 RwLock 等常见标准库内部可变类型的 Rust 程序不会出现 panic。我们的评估表明,这些库注解可有效验证真实库的使用场景,且功能足够强大,在许多被验证的程序中无需客户端侧添加任何注解。

英文摘要:

Existing automated verification techniques for safe Rust code rely on the strong type-system properties to reason about programs, especially to deduce which memory locations do not change (i.e., are framed) across function calls. However, these type guarantees do not hold in the presence of interior mutability (e.g., when interacting with any concurrent data structure). As a consequence, existing verification techniques for safe code such as Prusti and Creusot are either unsound or fundamentally incomplete if applied to this setting. In this work, we present the first technique capable of automatically verifying safe clients of existing interiorly mutable types. At the core of our approach, we identify a novel notion of implicit capabilities: library-defined properties that cannot be expressed using Rust's types. We propose new annotations to specify these capabilities and a first-order logic encoding suitable for program verification. We have implemented our technique in a verifier called Mendel and used it to prove absence of panics in Rust programs that make use of popular standard-library types with interior mutability, including Rc, Arc, Cell, RefCell, AtomicI32, Mutex and RwLock. Our evaluation shows that these library annotations are useful for verifying usages of real-world libraries, and powerful enough to require zero client-side annotations in many of the verified programs.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑