rCanary: Detecting Memory Leaks Across Semi-Automated Memory Management Boundary in Rust

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 <italic xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:xlink="http://www.w3.org/1999/xlink">unsafe</i> keyword, the boundary of leaking memory is implicit, and the compiler would not emit any warnings for developers. In this paper, we present <sc xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:xlink="http://www.w3.org/1999/xlink">rCanary</small>, a static, non-intrusive, and fully automated model checker to detect leaks across the semi-automated 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 <sc xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:xlink="http://www.w3.org/1999/xlink">rCanary</small> 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.

Authors

Institutions

Publication Details

Journal
IEEE Transactions on Software Engineering
Published
2024-08-13
DOI
https://doi.org/10.1109/tse.2024.3443624
Citations
2
Primary Topic
Advanced Data Storage Technologies
Type
article
Field-Weighted Citation Impact
0.70

Funders

Controls
|||
ALL TIME
JAN
FEB
MAR
APR
MAY
JUN
JUL
AUG
SEP
OCT
article

rCanary: Detecting Memory Leaks Across Semi-Automated Memory Management Boundary in Rust

Hui Xu, Mohan Cui, Hongliang Tian, Yangfan Zhou
2 citations
IEEE Transactions on Software Engineering
Advanced Data Storage Technologies
0.70
article

rCanary: Detecting Memory Leaks Across Semi-Automated Memory Management Boundary in Rust

Hui Xu, Mohan Cui, Hongliang Tian, Yangfan Zhou
article en
2 citations

Abstract

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 <italic xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:xlink="http://www.w3.org/1999/xlink">unsafe</i> keyword, the boundary of leaking memory is implicit, and the compiler would not emit any warnings for developers. In this paper, we present <sc xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:xlink="http://www.w3.org/1999/xlink">rCanary</small>, a static, non-intrusive, and fully automated model checker to detect leaks across the semi-automated 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 <sc xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:xlink="http://www.w3.org/1999/xlink">rCanary</small> 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.

IEEE Transactions on Software EngineeringVol. 50(9)
Fudan University (CN)
National Natural Science Foundation of China
Openalex Percentile: Top 29%
Advanced Data Storage Technologies
0.70
AI Navigator

Ask Laika to Summarize, Analyze, and Connect papers live on the map.

Summarize Papers & Methodologies

Extract key findings, datasets, and comparative methods across publications.

Benchmark Rankings & Visual Analytics

Rank top research institutions, authors, funders, topics, and journals by Field-Weighted Citation Impact (FWCI) and paper volume with instant charts.

Connect Distant Disciplines

Bridge topological clusters on the map to find hidden collaborative intersections.

rCanary: Detecting Memory Leaks Across Semi-Automated Memory Management Boundary in Rust — Hui Xu, Mohan Cui, et al. · IEEE Transactions on Software Engineering (2024) | TGRS Research Map | TGRS