Basic python script for helping to check for deadlocks in C/C++ programs that use POSIX mutexes as the primary synchronization mechanism.
Internally, this script calls the C/C++ program using GDB. As such, this script requires GDB to be installed, and that the program being debugged is compiled with the -g compiler flag. Additionally, this program will not work for multi-processed programs.
This script can be run from the command line or by importing in python
This script can be called from the command line:
python3 deadlock_detector [--print] <executable file> <executable arguments...>Use a context manager to open up a DeadlockDetector:
from deadlock_detector import DeadlockDetector
with DeadlockDetector({ executable file name }) as dd:
dd.run({ executable arguments }) # Run the program using the deadlock detector
dd.verify_lock_stacks() # Ensure all pthread_mutex_lock call stacks don't have deadlock