Open tomjoy75 opened 6 months ago
There are some tools we can use to help us detect thread-related errors like possible data races, deadlocks and lock order violations:
The -fsanitize=thread -g flag we can add at compilation. The -g option displays the specific files and line numbers involved.
The thread error detection tool Helgrind that we can run our program with, like this: valgrind --tool=helgrind ./philo
Beware of using both -fsanitize=thread and valgrind, they do not play well together!
And as always, we can’t forget to check for memory leaks with -fsanitize=address and valgrind!