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

对Rust库中跨外函数边界未定义行为的研究

A Study of Undefined Behavior Across Foreign Function Boundaries in Rust Libraries

Carnegie Mellon University(卡内基梅隆大学)

Ian McCormack, Joshua Sunshine, Jonathan Aldrich

AI总结:

研究发现Rust库中存在未定义行为,指出需改进多语言应用的工具以确保正确性。

摘要:

开发者依赖Rust编程语言的静态安全性保证来编写安全且高性能的应用程序。然而,Rust经常与其他语言交互,这些语言允许与Rust不断演变的别名模型相冲突的设计模式。Miri是目前唯一能够验证应用程序符合这些模型的动态分析工具,但它不支持在外部函数中发现错误,这表明在Rust生态系统中可能存在一个关键的正确性缺口。我们对调用外部函数的Rust库进行了大规模评估,以确定Miri的动态分析在此背景下是否仍然有用。我们使用Miri和LLVM解释器共同执行调用外部函数的应用程序,在其中发现了37个库中的46个未定义或不期望的行为实例。在我们的观察期内,有三个库的平均每日下载量超过10,000次,其中发现了一个错误,该库由Rust项目维护。许多这些错误是Rust别名模型的违反,但最新的Tree Borrows模型比早期的Stacked Borrows模型要宽松得多。Rust社区必须投资于新的、生产就绪的工具,以确保开发者能够检测到这些错误。

英文摘要:

Developers rely on the static safety guarantees of the Rust programming language to write secure and performant applications. However, Rust is frequently used to interoperate with other languages which allow design patterns that conflict with Rust's evolving aliasing models. Miri is currently the only dynamic analysis tool that can validate applications against these models, but it does not support finding bugs in foreign functions, indicating that there may be a critical correctness gap across the Rust ecosystem. We conducted a large-scale evaluation of Rust libraries that call foreign functions to determine whether Miri's dynamic analyses remain useful in this context. We used Miri and an LLVM interpreter to jointly execute applications that call foreign functions, where we found 46 instances of undefined or undesired behavior in 37 libraries. Three bugs were found in libraries that had more than 10,000 daily downloads on average during our observation period, and one was found in a library maintained by the Rust Project. Many of these bugs were violations of Rust's aliasing models, but the latest Tree Borrows model was significantly more permissive than the earlier Stacked Borrows model. The Rust community must invest in new, production-ready tooling for multi-language applications to ensure that developers can detect these errors.

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

↑