blob: 74ee451e93ad690d8913577e3d98722c3c399445 [file] [log] [blame]
sewardjf555ac72002-11-18 00:07:28 +00001
sewardja9a2dcf2002-11-11 00:20:07 +00002<html>
3 <head>
sewardjf555ac72002-11-18 00:07:28 +00004 <title>Helgrind: a data-race detector</title>
sewardja9a2dcf2002-11-11 00:20:07 +00005 </head>
6
sewardjf555ac72002-11-18 00:07:28 +00007<a name="hg-top"></a>
8<h2>6&nbsp; Helgrind: a data-race detector</h2>
sewardja9a2dcf2002-11-11 00:20:07 +00009
nethercote137bc552003-11-14 17:47:54 +000010To use this tool, you must specify <code>--tool=helgrind</code> on the
sewardjf555ac72002-11-18 00:07:28 +000011Valgrind command line.
sewardja9a2dcf2002-11-11 00:20:07 +000012<p>
13
nethercote137bc552003-11-14 17:47:54 +000014Helgrind is a Valgrind tool for detecting data races in C and C++ programs
sewardja9a2dcf2002-11-11 00:20:07 +000015that use the Pthreads library.
16<p>
17It uses the Eraser algorithm described in
18<blockquote>
19 Eraser: A Dynamic Data Race Detector for Multithreaded Programs<br>
20 Stefan Savage, Michael Burrows, Greg Nelson, Patrick Sobalvarro and
21 Thomas Anderson<br>
22 ACM Transactions on Computer Systems, 15(4):391-411<br>
23 November 1997.
24</blockquote>
25
sewardjf555ac72002-11-18 00:07:28 +000026We also incorporate significant improvements from this paper:
sewardja9a2dcf2002-11-11 00:20:07 +000027
28<blockquote>
29 Runtime Checking of Multithreaded Applications with Visual Threads
30 Jerry J. Harrow, Jr.<br>
31 Proceedings of the 7th International SPIN Workshop on Model Checking of
32 Software<br>
33 Stanford, California, USA<br>
34 August 2000<br>
35 LNCS 1885, pp331--342<br>
36 K. Havelund, J. Penix, and W. Visser, editors.<br>
37</blockquote>
38
sewardjf555ac72002-11-18 00:07:28 +000039<p>
40Basically what Helgrind does is to look for memory locations which are
41accessed by more than one thread. For each such location, Helgrind
42records which of the program's (pthread_mutex_)locks were held by the
43accessing thread at the time of the access. The hope is to discover
44that there is indeed at least one lock which is used by all threads to
45protect that location. If no such lock can be found, then there is
46(apparently) no consistent locking strategy being applied for that
47location, and so a possible data race might result.
njnb7677692003-05-20 17:41:24 +000048<p>
49Helgrind also allows for "thread segment lifetimes". If the execution of two
50threads cannot overlap -- for example, if your main thread waits on another
51thread with a <code>pthread_join()</code> operation -- they can both access the
52same variable without holding a lock.
sewardjf555ac72002-11-18 00:07:28 +000053<p>
nethercote137bc552003-11-14 17:47:54 +000054There's a lot of other sophistication in Helgrind, aimed at
sewardjf555ac72002-11-18 00:07:28 +000055reducing the number of false reports, and at producing useful error
njnb7677692003-05-20 17:41:24 +000056reports. We hope to have more documentation one day...
sewardjf555ac72002-11-18 00:07:28 +000057
sewardja9a2dcf2002-11-11 00:20:07 +000058</body>
59</html>
60