blob: efea0124c276c81cf0f6d2c164a30d5d8cd440e5 [file] [log] [blame]
njn3e986b22004-11-30 10:43:45 +00001<?xml version="1.0"?> <!-- -*- sgml -*- -->
2<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
3 "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
4
5<chapter id="hg-manual" xreflabel="Helgrind: a data-race detector">
6 <title>Helgrind: a data-race detector</title>
7
8<para>Helgrind is a Valgrind tool for detecting data races in C
9and C++ programs that use the Pthreads library.</para>
10
sewardj8d9fec52005-11-15 20:56:23 +000011<para>Note: Helgrind does not work in Valgrind 3.1.0. We hope
12to reinstate in version 3.2.0.</para>
13
14<para>To use this tool, you must specify
njn3e986b22004-11-30 10:43:45 +000015<computeroutput>--tool=helgrind</computeroutput> on the Valgrind
16command line.</para>
17
18<para>It uses the Eraser algorithm described in:
19
20 <address>Eraser: A Dynamic Data Race Detector for Multithreaded Programs
21 Stefan Savage, Michael Burrows, Greg Nelson, Patrick Sobalvarro and Thomas Anderson
22 ACM Transactions on Computer Systems, 15(4):391-411
23 November 1997.
24 </address>
25</para>
26
27<para>We also incorporate significant improvements from this paper:
28
29 <address>Runtime Checking of Multithreaded Applications with Visual Threads
30 Jerry J. Harrow, Jr.
31 Proceedings of the 7th International SPIN Workshop on Model Checking of Software
32 Stanford, California, USA
33 August 2000
34 LNCS 1885, pp331--342
35 K. Havelund, J. Penix, and W. Visser, editors.
36 </address>
37</para>
38
39<para>Basically what Helgrind does is to look for memory
40locations which are accessed by more than one thread. For each
41such location, Helgrind records which of the program's
42(pthread_mutex_)locks were held by the accessing thread at the
43time of the access. The hope is to discover that there is indeed
44at least one lock which is used by all threads to protect that
45location. If no such lock can be found, then there is
46(apparently) no consistent locking strategy being applied for
47that location, and so a possible data race might result.</para>
48
49<para>Helgrind also allows for "thread segment lifetimes". If
50the execution of two threads cannot overlap -- for example, if
51your main thread waits on another thread with a
52<computeroutput>pthread_join()</computeroutput> operation -- they
53can both access the same variable without holding a lock.</para>
54
55<para>There's a lot of other sophistication in Helgrind, aimed at
56reducing the number of false reports, and at producing useful
57error reports. We hope to have more documentation one
58day...</para>
59
60</chapter>