All Projects → BurtonQin → rust-lock-bug-detector

BurtonQin / rust-lock-bug-detector

Licence: Apache-2.0 license
Statically detect double-lock & conflicting-lock bugs on MIR

Programming Languages

rust
11053 projects
shell
77523 projects

Projects that are alternatives of or similar to rust-lock-bug-detector

numpy-vs-mir
Multigrid benchmark between Dlang's Mir library and Python's numpy
Stars: ✭ 19 (-51.28%)
Mutual labels:  mir
sonarlint4netbeans
SonarLint integration for Apache Netbeans
Stars: ✭ 23 (-41.03%)
Mutual labels:  static-analyzer
identypo
identypo is a Go static analysis tool to find typos in identifiers (functions, function calls, variables, constants, type declarations, packages, labels).
Stars: ✭ 26 (-33.33%)
Mutual labels:  static-analyzer
lints
Lint all your JavaScript, CSS, HTML, Markdown and Dockerfiles with a single command
Stars: ✭ 14 (-64.1%)
Mutual labels:  static-analyzer
phpstan-nette
Nette Framework class reflection extension for PHPStan & framework-specific rules
Stars: ✭ 87 (+123.08%)
Mutual labels:  static-analyzer
unimport
unimport is a Go static analysis tool to find unnecessary import aliases.
Stars: ✭ 64 (+64.1%)
Mutual labels:  static-analyzer
simpledbm
SimpleDBM is an Open Source Multi-Threaded Embeddable Transactional Database Engine in Java.
Stars: ✭ 51 (+30.77%)
Mutual labels:  deadlock-detection
libfmp
libfmp - Python package for teaching and learning Fundamentals of Music Processing (FMP)
Stars: ✭ 71 (+82.05%)
Mutual labels:  mir
pretty-d-array
Pretty printing multidimensional D arrays.
Stars: ✭ 16 (-58.97%)
Mutual labels:  mir
Exia
Million-scale code analysis and refactoring toolkit for Java
Stars: ✭ 42 (+7.69%)
Mutual labels:  static-analyzer
gdb-automatic-deadlock-detector
Script adds new command to GDB which allows automatically detect C/C++ thread locking and deadlocks in GDB debugger
Stars: ✭ 60 (+53.85%)
Mutual labels:  deadlock-detection
sonar-css-plugin
SonarQube CSS / SCSS / Less Analyzer
Stars: ✭ 46 (+17.95%)
Mutual labels:  static-analyzer
mir-core
Base software building blocks: Algebraic types (aka sumtype/tagged union/variant), universal reflection API, basic math, and more.
Stars: ✭ 23 (-41.03%)
Mutual labels:  mir
emusic net
Neural network to classify certain styles of Electronic music
Stars: ✭ 22 (-43.59%)
Mutual labels:  mir
nakedret
nakedret is a Go static analysis tool to find naked returns in functions greater than a specified function length.
Stars: ✭ 82 (+110.26%)
Mutual labels:  static-analyzer
tempo-cnn
Framework for estimating temporal properties of music tracks.
Stars: ✭ 62 (+58.97%)
Mutual labels:  mir
audio degrader
Audio degradation toolbox in python, with a command-line tool. It is useful to apply controlled degradations to audio: e.g. data augmentation, evaluation in noisy conditions, etc.
Stars: ✭ 40 (+2.56%)
Mutual labels:  mir
MixingBear
Package for automatic beat-mixing of music files in Python 🐻🎚
Stars: ✭ 73 (+87.18%)
Mutual labels:  mir
eba
EBA is a static bug finder for C.
Stars: ✭ 14 (-64.1%)
Mutual labels:  static-analyzer
MusDr
Evaluation metrics for machine-composed symbolic music. Paper: "The Jazz Transformer on the Front Line: Exploring the Shortcomings of AI-Composed Music through Quantitative Measures", ISMIR 2020
Stars: ✭ 38 (-2.56%)
Mutual labels:  mir

rust-lock-bug-detector

Statically detect double-lock & conflicting-lock bugs on MIR.

This work follows up the our elaborated Rust study in Understanding Memory and Thread Safety Practices and Issues in Real-World Rust Programs in PLDI'20. I am honored to share the co-first author with Yilun Chen and be able to collaborate with far-sighted, knowledgeable and hardworking Prof Linhai Song and Yiying Zhang. I focus on Rust unsafe code and concurrency bugs in this paper. This project is my initial efforts to improve the concurrency safety in Rust ecosystem by statically detecting two common kinds of concurrency bugs: double lock and locks in conflicting order.

Install

Currently supports rustc version: 1.51.0-nightly (7a9b552cb 2021-01-12)

$ git clone https://github.com/BurtonQin/rust-lock-bug-detector.git
$ cd rust-lock-bug-detector
$ rustup component add rust-src
$ rustup component add rustc-dev
$ rustup component add llvm-tools-preview
$ cargo install --path .

Example

Test examples

$ ./run.sh examples/inter

Run with cargo subcommands

$ cd examples/inter; cargo clean; cargo lock-bug-detect double-lock
$ cd examples/conflict-inter; cargo clean; cargo lock-bug-detect conflict-lock

You need to run

cargo clean

before re-detecting.

How it works

In Rust, a lock operation returns a lockguard. The lock will be unlocked when the lockguard is dropped. So we can track the lifetime of lockguards to detect lock-related bugs. For each crate (the crate to be checked and its dependencies)

  1. Collect LockGuard info, including
    • Where its lifetime begins and where it is dropped.
    • Use an (immature) automata to track its src (where the lockguard is created) to check if two lockguards come from the same lock heuristically.
  2. Collect the caller-callee relationship to generate the callgraph.
  3. Apply a GenKill algorithm to detect the lock-related bugs.

Caveats

  1. Currently only supports std::sync::{Mutex, RwLock}, parking_lot::{Mutex, RwLock}, spin::{Mutex, RwLock}
  2. The automata to track lockguard src location is still immature and uses many heuristic assumptions.
  3. The callgraph is crate-specific (the callers and callees are in the same crate) and cannot track indirect call.
  4. In the GenKill algorithm, the current iteration times for one function is limited to 10000 and the call-chain depth is 4 for speed.

Results

Found dozens of bugs in many repositories: openethereum, grin, winit, sonic, lighthouse, etc. Some of the repositories are dependencies of other large projects. I only find one FP is in crate cc because the automata mistakenly assumes two unrelated lockguards are from the same src.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].