Understanding Atomics and Memory Ordering Issues in Real-World Rust Software

Cheng Wang,Tengfei Tu,Sujuan Qin,Guangjun Wu,Fei Gao,Mingchao Wan
DOI: https://doi.org/10.1109/issre62328.2024.00061
2024-01-01
Abstract:Rust is designed as a systems programming language that aims to provide safety guarantees and performance efficiency. In practice, programmers usually use atomic correlations to share data across threads. For example, by using atomic operations to correlate with non-atomic addresses, they can design lock-free data structures for efficient concurrency. Although atomic operations are used in safe code, memory ordering misuses can still lead to atomic concurrency bugs and performance loss.In this paper, we conduct the first empirical study of atomic operations and memory ordering usage in Rust, manual inspection of 2883 atomic usages in real-world applications, including 15 thread bugs and 150 performance issues. We also study their usage scenarios, performance comparisons and issue fixes to provide a better understanding on Rust’s memory ordering misuses and guide better code practices in the future.We design AtomVChecker, an automated static analyzer to detect memory ordering misuses. we evaluate our tool on four widely-used concurrent libraries, it can automatically analyze 228 atomic correlations with 80% accuracy. Based on the atomic correlation analysis, AtomVChecker finds a total of 51 performance loss issues in 9 Rust packages, with all of them recently confirmed by the project maintainer based on our reports.
What problem does this paper attempt to address?