sewardj | f555ac7 | 2002-11-18 00:07:28 +0000 | [diff] [blame] | 1 | |
sewardj | a9a2dcf | 2002-11-11 00:20:07 +0000 | [diff] [blame] | 2 | <html> |
| 3 | <head> |
sewardj | f555ac7 | 2002-11-18 00:07:28 +0000 | [diff] [blame] | 4 | <title>Helgrind: a data-race detector</title> |
sewardj | a9a2dcf | 2002-11-11 00:20:07 +0000 | [diff] [blame] | 5 | </head> |
| 6 | |
sewardj | f555ac7 | 2002-11-18 00:07:28 +0000 | [diff] [blame] | 7 | <a name="hg-top"></a> |
| 8 | <h2>6 Helgrind: a data-race detector</h2> |
sewardj | a9a2dcf | 2002-11-11 00:20:07 +0000 | [diff] [blame] | 9 | |
nethercote | 137bc55 | 2003-11-14 17:47:54 +0000 | [diff] [blame] | 10 | To use this tool, you must specify <code>--tool=helgrind</code> on the |
sewardj | f555ac7 | 2002-11-18 00:07:28 +0000 | [diff] [blame] | 11 | Valgrind command line. |
sewardj | a9a2dcf | 2002-11-11 00:20:07 +0000 | [diff] [blame] | 12 | <p> |
| 13 | |
nethercote | 137bc55 | 2003-11-14 17:47:54 +0000 | [diff] [blame] | 14 | Helgrind is a Valgrind tool for detecting data races in C and C++ programs |
sewardj | a9a2dcf | 2002-11-11 00:20:07 +0000 | [diff] [blame] | 15 | that use the Pthreads library. |
| 16 | <p> |
| 17 | It 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 | |
sewardj | f555ac7 | 2002-11-18 00:07:28 +0000 | [diff] [blame] | 26 | We also incorporate significant improvements from this paper: |
sewardj | a9a2dcf | 2002-11-11 00:20:07 +0000 | [diff] [blame] | 27 | |
| 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 | |
sewardj | f555ac7 | 2002-11-18 00:07:28 +0000 | [diff] [blame] | 39 | <p> |
| 40 | Basically what Helgrind does is to look for memory locations which are |
| 41 | accessed by more than one thread. For each such location, Helgrind |
| 42 | records which of the program's (pthread_mutex_)locks were held by the |
| 43 | accessing thread at the time of the access. The hope is to discover |
| 44 | that there is indeed at least one lock which is used by all threads to |
| 45 | protect that location. If no such lock can be found, then there is |
| 46 | (apparently) no consistent locking strategy being applied for that |
| 47 | location, and so a possible data race might result. |
njn | b767769 | 2003-05-20 17:41:24 +0000 | [diff] [blame] | 48 | <p> |
| 49 | Helgrind also allows for "thread segment lifetimes". If the execution of two |
| 50 | threads cannot overlap -- for example, if your main thread waits on another |
| 51 | thread with a <code>pthread_join()</code> operation -- they can both access the |
| 52 | same variable without holding a lock. |
sewardj | f555ac7 | 2002-11-18 00:07:28 +0000 | [diff] [blame] | 53 | <p> |
nethercote | 137bc55 | 2003-11-14 17:47:54 +0000 | [diff] [blame] | 54 | There's a lot of other sophistication in Helgrind, aimed at |
sewardj | f555ac7 | 2002-11-18 00:07:28 +0000 | [diff] [blame] | 55 | reducing the number of false reports, and at producing useful error |
njn | b767769 | 2003-05-20 17:41:24 +0000 | [diff] [blame] | 56 | reports. We hope to have more documentation one day... |
sewardj | f555ac7 | 2002-11-18 00:07:28 +0000 | [diff] [blame] | 57 | |
sewardj | a9a2dcf | 2002-11-11 00:20:07 +0000 | [diff] [blame] | 58 | </body> |
| 59 | </html> |
| 60 | |