rCanary:在 Rust 半自动内存管理边界上检测内存泄漏
rCanary: Detecting Memory Leaks Across Semi-automated Memory Management Boundary in Rust
AI总结:
rCanary 是一个静态全自动模型检查器,通过编码堆分配数据并基于布尔可满足性形式化无泄漏内存模型,检测 Rust 半自动内存管理边界上的泄漏,在 1200 多个真实 crate 中识别出 19 个存在泄漏的 crate。
摘要:
Rust 是一种有效的系统编程语言,通过编译期验证保证内存安全。它采用一种新颖的基于所有权的资源管理模型来实现自动释放。该模型被认为能够消除内存泄漏。然而,我们观察到用户干预使其转变为半自动内存管理,并且容易出错从而导致泄漏。与违反由 unsafe 关键字限制的内存安全保证不同,内存泄漏的边界是隐式的,编译器不会为开发者发出任何警告。在本文中,我们提出了 rCanary,一个静态、非侵入式且全自动的模型检查器,用于检测半自动边界上的泄漏。我们设计了一个编码器,对具有堆分配的数据进行抽象,并基于布尔可满足性形式化了一个精化的无泄漏内存模型。它可以为 Rust MIR 生成 SMT-Lib2 格式的约束,并作为 Cargo 组件实现。我们使用从开源 Rust 项目的拉取请求中收集的有缺陷的包基准来评估 rCanary。结果表明,可以在可接受的误报率下召回所有这些缺陷。我们进一步将工具应用于来自 crates.io 和 GitHub 的 1200 多个真实世界 crate,识别出 19 个存在内存泄漏的 crate。我们的分析器也很高效,每个包耗时 8.4 秒。
英文摘要:
Rust is an effective system programming language that guarantees memory safety via compile-time verifications. It employs a novel ownership-based resource management model to facilitate automated deallocation. This model is anticipated to eliminate memory leaks. However, we observed that user intervention drives it into semi-automated memory management and makes it error-prone to cause leaks. In contrast to violating memory-safety guarantees restricted by the unsafe keyword, the boundary of leaking memory is implicit, and the compiler would not emit any warnings for developers. In this paper, we present rCanary, a static, non-intrusive, and fully automated model checker to detect leaks across the semiautomated boundary. We design an encoder to abstract data with heap allocation and formalize a refined leak-free memory model based on boolean satisfiability. It can generate SMT-Lib2 format constraints for Rust MIR and is implemented as a Cargo component. We evaluate rCanary by using flawed package benchmarks collected from the pull requests of open-source Rust projects. The results indicate that it is possible to recall all these defects with acceptable false positives. We further apply our tool to more than 1,200 real-world crates from crates.io and GitHub, identifying 19 crates having memory leaks. Our analyzer is also efficient, that costs 8.4 seconds per package.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。