6  Helgrind: a data-race detector

To use this skin, you must specify --skin=helgrind on the Valgrind command line.

Helgrind is a Valgrind skin for detecting data races in C and C++ programs that use the Pthreads library.

It uses the Eraser algorithm described in

Eraser: A Dynamic Data Race Detector for Multithreaded Programs
Stefan Savage, Michael Burrows, Greg Nelson, Patrick Sobalvarro and Thomas Anderson
ACM Transactions on Computer Systems, 15(4):391-411
November 1997.
We also incorporate significant improvements from this paper:
Runtime Checking of Multithreaded Applications with Visual Threads Jerry J. Harrow, Jr.
Proceedings of the 7th International SPIN Workshop on Model Checking of Software
Stanford, California, USA
August 2000
LNCS 1885, pp331--342
K. Havelund, J. Penix, and W. Visser, editors.

Basically what Helgrind does is to look for memory locations which are accessed by more than one thread. For each such location, Helgrind records which of the program's (pthread_mutex_)locks were held by the accessing thread at the time of the access. The hope is to discover that there is indeed at least one lock which is used by all threads to protect that location. If no such lock can be found, then there is (apparently) no consistent locking strategy being applied for that location, and so a possible data race might result.

There's a lot of other sophistication in the Helgrind skin, aimed at reducing the number of false reports, and at producing useful error reports. We hope to have more documentation soon.