Static analyzer for Rust concurrency and memory safety
Top 58.9% on sourcepulse
This project provides static analysis tools for detecting concurrency and memory bugs, as well as potential panic locations in Rust projects. It is primarily aimed at Rust developers and researchers seeking to improve code safety and reliability by identifying issues like deadlocks, atomicity violations, use-after-free, and panics.
How It Works
Lockbud tracks the lifetime of Rust's LockGuard
types to detect lock-related bugs. It constructs a call graph for each crate and its dependencies, identifies LockGuard
creation and drop points, and uses a GenKill algorithm to find pairs of lockguards where one is not dropped before the other is acquired. It then applies points-to analysis to determine if these lockguards refer to the same lock, enabling detection of double-locking and, by building a graph of lock acquisition sequences, conflict-locking (deadlocks).
Quick Start & Requirements
rustc-1.76.0-nightly-2024-12-01
or later), install components (rust-src
, rustc-dev
, llvm-tools-preview
), and then run cargo install --path .
. Alternatively, use cargo lockbud
within your project directory or the provided Docker image../detect.sh <path_to_project>
or cargo lockbud -k <bug_kind>
.Highlighted Details
Maintenance & Community
The codebase is described as implemented quickly with plans for future refactoring. A to-do list is available in issue #58.
Licensing & Compatibility
Limitations & Caveats
The panic location detector may report many locations due to simplified analysis. Deadlock detectors currently support specific Mutex
and RwLock
implementations (std
, parking_lot
, spin
). Call graph analysis is crate-specific and may not track indirect calls. Points-to analysis has limitations, particularly with the cc
crate, leading to potential false positives; blacklisting cc
is recommended. Memory and panic detectors may have false positives, especially on standard library and common dependencies.
2 months ago
1 day