Static Deadlock Detection for Rust Programs

Yu Zhang,Kaiwen Zhang,Guanjun Liu
2024-01-02
Abstract:Rust relies on its unique ownership mechanism to ensure thread and memory safety. However, numerous potential security vulnerabilities persist in practical applications. New language features in Rust pose new challenges for vulnerability detection. This paper proposes a static deadlock detection method tailored for Rust programs, aiming to identify various deadlock types, including double lock, conflict lock, and deadlock associated with conditional variables. With due consideration for Rust's ownership and lifetimes, we first complete the pointer analysis. Then, based on the obtained points-to information, we analyze dependencies among variables to identify potential deadlocks. We develop a tool and conduct experiments based on the proposed method. The experimental results demonstrate that our method outperforms existing deadlock detection methods in precision.
Programming Languages,Cryptography and Security,Software Engineering
What problem does this paper attempt to address?
The paper primarily addresses the issue of deadlock detection in the Rust programming language. Rust ensures the safety of threads and memory through its unique ownership mechanism, but there are still potential security vulnerabilities in practical applications, especially challenges brought by new features. The paper proposes a static deadlock detection method for Rust programs, aimed at identifying various types of deadlocks, including double locking, conflicting locks, and deadlocks related to condition variables. To adapt to Rust's ownership and lifetime concepts, the authors first completed pointer analysis, and then, based on the acquired pointer information, analyzed the dependencies between variables to identify potential deadlocks. They developed a tool and conducted experiments based on this method. The experimental results show that this method is more accurate than existing deadlock detection methods. The paper provides a detailed introduction to Rust's ownership and lifetime rules, the Mid-level Intermediate Representation (MIR), and deadlock patterns, and describes the framework used for deadlock detection, including two main parts: pointer analysis and deadlock detection. In addition, it proposes detection algorithms for double locks, conflicting locks, and deadlocks related to condition variables, and visualizes these dependencies using lock graphs and extended lock graphs. Finally, the paper discusses the efficiency and time complexity of the method and points out that future work will focus on improving the precision of the method and tool, and supporting more types of deadlock detection.