Open jrmuizel opened 5 years ago
Here's another example: https://searchfox.org/mozilla-central/source/xpcom/threads/DeadlockDetector.h
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.
I'm happy to add sanitizer support under a feature flag.
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.