Amanieu / parking_lot

Compact and efficient synchronization primitives for Rust. Also provides an API for creating custom synchronization primitives.
Apache License 2.0
2.69k stars 211 forks source link

Add lock dependency checking #120

Open jrmuizel opened 5 years ago

jrmuizel commented 5 years ago

It would be cool if parking_lot had runtime support for doing the kind of lock dependency checking that liblockdep (https://lwn.net/Articles/536363/) or https://github.com/cmccabe/lksmith do.

jrmuizel commented 5 years ago

Here's another example: https://searchfox.org/mozilla-central/source/xpcom/threads/DeadlockDetector.h

tmiasko commented 3 years ago

The Thread Sanitizer detects lock order inversions. By default this includes only pthread mutexes, but there is an API that can be used to integrate custom implementations. Additionally, when reporting data races, the reports include information about mutexes held at the time, by each thread.

If there is interest in such a functionality it shouldn't be technically difficult to implement. I prototyped this at some point and didn't encounter significant issues.

Amanieu commented 3 years ago

I'm happy to add sanitizer support under a feature flag.