arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 1804.07608cs.PL
收藏

Rust的可执行操作语义及其所有权和借用的形式化

An Executable Operational Semantics for Rust with the Formalization of Ownership and Borrowing

Shuanglong Kan, Zhe Chen, David Sanan, Shang-Wei Lin, Yang Liu

摘要:

Rust是一种紧急系统程序设计语言,通过其所有权和借用系统(OBS)强调内存安全。Rust现有的形式语义只覆盖了Rust主要语言特性的有限子集。此外,他们形式化的OBS类型系统在语言级别上,它只能用于保守地分析程序在编译时对OBS不变量。也就是说,它们是不可执行的,因此不能用于运行时行为的自动验证。在本文中,我们提出了RustSEM,一个新的可执行操作语义的Rust。RustSEM涵盖了比现有语义更大的主要语言功能子集。此外,RustSEM在内存级别为OBS提供了一个操作语义,可以用来验证Rust程序在运行时的行为是否与OBS不变量相一致。我们在可执行语义建模工具K-Framework中实现了RustSEM。我们已经评估了RustSEM wrt的语义正确性。Rust编译器使用了大约700个测试。特别是,我们提出了一种新的技术,用于测试语义的一致性,以确保所有可能的执行选择的语义歧义的情况下。我们还评估了RustSEM在自动运行时和功能和内存属性的形式化验证中的潜在应用。实验结果表明,RustSEM能够增强Rust的内存安全机制,因为它在检测内存错误方面比OBS更强大。

英文摘要:

Rust is an emergent systems programming language highlighting memory safety by its Ownership and Borrowing System (OBS). The existing formal semantics for Rust only covers limited subsets of the major language features of Rust. Moreover, they formalize OBS as type systems at the language-level, which can only be used to conservatively analyze programs against the OBS invariants at compile-time. That is, they are not executable, and thus cannot be used for automated verification of runtime behavior. In this paper, we propose RustSEM, a new executable operational semantics for Rust. RustSEM covers a much larger subset of the major language features than existing semantics. Moreover, RustSEM provides an operational semantics for OBS at the memory-level, which can be used to verify the runtime behavior of Rust programs against the OBS invariants. We have implemented RustSEM in the executable semantics modeling tool K-Framework. We have evaluated the semantics correctness of RustSEM wrt. the Rust compiler using around 700 tests. In particular, we have proposed a new technique for testing semantic consistency to ensure the absence of semantic ambiguities on all possible execution selections. We have also evaluated the potential applications of RustSEM in automated runtime and formal verification for both functional and memory properties. Experimental results show that RustSEM can enhance the memory safety mechanism of Rust, as it is more powerful than OBS in detecting memory errors.

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

↑