| 1 |
<html> |
| 2 |
<head> |
| 3 |
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> |
| 4 |
<title>Valgrind Frequently Asked Questions</title> |
| 5 |
<link rel="stylesheet" type="text/css" href="vg_basic.css"> |
| 6 |
<meta name="generator" content="DocBook XSL Stylesheets Vsnapshot"> |
| 7 |
<link rel="home" href="index.html" title="Valgrind Documentation"> |
| 8 |
<link rel="up" href="FAQ.html" title="Valgrind FAQ"> |
| 9 |
<link rel="prev" href="FAQ.html" title="Valgrind FAQ"> |
| 10 |
<link rel="next" href="tech-docs.html" title="Valgrind Technical Documentation"> |
| 11 |
</head> |
| 12 |
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> |
| 13 |
<div><table class="nav" width="100%" cellspacing="3" cellpadding="3" border="0" summary="Navigation header"><tr> |
| 14 |
<td width="22px" align="center" valign="middle"><a accesskey="p" href="FAQ.html"><img src="images/prev.png" width="18" height="21" border="0" alt="Prev"></a></td> |
| 15 |
<td width="25px" align="center" valign="middle"><a accesskey="u" href="FAQ.html"><img src="images/up.png" width="21" height="18" border="0" alt="Up"></a></td> |
| 16 |
<td width="31px" align="center" valign="middle"><a accesskey="h" href="index.html"><img src="images/home.png" width="27" height="20" border="0" alt="Up"></a></td> |
| 17 |
<th align="center" valign="middle">Valgrind FAQ</th> |
| 18 |
<td width="22px" align="center" valign="middle"><a accesskey="n" href="tech-docs.html"><img src="images/next.png" width="18" height="21" border="0" alt="Next"></a></td> |
| 19 |
</tr></table></div> |
| 20 |
<div class="article"> |
| 21 |
<div class="titlepage"> |
| 22 |
<div><div><h1 class="title"> |
| 23 |
<a name="faq"></a>Valgrind Frequently Asked Questions</h1></div></div> |
| 24 |
<hr> |
| 25 |
</div> |
| 26 |
<div class="qandaset"> |
| 27 |
<dl> |
| 28 |
<dt>1. <a href="faq.html#faq.background">Background</a> |
| 29 |
</dt> |
| 30 |
<dd>1.1. <a href="faq.html#faq.pronounce">How do you pronounce "Valgrind"?</a> |
| 31 |
</dd> |
| 32 |
<dd>1.2. <a href="faq.html#faq.whence">Where does the name "Valgrind" come from?</a> |
| 33 |
</dd> |
| 34 |
</dl> |
| 35 |
<dl> |
| 36 |
<dt>2. <a href="faq.html#faq.installing">Compiling, installing and configuring</a> |
| 37 |
</dt> |
| 38 |
<dd>2.1. <a href="faq.html#faq.make_dies">When building Valgrind, 'make' dies partway with |
| 39 |
an assertion failure, something like this:</a> |
| 40 |
</dd> |
| 41 |
<dd>2.2. <a href="faq.html#faq.glibc_devel">When building Valgrind, 'make' fails with this:</a> |
| 42 |
</dd> |
| 43 |
</dl> |
| 44 |
<dl> |
| 45 |
<dt>3. <a href="faq.html#faq.abort">Valgrind aborts unexpectedly</a> |
| 46 |
</dt> |
| 47 |
<dd>3.1. <a href="faq.html#faq.exit_errors">Programs run OK on Valgrind, but at exit produce a bunch of |
| 48 |
errors involving __libc_freeres and then die |
| 49 |
with a segmentation fault.</a> |
| 50 |
</dd> |
| 51 |
<dd>3.2. <a href="faq.html#faq.bugdeath">My (buggy) program dies like this:</a> |
| 52 |
</dd> |
| 53 |
<dd>3.3. <a href="faq.html#faq.msgdeath">My program dies, printing a message like this along the |
| 54 |
way:</a> |
| 55 |
</dd> |
| 56 |
<dd>3.4. <a href="faq.html#faq.java">I tried running a Java program (or another program that uses a |
| 57 |
just-in-time compiler) under Valgrind but something went wrong. |
| 58 |
Does Valgrind handle such programs?</a> |
| 59 |
</dd> |
| 60 |
</dl> |
| 61 |
<dl> |
| 62 |
<dt>4. <a href="faq.html#faq.unexpected">Valgrind behaves unexpectedly</a> |
| 63 |
</dt> |
| 64 |
<dd>4.1. <a href="faq.html#faq.reports">My program uses the C++ STL and string classes. Valgrind |
| 65 |
reports 'still reachable' memory leaks involving these classes at |
| 66 |
the exit of the program, but there should be none.</a> |
| 67 |
</dd> |
| 68 |
<dd>4.2. <a href="faq.html#faq.unhelpful">The stack traces given by Memcheck (or another tool) aren't |
| 69 |
helpful. How can I improve them?</a> |
| 70 |
</dd> |
| 71 |
<dd>4.3. <a href="faq.html#faq.aliases">The stack traces given by Memcheck (or another tool) seem to |
| 72 |
have the wrong function name in them. What's happening?</a> |
| 73 |
</dd> |
| 74 |
<dd>4.4. <a href="faq.html#faq.crashes">My program crashes normally, but doesn't under Valgrind, or vice |
| 75 |
versa. What's happening?</a> |
| 76 |
</dd> |
| 77 |
<dd>4.5. <a href="faq.html#faq.hiddenbug"> Memcheck doesn't report any errors and I know my program has |
| 78 |
errors.</a> |
| 79 |
</dd> |
| 80 |
<dd>4.6. <a href="faq.html#faq.overruns">Why doesn't Memcheck find the array overruns in this |
| 81 |
program?</a> |
| 82 |
</dd> |
| 83 |
<dd>4.7. <a href="faq.html#faq.mismatches">Why does Memcheck report many |
| 84 |
"Mismatched free() / delete / delete []" errors when |
| 85 |
my code is correct?</a> |
| 86 |
</dd> |
| 87 |
</dl> |
| 88 |
<dl> |
| 89 |
<dt>5. <a href="faq.html#faq.misc">Miscellaneous</a> |
| 90 |
</dt> |
| 91 |
<dd>5.1. <a href="faq.html#faq.writesupp">I tried writing a suppression but it didn't work. Can you |
| 92 |
write my suppression for me?</a> |
| 93 |
</dd> |
| 94 |
<dd>5.2. <a href="faq.html#faq.deflost">With Memcheck's memory leak detector, what's the |
| 95 |
difference between "definitely lost", "indirectly lost", "possibly |
| 96 |
lost", "still reachable", and "suppressed"?</a> |
| 97 |
</dd> |
| 98 |
<dd>5.3. <a href="faq.html#faq.undeferrors">Memcheck's uninitialised value errors are hard to track down, |
| 99 |
because they are often reported some time after they are caused. Could |
| 100 |
Memcheck record a trail of operations to better link the cause to the |
| 101 |
effect? Or maybe just eagerly report any copies of uninitialised |
| 102 |
memory values?</a> |
| 103 |
</dd> |
| 104 |
<dd>5.4. <a href="faq.html#faq.pcre2_qt">I'm developing a Qt application and I get huge numbers of "Conditional jump" |
| 105 |
errors. Is there anything that I can do about it?</a> |
| 106 |
</dd> |
| 107 |
<dd>5.5. <a href="faq.html#faq.attach">Is it possible to attach Valgrind to a program that is already |
| 108 |
running?</a> |
| 109 |
</dd> |
| 110 |
</dl> |
| 111 |
<dl> |
| 112 |
<dt>6. <a href="faq.html#faq.help">How To Get Further Assistance</a> |
| 113 |
</dt> |
| 114 |
<dd>6.1. <a href="faq.html#e-help">Where can I get more help?</a> |
| 115 |
</dd> |
| 116 |
</dl> |
| 117 |
<br><table width="100%" summary="Q and A Div" cellpadding="2" cellspacing="2" border="0"> |
| 118 |
<tr class="qandadiv"><td align="left" valign="top" colspan="2"> |
| 119 |
<a name="faq.background"></a><h3 class="title"> |
| 120 |
<a name="faq.background"></a>1. Background</h3> |
| 121 |
</td></tr> |
| 122 |
<tr class="toc" colspan="2"><td align="left" valign="top" colspan="2">1.1. <a href="faq.html#faq.pronounce">How do you pronounce "Valgrind"?</a><br>1.2. <a href="faq.html#faq.whence">Where does the name "Valgrind" come from?</a><br> |
| 123 |
</td></tr> |
| 124 |
<tr><td colspan="2"> </td></tr> |
| 125 |
<tr class="question"> |
| 126 |
<td align="left" valign="top"> |
| 127 |
<a name="faq.pronounce"></a><a name="q-pronounce"></a><b>1.1.</b> |
| 128 |
</td> |
| 129 |
<td align="left" valign="top"><b>How do you pronounce "Valgrind"?</b></td> |
| 130 |
</tr> |
| 131 |
<tr class="answer"> |
| 132 |
<td align="left" valign="top"><a name="a-pronounce"></a></td> |
| 133 |
<td align="left" valign="top"> |
| 134 |
<p>The "Val" as in the word "value". The "grind" is pronounced |
| 135 |
with a short 'i' -- ie. "grinned" (rhymes with "tinned") rather than |
| 136 |
"grined" (rhymes with "find").</p> |
| 137 |
<p>Don't feel bad: almost |
| 138 |
everyone gets it wrong at first.</p> |
| 139 |
</td> |
| 140 |
</tr> |
| 141 |
<tr><td colspan="2"> </td></tr> |
| 142 |
<tr class="question"> |
| 143 |
<td align="left" valign="top"> |
| 144 |
<a name="faq.whence"></a><a name="q-whence"></a><b>1.2.</b> |
| 145 |
</td> |
| 146 |
<td align="left" valign="top"><b>Where does the name "Valgrind" come from?</b></td> |
| 147 |
</tr> |
| 148 |
<tr class="answer"> |
| 149 |
<td align="left" valign="top"><a name="a-whence"></a></td> |
| 150 |
<td align="left" valign="top"> |
| 151 |
<p>From Nordic mythology. Originally (before release) the project |
| 152 |
was named Heimdall, after the watchman of the Nordic gods. He could |
| 153 |
"see a hundred miles by day or night, hear the grass growing, see the |
| 154 |
wool growing on a sheep's back", etc. This would have been a great |
| 155 |
name, but it was already taken by a security package "Heimdal".</p> |
| 156 |
<p>Keeping with the Nordic theme, Valgrind was chosen. Valgrind is |
| 157 |
the name of the main entrance to Valhalla (the Hall of the Chosen |
| 158 |
Slain in Asgard). Over this entrance there resides a wolf and over it |
| 159 |
there is the head of a boar and on it perches a huge eagle, whose eyes |
| 160 |
can see to the far regions of the nine worlds. Only those judged |
| 161 |
worthy by the guardians are allowed to pass through Valgrind. All |
| 162 |
others are refused entrance.</p> |
| 163 |
<p>It's not short for "value grinder", although that's not a bad |
| 164 |
guess.</p> |
| 165 |
</td> |
| 166 |
</tr> |
| 167 |
</table> |
| 168 |
<br><table width="100%" summary="Q and A Div" cellpadding="2" cellspacing="2" border="0"> |
| 169 |
<tr class="qandadiv"><td align="left" valign="top" colspan="2"> |
| 170 |
<a name="faq.installing"></a><h3 class="title"> |
| 171 |
<a name="faq.installing"></a>2. Compiling, installing and configuring</h3> |
| 172 |
</td></tr> |
| 173 |
<tr class="toc" colspan="2"><td align="left" valign="top" colspan="2">2.1. <a href="faq.html#faq.make_dies">When building Valgrind, 'make' dies partway with |
| 174 |
an assertion failure, something like this:</a><br>2.2. <a href="faq.html#faq.glibc_devel">When building Valgrind, 'make' fails with this:</a><br> |
| 175 |
</td></tr> |
| 176 |
<tr><td colspan="2"> </td></tr> |
| 177 |
<tr class="question"> |
| 178 |
<td align="left" valign="top"> |
| 179 |
<a name="faq.make_dies"></a><a name="q-make_dies"></a><b>2.1.</b> |
| 180 |
</td> |
| 181 |
<td align="left" valign="top"> |
| 182 |
<b>When building Valgrind, 'make' dies partway with |
| 183 |
an assertion failure, something like this:</b><pre class="screen"> |
| 184 |
% make: expand.c:489: allocated_variable_append: |
| 185 |
Assertion 'current_variable_set_list->next != 0' failed. |
| 186 |
</pre> |
| 187 |
</td> |
| 188 |
</tr> |
| 189 |
<tr class="answer"> |
| 190 |
<td align="left" valign="top"><a name="a-make_dies"></a></td> |
| 191 |
<td align="left" valign="top"><p>It's probably a bug in 'make'. Some, but not all, instances of |
| 192 |
version 3.79.1 have this bug, see |
| 193 |
<a class="ulink" href="http://www.mail-archive.com/[email protected]/msg01658.html" target="_top">this</a>. |
| 194 |
Try upgrading to a more recent version of 'make'. Alternatively, we have |
| 195 |
heard that unsetting the CFLAGS environment variable avoids the |
| 196 |
problem.</p></td> |
| 197 |
</tr> |
| 198 |
<tr><td colspan="2"> </td></tr> |
| 199 |
<tr class="question"> |
| 200 |
<td align="left" valign="top"> |
| 201 |
<a name="faq.glibc_devel"></a><a name="q-glibc_devel"></a><b>2.2.</b> |
| 202 |
</td> |
| 203 |
<td align="left" valign="top"> |
| 204 |
<b>When building Valgrind, 'make' fails with this:</b><pre class="screen"> |
| 205 |
/usr/bin/ld: cannot find -lc |
| 206 |
collect2: ld returned 1 exit status |
| 207 |
</pre> |
| 208 |
</td> |
| 209 |
</tr> |
| 210 |
<tr class="answer"> |
| 211 |
<td align="left" valign="top"><a name="a-glibc_devel"></a></td> |
| 212 |
<td align="left" valign="top"><p>You need to install the glibc-static-devel package.</p></td> |
| 213 |
</tr> |
| 214 |
</table> |
| 215 |
<br><table width="100%" summary="Q and A Div" cellpadding="2" cellspacing="2" border="0"> |
| 216 |
<tr class="qandadiv"><td align="left" valign="top" colspan="2"> |
| 217 |
<a name="faq.abort"></a><h3 class="title"> |
| 218 |
<a name="faq.abort"></a>3. Valgrind aborts unexpectedly</h3> |
| 219 |
</td></tr> |
| 220 |
<tr class="toc" colspan="2"><td align="left" valign="top" colspan="2">3.1. <a href="faq.html#faq.exit_errors">Programs run OK on Valgrind, but at exit produce a bunch of |
| 221 |
errors involving __libc_freeres and then die |
| 222 |
with a segmentation fault.</a><br>3.2. <a href="faq.html#faq.bugdeath">My (buggy) program dies like this:</a><br>3.3. <a href="faq.html#faq.msgdeath">My program dies, printing a message like this along the |
| 223 |
way:</a><br>3.4. <a href="faq.html#faq.java">I tried running a Java program (or another program that uses a |
| 224 |
just-in-time compiler) under Valgrind but something went wrong. |
| 225 |
Does Valgrind handle such programs?</a><br> |
| 226 |
</td></tr> |
| 227 |
<tr><td colspan="2"> </td></tr> |
| 228 |
<tr class="question"> |
| 229 |
<td align="left" valign="top"> |
| 230 |
<a name="faq.exit_errors"></a><a name="q-exit_errors"></a><b>3.1.</b> |
| 231 |
</td> |
| 232 |
<td align="left" valign="top"><b>Programs run OK on Valgrind, but at exit produce a bunch of |
| 233 |
errors involving <code class="literal">__libc_freeres</code> and then die |
| 234 |
with a segmentation fault.</b></td> |
| 235 |
</tr> |
| 236 |
<tr class="answer"> |
| 237 |
<td align="left" valign="top"><a name="a-exit_errors"></a></td> |
| 238 |
<td align="left" valign="top"> |
| 239 |
<p>When the program exits, Valgrind runs the procedure |
| 240 |
<code class="function">__libc_freeres</code> in glibc. This is a hook for |
| 241 |
memory debuggers, so they can ask glibc to free up any memory it has |
| 242 |
used. Doing that is needed to ensure that Valgrind doesn't |
| 243 |
incorrectly report space leaks in glibc.</p> |
| 244 |
<p>The problem is that running <code class="literal">__libc_freeres</code> in |
| 245 |
older glibc versions causes this crash.</p> |
| 246 |
<p>Workaround for 1.1.X and later versions of Valgrind: use the |
| 247 |
<code class="option">--run-libc-freeres=no</code> option. You may then get space |
| 248 |
leak reports for glibc allocations (please don't report these to |
| 249 |
the glibc people, since they are not real leaks), but at least the |
| 250 |
program runs.</p> |
| 251 |
</td> |
| 252 |
</tr> |
| 253 |
<tr><td colspan="2"> </td></tr> |
| 254 |
<tr class="question"> |
| 255 |
<td align="left" valign="top"> |
| 256 |
<a name="faq.bugdeath"></a><a name="q-bugdeath"></a><b>3.2.</b> |
| 257 |
</td> |
| 258 |
<td align="left" valign="top"> |
| 259 |
<b>My (buggy) program dies like this:</b><pre class="screen">valgrind: m_mallocfree.c:248 (get_bszB_as_is): Assertion 'bszB_lo == bszB_hi' failed.</pre> |
| 260 |
<b>or like this:</b><pre class="screen">valgrind: m_mallocfree.c:442 (mk_inuse_bszB): Assertion 'bszB != 0' failed.</pre> |
| 261 |
<b>or otherwise aborts or crashes in m_mallocfree.c.</b> |
| 262 |
</td> |
| 263 |
</tr> |
| 264 |
<tr class="answer"> |
| 265 |
<td align="left" valign="top"><a name="a-bugdeath"></a></td> |
| 266 |
<td align="left" valign="top"><p>If Memcheck (the memory checker) shows any invalid reads, |
| 267 |
invalid writes or invalid frees in your program, the above may |
| 268 |
happen. Reason is that your program may trash Valgrind's low-level |
| 269 |
memory manager, which then dies with the above assertion, or |
| 270 |
something similar. The cure is to fix your program so that it |
| 271 |
doesn't do any illegal memory accesses. The above failure will |
| 272 |
hopefully go away after that.</p></td> |
| 273 |
</tr> |
| 274 |
<tr><td colspan="2"> </td></tr> |
| 275 |
<tr class="question"> |
| 276 |
<td align="left" valign="top"> |
| 277 |
<a name="faq.msgdeath"></a><a name="q-msgdeath"></a><b>3.3.</b> |
| 278 |
</td> |
| 279 |
<td align="left" valign="top"> |
| 280 |
<b>My program dies, printing a message like this along the |
| 281 |
way:</b><pre class="screen">vex x86->IR: unhandled instruction bytes: 0x66 0xF 0x2E 0x5</pre> |
| 282 |
</td> |
| 283 |
</tr> |
| 284 |
<tr class="answer"> |
| 285 |
<td align="left" valign="top"><a name="a-msgdeath"></a></td> |
| 286 |
<td align="left" valign="top"> |
| 287 |
<p>One possibility is that your program has a bug and erroneously |
| 288 |
jumps to a non-code address, in which case you'll get a SIGILL signal. |
| 289 |
Memcheck may issue a warning just before this happens, but it might not |
| 290 |
if the jump happens to land in addressable memory.</p> |
| 291 |
<p>Another possibility is that Valgrind does not handle the |
| 292 |
instruction. If you are using an older Valgrind, a newer version might |
| 293 |
handle the instruction. However, all instruction sets have some |
| 294 |
obscure, rarely used instructions. Also, on amd64 there are an almost |
| 295 |
limitless number of combinations of redundant instruction prefixes, many |
| 296 |
of them undocumented but accepted by CPUs. So Valgrind will still have |
| 297 |
decoding failures from time to time. If this happens, please file a bug |
| 298 |
report.</p> |
| 299 |
</td> |
| 300 |
</tr> |
| 301 |
<tr><td colspan="2"> </td></tr> |
| 302 |
<tr class="question"> |
| 303 |
<td align="left" valign="top"> |
| 304 |
<a name="faq.java"></a><a name="q-java"></a><b>3.4.</b> |
| 305 |
</td> |
| 306 |
<td align="left" valign="top"><b>I tried running a Java program (or another program that uses a |
| 307 |
just-in-time compiler) under Valgrind but something went wrong. |
| 308 |
Does Valgrind handle such programs?</b></td> |
| 309 |
</tr> |
| 310 |
<tr class="answer"> |
| 311 |
<td align="left" valign="top"><a name="a-java"></a></td> |
| 312 |
<td align="left" valign="top"> |
| 313 |
<p>Valgrind can handle dynamically generated code, so long as |
| 314 |
none of the generated code is later overwritten by other generated |
| 315 |
code. If this happens, though, things will go wrong as Valgrind |
| 316 |
will continue running its translations of the old code (this is true |
| 317 |
on x86 and amd64, on PowerPC there are explicit cache flush |
| 318 |
instructions which Valgrind detects and honours). |
| 319 |
You should try running with |
| 320 |
<code class="option">--smc-check=all</code> in this case. Valgrind will run |
| 321 |
much more slowly, but should detect the use of the out-of-date |
| 322 |
code.</p> |
| 323 |
<p>Alternatively, if you have the source code to the JIT compiler |
| 324 |
you can insert calls to the |
| 325 |
<code class="computeroutput">VALGRIND_DISCARD_TRANSLATIONS</code> |
| 326 |
client request to mark out-of-date code, saving you from using |
| 327 |
<code class="option">--smc-check=all</code>.</p> |
| 328 |
<p>Apart from this, in theory Valgrind can run any Java program |
| 329 |
just fine, even those that use JNI and are partially implemented in |
| 330 |
other languages like C and C++. In practice, Java implementations |
| 331 |
tend to do nasty things that most programs do not, and Valgrind |
| 332 |
sometimes falls over these corner cases.</p> |
| 333 |
<p>If your Java programs do not run under Valgrind, even with |
| 334 |
<code class="option">--smc-check=all</code>, please file a bug report and |
| 335 |
hopefully we'll be able to fix the problem.</p> |
| 336 |
</td> |
| 337 |
</tr> |
| 338 |
</table> |
| 339 |
<br><table width="100%" summary="Q and A Div" cellpadding="2" cellspacing="2" border="0"> |
| 340 |
<tr class="qandadiv"><td align="left" valign="top" colspan="2"> |
| 341 |
<a name="faq.unexpected"></a><h3 class="title"> |
| 342 |
<a name="faq.unexpected"></a>4. Valgrind behaves unexpectedly</h3> |
| 343 |
</td></tr> |
| 344 |
<tr class="toc" colspan="2"><td align="left" valign="top" colspan="2">4.1. <a href="faq.html#faq.reports">My program uses the C++ STL and string classes. Valgrind |
| 345 |
reports 'still reachable' memory leaks involving these classes at |
| 346 |
the exit of the program, but there should be none.</a><br>4.2. <a href="faq.html#faq.unhelpful">The stack traces given by Memcheck (or another tool) aren't |
| 347 |
helpful. How can I improve them?</a><br>4.3. <a href="faq.html#faq.aliases">The stack traces given by Memcheck (or another tool) seem to |
| 348 |
have the wrong function name in them. What's happening?</a><br>4.4. <a href="faq.html#faq.crashes">My program crashes normally, but doesn't under Valgrind, or vice |
| 349 |
versa. What's happening?</a><br>4.5. <a href="faq.html#faq.hiddenbug"> Memcheck doesn't report any errors and I know my program has |
| 350 |
errors.</a><br>4.6. <a href="faq.html#faq.overruns">Why doesn't Memcheck find the array overruns in this |
| 351 |
program?</a><br>4.7. <a href="faq.html#faq.mismatches">Why does Memcheck report many |
| 352 |
"Mismatched free() / delete / delete []" errors when |
| 353 |
my code is correct?</a><br> |
| 354 |
</td></tr> |
| 355 |
<tr><td colspan="2"> </td></tr> |
| 356 |
<tr class="question"> |
| 357 |
<td align="left" valign="top"> |
| 358 |
<a name="faq.reports"></a><a name="q-reports"></a><b>4.1.</b> |
| 359 |
</td> |
| 360 |
<td align="left" valign="top"><b>My program uses the C++ STL and string classes. Valgrind |
| 361 |
reports 'still reachable' memory leaks involving these classes at |
| 362 |
the exit of the program, but there should be none.</b></td> |
| 363 |
</tr> |
| 364 |
<tr class="answer"> |
| 365 |
<td align="left" valign="top"><a name="a-reports"></a></td> |
| 366 |
<td align="left" valign="top"> |
| 367 |
<p>First of all: relax, it's probably not a bug, but a feature. |
| 368 |
Many implementations of the C++ standard libraries use their own |
| 369 |
memory pool allocators. Memory for quite a number of destructed |
| 370 |
objects is not immediately freed and given back to the OS, but kept |
| 371 |
in the pool(s) for later re-use. The fact that the pools are not |
| 372 |
freed at the exit of the program cause Valgrind to report this |
| 373 |
memory as still reachable. The behaviour not to free pools at the |
| 374 |
exit could be called a bug of the library though.</p> |
| 375 |
<p>Using GCC, you can force the STL to use malloc and to free |
| 376 |
memory as soon as possible by globally disabling memory caching. |
| 377 |
Beware! Doing so will probably slow down your program, sometimes |
| 378 |
drastically.</p> |
| 379 |
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "> |
| 380 |
<li class="listitem"><p>With GCC 2.91, 2.95, 3.0 and 3.1, compile all source using |
| 381 |
the STL with <code class="literal">-D__USE_MALLOC</code>. Beware! This was |
| 382 |
removed from GCC starting with version 3.3.</p></li> |
| 383 |
<li class="listitem"><p>With GCC 3.2.2 and later, you should export the |
| 384 |
environment variable <code class="literal">GLIBCPP_FORCE_NEW</code> before |
| 385 |
running your program.</p></li> |
| 386 |
<li class="listitem"><p>With GCC 3.4 and later, that variable has changed name to |
| 387 |
<code class="literal">GLIBCXX_FORCE_NEW</code>.</p></li> |
| 388 |
</ul></div> |
| 389 |
<p>There are other ways to disable memory pooling: using the |
| 390 |
<code class="literal">malloc_alloc</code> template with your objects (not |
| 391 |
portable, but should work for GCC) or even writing your own memory |
| 392 |
allocators. But all this goes beyond the scope of this FAQ. Start |
| 393 |
by reading |
| 394 |
<a class="ulink" href="http://gcc.gnu.org/onlinedocs/libstdc++/faq/index.html#4_4_leak" target="_top"> |
| 395 |
http://gcc.gnu.org/onlinedocs/libstdc++/faq/index.html#4_4_leak</a> |
| 396 |
if you absolutely want to do that. But beware: |
| 397 |
allocators belong to the more messy parts of the STL and |
| 398 |
people went to great lengths to make the STL portable across |
| 399 |
platforms. Chances are good that your solution will work on your |
| 400 |
platform, but not on others.</p> |
| 401 |
</td> |
| 402 |
</tr> |
| 403 |
<tr><td colspan="2"> </td></tr> |
| 404 |
<tr class="question"> |
| 405 |
<td align="left" valign="top"> |
| 406 |
<a name="faq.unhelpful"></a><a name="q-unhelpful"></a><b>4.2.</b> |
| 407 |
</td> |
| 408 |
<td align="left" valign="top"><b>The stack traces given by Memcheck (or another tool) aren't |
| 409 |
helpful. How can I improve them?</b></td> |
| 410 |
</tr> |
| 411 |
<tr class="answer"> |
| 412 |
<td align="left" valign="top"><a name="a-unhelpful"></a></td> |
| 413 |
<td align="left" valign="top"> |
| 414 |
<p>If they're not long enough, use <code class="option">--num-callers</code> |
| 415 |
to make them longer.</p> |
| 416 |
<p>If they're not detailed enough, make sure you are compiling |
| 417 |
with <code class="option">-g</code> to add debug information. And don't strip |
| 418 |
symbol tables (programs should be unstripped unless you run 'strip' |
| 419 |
on them; some libraries ship stripped).</p> |
| 420 |
<p>Also, for leak reports involving shared objects, if the shared object |
| 421 |
is unloaded before the program terminates, Valgrind will discard the debug |
| 422 |
information and the error message will be full of <code class="literal">???</code> |
| 423 |
entries. If you use the option <code class="option">--keep-debuginfo=yes</code>, then |
| 424 |
Valgrind will keep the debug information in order to show the stack traces, |
| 425 |
at the price of increased memory. An alternate workaround is to avoid |
| 426 |
calling <code class="function">dlclose</code> on these shared objects.</p> |
| 427 |
<p>Also, <code class="option">-fomit-frame-pointer</code> and |
| 428 |
<code class="option">-fstack-check</code> can make stack traces worse.</p> |
| 429 |
<p>Some example sub-traces:</p> |
| 430 |
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "> |
| 431 |
<li class="listitem"> |
| 432 |
<p>With debug information and unstripped (best):</p> |
| 433 |
<pre class="programlisting"> |
| 434 |
Invalid write of size 1 |
| 435 |
at 0x80483BF: really (malloc1.c:20) |
| 436 |
by 0x8048370: main (malloc1.c:9) |
| 437 |
</pre> |
| 438 |
</li> |
| 439 |
<li class="listitem"> |
| 440 |
<p>With no debug information, unstripped:</p> |
| 441 |
<pre class="programlisting"> |
| 442 |
Invalid write of size 1 |
| 443 |
at 0x80483BF: really (in /auto/homes/njn25/grind/head5/a.out) |
| 444 |
by 0x8048370: main (in /auto/homes/njn25/grind/head5/a.out) |
| 445 |
</pre> |
| 446 |
</li> |
| 447 |
<li class="listitem"> |
| 448 |
<p>With no debug information, stripped:</p> |
| 449 |
<pre class="programlisting"> |
| 450 |
Invalid write of size 1 |
| 451 |
at 0x80483BF: (within /auto/homes/njn25/grind/head5/a.out) |
| 452 |
by 0x8048370: (within /auto/homes/njn25/grind/head5/a.out) |
| 453 |
by 0x42015703: __libc_start_main (in /lib/tls/libc-2.3.2.so) |
| 454 |
by 0x80482CC: (within /auto/homes/njn25/grind/head5/a.out) |
| 455 |
</pre> |
| 456 |
</li> |
| 457 |
<li class="listitem"> |
| 458 |
<p>With debug information and -fomit-frame-pointer:</p> |
| 459 |
<pre class="programlisting"> |
| 460 |
Invalid write of size 1 |
| 461 |
at 0x80483C4: really (malloc1.c:20) |
| 462 |
by 0x42015703: __libc_start_main (in /lib/tls/libc-2.3.2.so) |
| 463 |
by 0x80482CC: ??? (start.S:81) |
| 464 |
</pre> |
| 465 |
</li> |
| 466 |
<li class="listitem"> |
| 467 |
<p>A leak error message involving an unloaded shared object:</p> |
| 468 |
<pre class="programlisting"> |
| 469 |
84 bytes in 1 blocks are possibly lost in loss record 488 of 713 |
| 470 |
at 0x1B9036DA: operator new(unsigned) (vg_replace_malloc.c:132) |
| 471 |
by 0x1DB63EEB: ??? |
| 472 |
by 0x1DB4B800: ??? |
| 473 |
by 0x1D65E007: ??? |
| 474 |
by 0x8049EE6: main (main.cpp:24) |
| 475 |
</pre> |
| 476 |
</li> |
| 477 |
</ul></div> |
| 478 |
</td> |
| 479 |
</tr> |
| 480 |
<tr><td colspan="2"> </td></tr> |
| 481 |
<tr class="question"> |
| 482 |
<td align="left" valign="top"> |
| 483 |
<a name="faq.aliases"></a><a name="q-aliases"></a><b>4.3.</b> |
| 484 |
</td> |
| 485 |
<td align="left" valign="top"><b>The stack traces given by Memcheck (or another tool) seem to |
| 486 |
have the wrong function name in them. What's happening?</b></td> |
| 487 |
</tr> |
| 488 |
<tr class="answer"> |
| 489 |
<td align="left" valign="top"><a name="a-aliases"></a></td> |
| 490 |
<td align="left" valign="top"><p>Occasionally Valgrind stack traces get the wrong function |
| 491 |
names. This is caused by glibc using aliases to effectively give |
| 492 |
one function two names. Most of the time Valgrind chooses a |
| 493 |
suitable name, but very occasionally it gets it wrong. Examples we know |
| 494 |
of are printing <code class="function">bcmp</code> instead of |
| 495 |
<code class="function">memcmp</code>, <code class="function">index</code> instead of |
| 496 |
<code class="function">strchr</code>, and <code class="function">rindex</code> instead of |
| 497 |
<code class="function">strrchr</code>.</p></td> |
| 498 |
</tr> |
| 499 |
<tr><td colspan="2"> </td></tr> |
| 500 |
<tr class="question"> |
| 501 |
<td align="left" valign="top"> |
| 502 |
<a name="faq.crashes"></a><a name="q-crashes"></a><b>4.4.</b> |
| 503 |
</td> |
| 504 |
<td align="left" valign="top"><b>My program crashes normally, but doesn't under Valgrind, or vice |
| 505 |
versa. What's happening?</b></td> |
| 506 |
</tr> |
| 507 |
<tr class="answer"> |
| 508 |
<td align="left" valign="top"><a name="a-crashes"></a></td> |
| 509 |
<td align="left" valign="top"> |
| 510 |
<p>When a program runs under Valgrind, its environment is slightly |
| 511 |
different to when it runs natively. For example, the memory layout is |
| 512 |
different, and the way that threads are scheduled is different.</p> |
| 513 |
<p>Most of the time this doesn't make any difference, but it can, |
| 514 |
particularly if your program is buggy. For example, if your program |
| 515 |
crashes because it erroneously accesses memory that is unaddressable, |
| 516 |
it's possible that this memory will not be unaddressable when run under |
| 517 |
Valgrind. Alternatively, if your program has data races, these may not |
| 518 |
manifest under Valgrind.</p> |
| 519 |
<p>There isn't anything you can do to change this, it's just the |
| 520 |
nature of the way Valgrind works that it cannot exactly replicate a |
| 521 |
native execution environment. In the case where your program crashes |
| 522 |
due to a memory error when run natively but not when run under Valgrind, |
| 523 |
in most cases Memcheck should identify the bad memory operation.</p> |
| 524 |
</td> |
| 525 |
</tr> |
| 526 |
<tr><td colspan="2"> </td></tr> |
| 527 |
<tr class="question"> |
| 528 |
<td align="left" valign="top"> |
| 529 |
<a name="faq.hiddenbug"></a><a name="q-hiddenbug"></a><b>4.5.</b> |
| 530 |
</td> |
| 531 |
<td align="left" valign="top"><b> Memcheck doesn't report any errors and I know my program has |
| 532 |
errors.</b></td> |
| 533 |
</tr> |
| 534 |
<tr class="answer"> |
| 535 |
<td align="left" valign="top"><a name="a-hiddenbug"></a></td> |
| 536 |
<td align="left" valign="top"> |
| 537 |
<p>There are two possible causes of this.</p> |
| 538 |
<p>First, by default, Valgrind only traces the top-level process. |
| 539 |
So if your program spawns children, they won't be traced by Valgrind |
| 540 |
by default. Also, if your program is started by a shell script, |
| 541 |
Perl script, or something similar, Valgrind will trace the shell, or |
| 542 |
the Perl interpreter, or equivalent.</p> |
| 543 |
<p>To trace child processes, use the |
| 544 |
<code class="option">--trace-children=yes</code> option.</p> |
| 545 |
<p>If you are tracing large trees of processes, it can be less |
| 546 |
disruptive to have the output sent over the network. Give Valgrind |
| 547 |
the option <code class="option">--log-socket=127.0.0.1:12345</code> (if you want |
| 548 |
logging output sent to port <code class="literal">12345</code> on |
| 549 |
<code class="literal">localhost</code>). You can use the valgrind-listener |
| 550 |
program to listen on that port:</p> |
| 551 |
<pre class="programlisting"> |
| 552 |
valgrind-listener 12345 |
| 553 |
</pre> |
| 554 |
<p>Obviously you have to start the listener process first. See |
| 555 |
the manual for more details.</p> |
| 556 |
<p>Second, if your program is statically linked, most Valgrind |
| 557 |
tools will only work well if they are able to replace certain |
| 558 |
functions, such as <code class="function">malloc</code>, with their own |
| 559 |
versions. By default, statically linked <code class="function">malloc |
| 560 |
functions</code> are not replaced. A key indicator of this is |
| 561 |
if Memcheck says: |
| 562 |
</p> |
| 563 |
<pre class="programlisting"> |
| 564 |
All heap blocks were freed -- no leaks are possible |
| 565 |
</pre> |
| 566 |
<p> |
| 567 |
when you know your program calls <code class="function">malloc</code>. The |
| 568 |
workaround is to use the option |
| 569 |
<code class="option">--soname-synonyms=somalloc=NONE</code> |
| 570 |
or to avoid statically linking your program.</p> |
| 571 |
<p>There will also be no replacement if you use an alternative |
| 572 |
<code class="function">malloc library</code> such as tcmalloc, jemalloc, |
| 573 |
... In such a case, the |
| 574 |
option <code class="option">--soname-synonyms=somalloc=zzzz</code> (where |
| 575 |
zzzz is the soname of the alternative malloc library) will allow |
| 576 |
Valgrind to replace the functions.</p> |
| 577 |
</td> |
| 578 |
</tr> |
| 579 |
<tr><td colspan="2"> </td></tr> |
| 580 |
<tr class="question"> |
| 581 |
<td align="left" valign="top"> |
| 582 |
<a name="faq.overruns"></a><a name="q-overruns"></a><b>4.6.</b> |
| 583 |
</td> |
| 584 |
<td align="left" valign="top"> |
| 585 |
<b>Why doesn't Memcheck find the array overruns in this |
| 586 |
program?</b><pre class="programlisting"> |
| 587 |
int static[5]; |
| 588 |
|
| 589 |
int main(void) |
| 590 |
{ |
| 591 |
int stack[5]; |
| 592 |
|
| 593 |
static[5] = 0; |
| 594 |
stack [5] = 0; |
| 595 |
|
| 596 |
return 0; |
| 597 |
} |
| 598 |
</pre> |
| 599 |
</td> |
| 600 |
</tr> |
| 601 |
<tr class="answer"> |
| 602 |
<td align="left" valign="top"><a name="a-overruns"></a></td> |
| 603 |
<td align="left" valign="top"><p>Unfortunately, Memcheck doesn't do bounds checking on global |
| 604 |
or stack arrays. We'd like to, but it's just not possible to do in |
| 605 |
a reasonable way that fits with how Memcheck works. Sorry.</p></td> |
| 606 |
</tr> |
| 607 |
<tr><td colspan="2"> </td></tr> |
| 608 |
<tr class="question"> |
| 609 |
<td align="left" valign="top"> |
| 610 |
<a name="faq.mismatches"></a><a name="q-mismatches"></a><b>4.7.</b> |
| 611 |
</td> |
| 612 |
<td align="left" valign="top"><b>Why does Memcheck report many |
| 613 |
"Mismatched free() / delete / delete []" errors when |
| 614 |
my code is correct?</b></td> |
| 615 |
</tr> |
| 616 |
<tr class="answer"> |
| 617 |
<td align="left" valign="top"><a name="a-mismatches"></a></td> |
| 618 |
<td align="left" valign="top"> |
| 619 |
<p>There are two possible causes of this.</p> |
| 620 |
<p>First, check if you are using an optimized build of Google |
| 621 |
tcmalloc (part of Google perftools). This library uses a single |
| 622 |
alias for free/scalar delete/array delete as an unmeasurable |
| 623 |
micro-optimization. There is simply no way for Memcheck to tell |
| 624 |
which of these was originally used. There are a few possible |
| 625 |
workarounds. |
| 626 |
</p> |
| 627 |
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "> |
| 628 |
<li class="listitem"><p>Build tcmalloc with "CPPFLAGS=-DTCMALLOC_NO_ALIASES" |
| 629 |
(best).</p></li> |
| 630 |
<li class="listitem"><p>Use a debug build of tcmalloc (debug builds turn off the alias |
| 631 |
micro-optimization).</p></li> |
| 632 |
<li class="listitem"><p>Do not link with tcmalloc for the builds that you use for |
| 633 |
Memcheck testing.</p></li> |
| 634 |
</ul></div> |
| 635 |
<p> |
| 636 |
</p> |
| 637 |
<p>Second, if you are replacing operator new or operator delete |
| 638 |
make sure that the compiler does not perform optimizations such as |
| 639 |
inlining on calls to these functions. Such optimizations can |
| 640 |
prevent Memcheck from correctly identifying the allocator or |
| 641 |
deallocator that is being used.</p> |
| 642 |
<p>The following two code snippets show how you can do this with |
| 643 |
GCC and LLVM (clang).</p> |
| 644 |
<pre class="programlisting"> |
| 645 |
// GCC |
| 646 |
void operator delete(void*) noexcept __attribute__((__externally_visible__)); |
| 647 |
</pre> |
| 648 |
<pre class="programlisting"> |
| 649 |
// LLVM (clang) |
| 650 |
__attribute__((__visibility__("default"))) void operator delete(void*) noexcept; |
| 651 |
</pre> |
| 652 |
<p>If all else fails, you might have to use "--show-mismatched-frees=no" |
| 653 |
</p> |
| 654 |
</td> |
| 655 |
</tr> |
| 656 |
</table> |
| 657 |
<br><table width="100%" summary="Q and A Div" cellpadding="2" cellspacing="2" border="0"> |
| 658 |
<tr class="qandadiv"><td align="left" valign="top" colspan="2"> |
| 659 |
<a name="faq.misc"></a><h3 class="title"> |
| 660 |
<a name="faq.misc"></a>5. Miscellaneous</h3> |
| 661 |
</td></tr> |
| 662 |
<tr class="toc" colspan="2"><td align="left" valign="top" colspan="2">5.1. <a href="faq.html#faq.writesupp">I tried writing a suppression but it didn't work. Can you |
| 663 |
write my suppression for me?</a><br>5.2. <a href="faq.html#faq.deflost">With Memcheck's memory leak detector, what's the |
| 664 |
difference between "definitely lost", "indirectly lost", "possibly |
| 665 |
lost", "still reachable", and "suppressed"?</a><br>5.3. <a href="faq.html#faq.undeferrors">Memcheck's uninitialised value errors are hard to track down, |
| 666 |
because they are often reported some time after they are caused. Could |
| 667 |
Memcheck record a trail of operations to better link the cause to the |
| 668 |
effect? Or maybe just eagerly report any copies of uninitialised |
| 669 |
memory values?</a><br>5.4. <a href="faq.html#faq.pcre2_qt">I'm developing a Qt application and I get huge numbers of "Conditional jump" |
| 670 |
errors. Is there anything that I can do about it?</a><br>5.5. <a href="faq.html#faq.attach">Is it possible to attach Valgrind to a program that is already |
| 671 |
running?</a><br> |
| 672 |
</td></tr> |
| 673 |
<tr><td colspan="2"> </td></tr> |
| 674 |
<tr class="question"> |
| 675 |
<td align="left" valign="top"> |
| 676 |
<a name="faq.writesupp"></a><a name="q-writesupp"></a><b>5.1.</b> |
| 677 |
</td> |
| 678 |
<td align="left" valign="top"><b>I tried writing a suppression but it didn't work. Can you |
| 679 |
write my suppression for me?</b></td> |
| 680 |
</tr> |
| 681 |
<tr class="answer"> |
| 682 |
<td align="left" valign="top"><a name="a-writesupp"></a></td> |
| 683 |
<td align="left" valign="top"> |
| 684 |
<p>Yes! Use the <code class="option">--gen-suppressions=yes</code> feature |
| 685 |
to spit out suppressions automatically for you. You can then edit |
| 686 |
them if you like, eg. combining similar automatically generated |
| 687 |
suppressions using wildcards like <code class="literal">'*'</code>.</p> |
| 688 |
<p>If you really want to write suppressions by hand, read the |
| 689 |
manual carefully. Note particularly that C++ function names must be |
| 690 |
mangled (that is, not demangled).</p> |
| 691 |
</td> |
| 692 |
</tr> |
| 693 |
<tr><td colspan="2"> </td></tr> |
| 694 |
<tr class="question"> |
| 695 |
<td align="left" valign="top"> |
| 696 |
<a name="faq.deflost"></a><a name="q-deflost"></a><b>5.2.</b> |
| 697 |
</td> |
| 698 |
<td align="left" valign="top"><b>With Memcheck's memory leak detector, what's the |
| 699 |
difference between "definitely lost", "indirectly lost", "possibly |
| 700 |
lost", "still reachable", and "suppressed"?</b></td> |
| 701 |
</tr> |
| 702 |
<tr class="answer"> |
| 703 |
<td align="left" valign="top"><a name="a-deflost"></a></td> |
| 704 |
<td align="left" valign="top"> |
| 705 |
<p>The details are in the Memcheck section of the user manual.</p> |
| 706 |
<p>In short:</p> |
| 707 |
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "> |
| 708 |
<li class="listitem"><p>"definitely lost" means your program is leaking memory -- |
| 709 |
fix those leaks!</p></li> |
| 710 |
<li class="listitem"><p>"indirectly lost" means your program is leaking memory in |
| 711 |
a pointer-based structure. (E.g. if the root node of a binary tree |
| 712 |
is "definitely lost", all the children will be "indirectly lost".) |
| 713 |
If you fix the "definitely lost" leaks, the "indirectly lost" leaks |
| 714 |
should go away. |
| 715 |
</p></li> |
| 716 |
<li class="listitem"><p>"possibly lost" means your program is leaking |
| 717 |
memory, unless you're doing unusual things with pointers that could |
| 718 |
cause them to point into the middle of an allocated block; see the |
| 719 |
user manual for some possible causes. Use |
| 720 |
<code class="option">--show-possibly-lost=no</code> if you don't want to see |
| 721 |
these reports.</p></li> |
| 722 |
<li class="listitem"><p>"still reachable" means your program is probably ok -- it |
| 723 |
didn't free some memory it could have. This is quite common and |
| 724 |
often reasonable. Don't use |
| 725 |
<code class="option">--show-reachable=yes</code> if you don't want to see |
| 726 |
these reports.</p></li> |
| 727 |
<li class="listitem"><p>"suppressed" means that a leak error has been suppressed. |
| 728 |
There are some suppressions in the default suppression files. |
| 729 |
You can ignore suppressed errors.</p></li> |
| 730 |
</ul></div> |
| 731 |
</td> |
| 732 |
</tr> |
| 733 |
<tr><td colspan="2"> </td></tr> |
| 734 |
<tr class="question"> |
| 735 |
<td align="left" valign="top"> |
| 736 |
<a name="faq.undeferrors"></a><a name="q-undeferrors"></a><b>5.3.</b> |
| 737 |
</td> |
| 738 |
<td align="left" valign="top"><b>Memcheck's uninitialised value errors are hard to track down, |
| 739 |
because they are often reported some time after they are caused. Could |
| 740 |
Memcheck record a trail of operations to better link the cause to the |
| 741 |
effect? Or maybe just eagerly report any copies of uninitialised |
| 742 |
memory values?</b></td> |
| 743 |
</tr> |
| 744 |
<tr class="answer"> |
| 745 |
<td align="left" valign="top"><a name="a-undeferrors"></a></td> |
| 746 |
<td align="left" valign="top"> |
| 747 |
<p>Prior to version 3.4.0, the answer was "we don't know how to do it |
| 748 |
without huge performance penalties". As of 3.4.0, try using the |
| 749 |
<code class="option">--track-origins=yes</code> option. It will run slower than |
| 750 |
usual, but will give you extra information about the origin of |
| 751 |
uninitialised values.</p> |
| 752 |
<p>Or if you want to do it the old fashioned way, you can use the |
| 753 |
client request |
| 754 |
<code class="computeroutput">VALGRIND_CHECK_VALUE_IS_DEFINED</code> to help |
| 755 |
track these errors down -- work backwards from the point where the |
| 756 |
uninitialised error occurs, checking suspect values until you find the |
| 757 |
cause. This requires editing, compiling and re-running your program |
| 758 |
multiple times, which is a pain, but still easier than debugging the |
| 759 |
problem without Memcheck's help.</p> |
| 760 |
<p>As for eager reporting of copies of uninitialised memory values, |
| 761 |
this has been suggested multiple times. Unfortunately, almost all |
| 762 |
programs legitimately copy uninitialised memory values around (because |
| 763 |
compilers pad structs to preserve alignment) and eager checking leads to |
| 764 |
hundreds of false positives. Therefore Memcheck does not support eager |
| 765 |
checking at this time.</p> |
| 766 |
</td> |
| 767 |
</tr> |
| 768 |
<tr><td colspan="2"> </td></tr> |
| 769 |
<tr class="question"> |
| 770 |
<td align="left" valign="top"> |
| 771 |
<a name="faq.pcre2_qt"></a><a name="q-pcre2_qt"></a><b>5.4.</b> |
| 772 |
</td> |
| 773 |
<td align="left" valign="top"><b>I'm developing a Qt application and I get huge numbers of "Conditional jump" |
| 774 |
errors. Is there anything that I can do about it?</b></td> |
| 775 |
</tr> |
| 776 |
<tr class="answer"> |
| 777 |
<td align="left" valign="top"><a name="a-pcre2_qt"></a></td> |
| 778 |
<td align="left" valign="top"> |
| 779 |
<p>Yes, there is a workaround. Here is an example error:</p> |
| 780 |
<pre class="programlisting"> |
| 781 |
Conditional jump or move depends on uninitialised value(s) |
| 782 |
at 0x1051C39B: ??? |
| 783 |
by 0x12657AA7: ??? |
| 784 |
</pre> |
| 785 |
<p>Qt Regular Expressions are built on the pcre2 library. |
| 786 |
pcre2 uses JITting which means that the errors cannot be suppressed |
| 787 |
(no function name). However, Qt provides a mechanism to turn off |
| 788 |
the use of JITting. To do so, use the following environment variable: |
| 789 |
<code class="computeroutput">export QT_ENABLE_REGEXP_JIT=0</code></p> |
| 790 |
</td> |
| 791 |
</tr> |
| 792 |
<tr><td colspan="2"> </td></tr> |
| 793 |
<tr class="question"> |
| 794 |
<td align="left" valign="top"> |
| 795 |
<a name="faq.attach"></a><a name="q-attach"></a><b>5.5.</b> |
| 796 |
</td> |
| 797 |
<td align="left" valign="top"><b>Is it possible to attach Valgrind to a program that is already |
| 798 |
running?</b></td> |
| 799 |
</tr> |
| 800 |
<tr class="answer"> |
| 801 |
<td align="left" valign="top"><a name="a-attach"></a></td> |
| 802 |
<td align="left" valign="top"> |
| 803 |
<p>No. The environment that Valgrind provides for running programs |
| 804 |
is significantly different to that for normal programs, e.g. due to |
| 805 |
different layout of memory. Therefore Valgrind has to have full control |
| 806 |
from the very start.</p> |
| 807 |
<p>It is possible to achieve something like this by running your |
| 808 |
program without any instrumentation (which involves a slow-down of about |
| 809 |
5x, less than that of most tools), and then adding instrumentation once |
| 810 |
you get to a point of interest. Support for this must be provided by |
| 811 |
the tool, however, and Callgrind is the only tool that currently has |
| 812 |
such support. See the instructions on the |
| 813 |
<code class="computeroutput">callgrind_control</code> program for details. |
| 814 |
</p> |
| 815 |
</td> |
| 816 |
</tr> |
| 817 |
</table> |
| 818 |
<br><table width="100%" summary="Q and A Div" cellpadding="2" cellspacing="2" border="0"> |
| 819 |
<tr class="qandadiv"><td align="left" valign="top" colspan="2"> |
| 820 |
<a name="faq.help"></a><h3 class="title"> |
| 821 |
<a name="faq.help"></a>6. How To Get Further Assistance</h3> |
| 822 |
</td></tr> |
| 823 |
<tr class="toc" colspan="2"><td align="left" valign="top" colspan="2">6.1. <a href="faq.html#e-help">Where can I get more help?</a><br> |
| 824 |
</td></tr> |
| 825 |
<tr><td colspan="2"> </td></tr> |
| 826 |
<tr class="question"> |
| 827 |
<td align="left" valign="top"> |
| 828 |
<a name="e-help"></a><a name="q-help"></a><b>6.1.</b> |
| 829 |
</td> |
| 830 |
<td align="left" valign="top"><b>Where can I get more help?</b></td> |
| 831 |
</tr> |
| 832 |
<tr class="answer"> |
| 833 |
<td align="left" valign="top"><a name="a-help"></a></td> |
| 834 |
<td align="left" valign="top"> |
| 835 |
<p>Read the appropriate section(s) of the |
| 836 |
<a class="ulink" href="http://www.valgrind.org/docs/manual/index.html" target="_top">Valgrind Documentation</a>.</p> |
| 837 |
<p><a class="ulink" href="http://search.gmane.org" target="_top">Search</a> the |
| 838 |
<a class="ulink" href="http://news.gmane.org/gmane.comp.debugging.valgrind" target="_top">valgrind-users</a> mailing list archives, using the group name |
| 839 |
<code class="computeroutput">gmane.comp.debugging.valgrind</code>.</p> |
| 840 |
<p>If you think an answer in this FAQ is incomplete or inaccurate, please |
| 841 |
e-mail <a class="ulink" href="mailto:[email protected]" target="_top">[email protected]</a>.</p> |
| 842 |
<p>If you have tried all of these things and are still |
| 843 |
stuck, you can try mailing the |
| 844 |
<a class="ulink" href="http://www.valgrind.org/support/mailing_lists.html" target="_top">valgrind-users mailing list</a>. |
| 845 |
Note that an email has a better change of being answered usefully if it is |
| 846 |
clearly written. Also remember that, despite the fact that most of the |
| 847 |
community are very helpful and responsive to emailed questions, you are |
| 848 |
probably requesting help from unpaid volunteers, so you have no guarantee |
| 849 |
of receiving an answer.</p> |
| 850 |
</td> |
| 851 |
</tr> |
| 852 |
</table> |
| 853 |
</div> |
| 854 |
</div> |
| 855 |
<div> |
| 856 |
<br><table class="nav" width="100%" cellspacing="3" cellpadding="2" border="0" summary="Navigation footer"> |
| 857 |
<tr> |
| 858 |
<td rowspan="2" width="40%" align="left"> |
| 859 |
<a accesskey="p" href="FAQ.html"><< Valgrind FAQ</a> </td> |
| 860 |
<td width="20%" align="center"><a accesskey="u" href="FAQ.html">Up</a></td> |
| 861 |
<td rowspan="2" width="40%" align="right"> <a accesskey="n" href="tech-docs.html">Valgrind Technical Documentation >></a> |
| 862 |
</td> |
| 863 |
</tr> |
| 864 |
<tr><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td></tr> |
| 865 |
</table> |
| 866 |
</div> |
| 867 |
</body> |
| 868 |
</html> |