blob: 720b6470230be14028ac3c4a655d9df4680ac88c [file] [log] [blame]
njn3e986b22004-11-30 10:43:45 +00001<?xml version="1.0"?> <!-- -*- sgml -*- -->
2<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
3 "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd"
4[ <!ENTITY % vg-entities SYSTEM "vg-entities.xml"> %vg-entities; ]>
5
de252c6142005-11-27 04:10:00 +00006
njn3e986b22004-11-30 10:43:45 +00007<book id="FAQ" xreflabel="Valgrind FAQ">
de53ad6842005-11-19 03:28:10 +00008
dee9b715c2005-08-03 20:28:33 +00009<bookinfo>
de53ad6842005-11-19 03:28:10 +000010 <title>Valgrind FAQ</title>
de53ad6842005-11-19 03:28:10 +000011 <releaseinfo>&rel-type; &rel-version; &rel-date;</releaseinfo>
de9bec93c2005-11-25 05:36:48 +000012 <copyright>
13 <year>&vg-lifespan;</year>
14 <holder><ulink url="&vg-developers;">Valgrind Developers</ulink></holder>
15 </copyright>
debad57fc2005-12-03 22:33:29 +000016 <legalnotice>
17 <para>Email: <ulink url="mailto:&vg-vemail;">&vg-vemail;</ulink></para>
18 </legalnotice>
dee9b715c2005-08-03 20:28:33 +000019</bookinfo>
njn3e986b22004-11-30 10:43:45 +000020
de53ad6842005-11-19 03:28:10 +000021
de252c6142005-11-27 04:10:00 +000022<article id="faq">
de9bec93c2005-11-25 05:36:48 +000023<title>Valgrind Frequently Asked Questions</title>
24
25
26<!-- FAQ starts here -->
27<qandaset>
28
29
30<!-- Background -->
31<qandadiv id="faq.background" xreflabel="Background">
njn3e986b22004-11-30 10:43:45 +000032<title>Background</title>
33
njn3e986b22004-11-30 10:43:45 +000034<qandaentry id="faq.pronounce">
de9bec93c2005-11-25 05:36:48 +000035 <question id="q-pronounce">
njn3e986b22004-11-30 10:43:45 +000036 <para>How do you pronounce "Valgrind"?</para>
37 </question>
de9bec93c2005-11-25 05:36:48 +000038 <answer id="a-pronounce">
debad57fc2005-12-03 22:33:29 +000039 <para>The "Val" as in the world "value". The "grind" is pronounced
40 with a short 'i' -- ie. "grinned" (rhymes with "tinned") rather than
41 "grined" (rhymes with "find").</para> <para>Don't feel bad: almost
42 everyone gets it wrong at first.</para>
njn3e986b22004-11-30 10:43:45 +000043 </answer>
44</qandaentry>
45
46<qandaentry id="faq.whence">
de9bec93c2005-11-25 05:36:48 +000047 <question id="q-whence">
njn3e986b22004-11-30 10:43:45 +000048 <para>Where does the name "Valgrind" come from?</para>
49 </question>
de9bec93c2005-11-25 05:36:48 +000050 <answer id="a-whence">
debad57fc2005-12-03 22:33:29 +000051
52 <para>From Nordic mythology. Originally (before release) the project
53 was named Heimdall, after the watchman of the Nordic gods. He could
54 "see a hundred miles by day or night, hear the grass growing, see the
55 wool growing on a sheep's back" (etc). This would have been a great
56 name, but it was already taken by a security package "Heimdal".</para>
57
58 <para>Keeping with the Nordic theme, Valgrind was chosen. Valgrind is
59 the name of the main entrance to Valhalla (the Hall of the Chosen
60 Slain in Asgard). Over this entrance there resides a wolf and over it
61 there is the head of a boar and on it perches a huge eagle, whose eyes
62 can see to the far regions of the nine worlds. Only those judged
63 worthy by the guardians are allowed to pass through Valgrind. All
64 others are refused entrance.</para>
65
66 <para>It's not short for "value grinder", although that's not a bad
67 guess.</para>
njn3e986b22004-11-30 10:43:45 +000068 </answer>
69 </qandaentry>
70
de9bec93c2005-11-25 05:36:48 +000071</qandadiv>
njn3e986b22004-11-30 10:43:45 +000072
73
de9bec93c2005-11-25 05:36:48 +000074
75<!-- Compiling, Installing and Configuring -->
76<qandadiv id="faq.installing" xreflabel="Compiling, installing and configuring">
njn3e986b22004-11-30 10:43:45 +000077<title>Compiling, installing and configuring</title>
njn3e986b22004-11-30 10:43:45 +000078
79<qandaentry id="faq.make_dies">
de9bec93c2005-11-25 05:36:48 +000080 <question id="q-make_dies">
njn3e986b22004-11-30 10:43:45 +000081 <para>When I trying building Valgrind, 'make' dies partway with
de9bec93c2005-11-25 05:36:48 +000082 an assertion failure, something like this:</para>
njn3e986b22004-11-30 10:43:45 +000083<screen>
84% make: expand.c:489: allocated_variable_append:
85 Assertion 'current_variable_set_list->next != 0' failed.
86</screen>
njn3e986b22004-11-30 10:43:45 +000087 </question>
de9bec93c2005-11-25 05:36:48 +000088 <answer id="a-make_dies">
debad57fc2005-12-03 22:33:29 +000089 <para>It's probably a bug in 'make'. Some, but not all, instances of
90 version 3.79.1 have this bug, see
91 www.mail-archive.com/bug-make@gnu.org/msg01658.html. Try upgrading to
92 a more recent version of 'make'. Alternatively, we have heard that
93 unsetting the CFLAGS environment variable avoids the problem.</para>
njn3e986b22004-11-30 10:43:45 +000094 </answer>
95</qandaentry>
96
njna874ef42006-04-06 14:04:48 +000097<qandaentry id="faq.glibc_devel">
98 <question>
99 <para>When I try to build Valgrind, 'make' fails with
100<programlisting>
101/usr/bin/ld: cannot find -lc
102collect2: ld returned 1 exit status
103</programlisting>
104 </para>
105 </question>
106 <answer>
107 <para>You need to install the glibc-static-devel package.</para>
108 </answer>
109</qandaentry>
njn3e986b22004-11-30 10:43:45 +0000110
njna874ef42006-04-06 14:04:48 +0000111</qandadiv>
njn3e986b22004-11-30 10:43:45 +0000112
113
de9bec93c2005-11-25 05:36:48 +0000114<!-- Valgrind aborts unexpectedly -->
115<qandadiv id="faq.abort" xreflabel="Valgrind aborts unexpectedly">
njn3e986b22004-11-30 10:43:45 +0000116<title>Valgrind aborts unexpectedly</title>
njn3e986b22004-11-30 10:43:45 +0000117
118<qandaentry id="faq.exit_errors">
debad57fc2005-12-03 22:33:29 +0000119 <question id="q-exit_errors">
120 <para>Programs run OK on Valgrind, but at exit produce a bunch of
121 errors involving <literal>__libc_freeres()</literal> and then die
122 with a segmentation fault.</para>
123 </question>
124 <answer id="a-exit_errors">
125 <para>When the program exits, Valgrind runs the procedure
126 <function>__libc_freeres()</function> in glibc. This is a hook for
127 memory debuggers, so they can ask glibc to free up any memory it has
128 used. Doing that is needed to ensure that Valgrind doesn't
129 incorrectly report space leaks in glibc.</para>
130
131 <para>Problem is that running <literal>__libc_freeres()</literal> in
132 older glibc versions causes this crash.</para>
133
134 <para>WORKAROUND FOR 1.1.X and later versions of Valgrind: use the
135 <option>--run-libc-freeres=no</option> flag. You may then get space
136 leak reports for glibc-allocations (please _don't_ report these to
137 the glibc people, since they are not real leaks), but at least the
138 program runs.</para>
139 </answer>
njn3e986b22004-11-30 10:43:45 +0000140</qandaentry>
141
142<qandaentry id="faq.bugdeath">
debad57fc2005-12-03 22:33:29 +0000143 <question id="q-bugdeath">
144 <para>My (buggy) program dies like this:</para>
de9bec93c2005-11-25 05:36:48 +0000145<screen>% valgrind: vg_malloc2.c:442 (bszW_to_pszW): Assertion 'pszW >= 0' failed.</screen>
debad57fc2005-12-03 22:33:29 +0000146 </question>
147 <answer id="a-bugdeath">
148 <para>If Memcheck (the memory checker) shows any invalid reads,
149 invalid writes and invalid frees in your program, the above may
150 happen. Reason is that your program may trash Valgrind's low-level
151 memory manager, which then dies with the above assertion, or
152 something like this. The cure is to fix your program so that it
153 doesn't do any illegal memory accesses. The above failure will
154 hopefully go away after that.</para>
155 </answer>
njn3e986b22004-11-30 10:43:45 +0000156</qandaentry>
157
158<qandaentry id="faq.msgdeath">
debad57fc2005-12-03 22:33:29 +0000159 <question id="q-msgdeath">
160 <para>My program dies, printing a message like this along the
njn3e986b22004-11-30 10:43:45 +0000161 way:</para>
de9bec93c2005-11-25 05:36:48 +0000162<screen>% disInstr: unhandled instruction bytes: 0x66 0xF 0x2E 0x5</screen>
debad57fc2005-12-03 22:33:29 +0000163 </question>
164 <answer id="a-msgdeath">
165 <para>Older versions did not support some x86 instructions,
166 particularly SSE/SSE2 instructions. Try a newer Valgrind; we now
167 support almost all instructions. If it still happens with newer
168 versions, if the failing instruction is an SSE/SSE2 instruction, you
169 might be able to recompile your program without it by using the flag
170 <option>-march</option> to gcc. Either way, let us know and we'll
171 try to fix it.</para>
njn3e986b22004-11-30 10:43:45 +0000172
debad57fc2005-12-03 22:33:29 +0000173 <para>Another possibility is that your program has a bug and
174 erroneously jumps to a non-code address, in which case you'll get a
njn1d0825f2006-03-27 11:37:07 +0000175 SIGILL signal. Memcheck may issue a warning just before
debad57fc2005-12-03 22:33:29 +0000176 this happens, but they might not if the jump happens to land in
177 addressable memory.</para>
178 </answer>
njn3e986b22004-11-30 10:43:45 +0000179</qandaentry>
180
njndde37b42005-10-06 18:58:33 +0000181<qandaentry id="faq.java">
debad57fc2005-12-03 22:33:29 +0000182 <question id="q-java">
183 <para>I tried running a Java program (or another program that uses a
184 just-in-time compiler) under Valgrind but something went wrong.
185 Does Valgrind handle such programs?</para>
186 </question>
187 <answer id="a-java">
188 <para>Valgrind can handle dynamically generated code, so long as
189 none of the generated code is later overwritten by other generated
190 code. If this happens, though, things will go wrong as Valgrind
191 will continue running its translations of the old code (this is true
192 on x86 and AMD64, on PPC32 there are explicit cache flush
193 instructions which Valgrind detects). You should try running with
194 <option>--smc-check=all</option> in this case; Valgrind will run
195 much more slowly, but should detect the use of the out-of-date
196 code.</para>
197
198 <para>Alternativaly, if you have the source code to the JIT compiler
199 you can insert calls to the
200 <computeroutput>VALGRIND_DISCARD_TRANSLATIONS</computeroutput>
201 client request to mark out-of-date code, saving you from using
202 <option>--smc-check=all</option>.</para>
203
204 <para>Apart from this, in theory Valgrind can run any Java program
205 just fine, even those that use JNI and are partially implemented in
206 other languages like C and C++. In practice, Java implementations
207 tend to do nasty things that most programs do not, and Valgrind
208 sometimes falls over these corner cases.</para>
209
210 <para>If your Java programs do not run under Valgrind, even with
211 <option>--smc-check=all</option>, please file a bug report and
212 hopefully we'll be able to fix the problem.</para>
213 </answer>
njndde37b42005-10-06 18:58:33 +0000214</qandaentry>
215
de9bec93c2005-11-25 05:36:48 +0000216</qandadiv>
njn3e986b22004-11-30 10:43:45 +0000217
218
de9bec93c2005-11-25 05:36:48 +0000219<!-- Valgrind behaves unexpectedly -->
220<qandadiv id="faq.unexpected" xreflabel="Valgrind behaves unexpectedly">
njn3e986b22004-11-30 10:43:45 +0000221<title>Valgrind behaves unexpectedly</title>
njn3e986b22004-11-30 10:43:45 +0000222
njn3e986b22004-11-30 10:43:45 +0000223<qandaentry id="faq.reports">
debad57fc2005-12-03 22:33:29 +0000224 <question id="q-reports">
225 <para>My program uses the C++ STL and string classes. Valgrind
226 reports 'still reachable' memory leaks involving these classes at
227 the exit of the program, but there should be none.</para>
228 </question>
229 <answer id="a-reports">
230 <para>First of all: relax, it's probably not a bug, but a feature.
231 Many implementations of the C++ standard libraries use their own
232 memory pool allocators. Memory for quite a number of destructed
233 objects is not immediately freed and given back to the OS, but kept
234 in the pool(s) for later re-use. The fact that the pools are not
235 freed at the exit() of the program cause Valgrind to report this
236 memory as still reachable. The behaviour not to free pools at the
237 exit() could be called a bug of the library though.</para>
njn3e986b22004-11-30 10:43:45 +0000238
debad57fc2005-12-03 22:33:29 +0000239 <para>Using gcc, you can force the STL to use malloc and to free
240 memory as soon as possible by globally disabling memory caching.
241 Beware! Doing so will probably slow down your program, sometimes
242 drastically.</para>
243 <itemizedlist>
244 <listitem>
245 <para>With gcc 2.91, 2.95, 3.0 and 3.1, compile all source using
246 the STL with <literal>-D__USE_MALLOC</literal>. Beware! This is
247 removed from gcc starting with version 3.3.</para>
248 </listitem>
249 <listitem>
250 <para>With gcc 3.2.2 and later, you should export the
251 environment variable <literal>GLIBCPP_FORCE_NEW</literal> before
252 running your program.</para>
253 </listitem>
254 <listitem>
255 <para>With gcc 3.4 and later, that variable has changed name to
256 <literal>GLIBCXX_FORCE_NEW</literal>.</para>
257 </listitem>
258 </itemizedlist>
njn3e986b22004-11-30 10:43:45 +0000259
debad57fc2005-12-03 22:33:29 +0000260 <para>There are other ways to disable memory pooling: using the
261 <literal>malloc_alloc</literal> template with your objects (not
262 portable, but should work for gcc) or even writing your own memory
263 allocators. But all this goes beyond the scope of this FAQ. Start
264 by reading
265 <ulink url="http://gcc.gnu.org/onlinedocs/libstdc++/ext/howto.html#3">
266 http://gcc.gnu.org/onlinedocs/libstdc++/ext/howto.html#3</ulink> if
267 you absolutely want to do that. But beware:</para>
njn3e986b22004-11-30 10:43:45 +0000268
debad57fc2005-12-03 22:33:29 +0000269 <orderedlist>
270 <listitem>
271 <para>there are currently changes underway for gcc which are not
272 totally reflected in the docs right now ("now" == 26 Apr 03)</para>
273 </listitem>
274 <listitem>
275 <para>allocators belong to the more messy parts of the STL and
276 people went to great lengths to make it portable across
277 platforms. Chances are good that your solution will work on your
278 platform, but not on others.</para>
279 </listitem>
280 </orderedlist>
njn3e986b22004-11-30 10:43:45 +0000281 </answer>
282</qandaentry>
283
284
285<qandaentry id="faq.unhelpful">
debad57fc2005-12-03 22:33:29 +0000286 <question id="q-unhelpful">
287 <para>The stack traces given by Memcheck (or another tool) aren't
288 helpful. How can I improve them?</para>
289 </question>
290 <answer id="a-unhelpful">
291 <para>If they're not long enough, use <option>--num-callers</option>
292 to make them longer.</para>
njn3e986b22004-11-30 10:43:45 +0000293
debad57fc2005-12-03 22:33:29 +0000294 <para>If they're not detailed enough, make sure you are compiling
295 with <option>-g</option> to add debug information. And don't strip
296 symbol tables (programs should be unstripped unless you run 'strip'
297 on them; some libraries ship stripped).</para>
njn0211ff32005-05-15 14:49:24 +0000298
debad57fc2005-12-03 22:33:29 +0000299 <para>Also, for leak reports involving shared objects, if the shared
300 object is unloaded before the program terminates, Valgrind will
301 discard the debug information and the error message will be full of
302 <literal>???</literal> entries. The workaround here is to avoid
303 calling dlclose() on these shared objects.</para>
304
305 <para>Also, <option>-fomit-frame-pointer</option> and
306 <option>-fstack-check</option> can make stack traces worse.</para>
njn3e986b22004-11-30 10:43:45 +0000307
308 <para>Some example sub-traces:</para>
309
njn15d7c342005-09-30 01:43:32 +0000310 <itemizedlist>
311 <listitem>
312 <para>With debug information and unstripped (best):</para>
njn3e986b22004-11-30 10:43:45 +0000313<programlisting>
314Invalid write of size 1
315 at 0x80483BF: really (malloc1.c:20)
316 by 0x8048370: main (malloc1.c:9)
317</programlisting>
njn15d7c342005-09-30 01:43:32 +0000318 </listitem>
njn3e986b22004-11-30 10:43:45 +0000319
njn15d7c342005-09-30 01:43:32 +0000320 <listitem>
321 <para>With no debug information, unstripped:</para>
njn3e986b22004-11-30 10:43:45 +0000322<programlisting>
323Invalid write of size 1
324 at 0x80483BF: really (in /auto/homes/njn25/grind/head5/a.out)
325 by 0x8048370: main (in /auto/homes/njn25/grind/head5/a.out)
326</programlisting>
njn15d7c342005-09-30 01:43:32 +0000327 </listitem>
njn3e986b22004-11-30 10:43:45 +0000328
njn15d7c342005-09-30 01:43:32 +0000329 <listitem>
330 <para>With no debug information, stripped:</para>
njn3e986b22004-11-30 10:43:45 +0000331<programlisting>
332Invalid write of size 1
333 at 0x80483BF: (within /auto/homes/njn25/grind/head5/a.out)
334 by 0x8048370: (within /auto/homes/njn25/grind/head5/a.out)
335 by 0x42015703: __libc_start_main (in /lib/tls/libc-2.3.2.so)
336 by 0x80482CC: (within /auto/homes/njn25/grind/head5/a.out)
337</programlisting>
njn15d7c342005-09-30 01:43:32 +0000338 </listitem>
njn3e986b22004-11-30 10:43:45 +0000339
njn15d7c342005-09-30 01:43:32 +0000340 <listitem>
341 <para>With debug information and -fomit-frame-pointer:</para>
njn3e986b22004-11-30 10:43:45 +0000342<programlisting>
343Invalid write of size 1
344 at 0x80483C4: really (malloc1.c:20)
345 by 0x42015703: __libc_start_main (in /lib/tls/libc-2.3.2.so)
346 by 0x80482CC: ??? (start.S:81)
347</programlisting>
njn15d7c342005-09-30 01:43:32 +0000348 </listitem>
njn3e986b22004-11-30 10:43:45 +0000349
njn15d7c342005-09-30 01:43:32 +0000350 <listitem>
351 <para>A leak error message involving an unloaded shared object:</para>
njn0211ff32005-05-15 14:49:24 +0000352<programlisting>
35384 bytes in 1 blocks are possibly lost in loss record 488 of 713
354 at 0x1B9036DA: operator new(unsigned) (vg_replace_malloc.c:132)
355 by 0x1DB63EEB: ???
356 by 0x1DB4B800: ???
357 by 0x1D65E007: ???
358 by 0x8049EE6: main (main.cpp:24)
359</programlisting>
njn15d7c342005-09-30 01:43:32 +0000360 </listitem>
361 </itemizedlist>
njn0211ff32005-05-15 14:49:24 +0000362
njn3e986b22004-11-30 10:43:45 +0000363 </answer>
364</qandaentry>
365
njn16eeb4e2005-06-16 03:56:58 +0000366<qandaentry id="faq.aliases">
debad57fc2005-12-03 22:33:29 +0000367 <question id="q-aliases">
368 <para>The stack traces given by Memcheck (or another tool) seem to
369 have the wrong function name in them. What's happening?</para>
370 </question>
371 <answer id="a-aliases">
372 <para>Occasionally Valgrind stack traces get the wrong function
373 names. This is caused by glibc using aliases to effectively give
374 one function two names. Most of the time Valgrind chooses a
375 suitable name, but very occasionally it gets it wrong. Examples we
376 know of are printing 'bcmp' instead of 'memcmp', 'index' instead of
377 'strchr', and 'rindex' instead of 'strrchr'.</para>
378 </answer>
njn16eeb4e2005-06-16 03:56:58 +0000379</qandaentry>
380
de9bec93c2005-11-25 05:36:48 +0000381</qandadiv>
njn3e986b22004-11-30 10:43:45 +0000382
383
de9bec93c2005-11-25 05:36:48 +0000384
385<!-- Memcheck doesn't find my bug -->
386<qandadiv id="faq.notfound" xreflabel="Memcheck doesn't find my bug">
njn3e986b22004-11-30 10:43:45 +0000387<title>Memcheck doesn't find my bug</title>
njn3e986b22004-11-30 10:43:45 +0000388
389<qandaentry id="faq.hiddenbug">
debad57fc2005-12-03 22:33:29 +0000390 <question id="q-hiddenbug">
391 <para>I try running "valgrind --tool=memcheck my_program" and get
392 Valgrind's startup message, but I don't get any errors and I know my
393 program has errors.</para>
394 </question>
395 <answer id="a-hiddenbug">
396 <para>There are two possible causes of this.</para>
njna11b9b02005-03-27 17:05:08 +0000397
debad57fc2005-12-03 22:33:29 +0000398 <para>First, by default, Valgrind only traces the top-level process.
399 So if your program spawns children, they won't be traced by Valgrind
400 by default. Also, if your program is started by a shell script,
401 Perl script, or something similar, Valgrind will trace the shell, or
402 the Perl interpreter, or equivalent.</para>
njn3e986b22004-11-30 10:43:45 +0000403
debad57fc2005-12-03 22:33:29 +0000404 <para>To trace child processes, use the
405 <option>--trace-children=yes</option> option.</para>
njn3e986b22004-11-30 10:43:45 +0000406
debad57fc2005-12-03 22:33:29 +0000407 <para>If you are tracing large trees of processes, it can be less
408 disruptive to have the output sent over the network. Give Valgrind
409 the flag <option>--log-socket=127.0.0.1:12345</option> (if you want
410 logging output sent to <literal>port 12345</literal> on
411 <literal>localhost</literal>). You can use the valgrind-listener
412 program to listen on that port:</para>
njn3e986b22004-11-30 10:43:45 +0000413<programlisting>
414valgrind-listener 12345
415</programlisting>
416
debad57fc2005-12-03 22:33:29 +0000417 <para>Obviously you have to start the listener process first. See
418 the manual for more details.</para>
njna11b9b02005-03-27 17:05:08 +0000419
debad57fc2005-12-03 22:33:29 +0000420 <para>Second, if your program is statically linked, most Valgrind
421 tools won't work as well, because they won't be able to replace
422 certain functions, such as malloc(), with their own versions. A key
423 indicator of this is if Memcheck says:
njna11b9b02005-03-27 17:05:08 +0000424<programlisting>
njn5666ee62005-12-19 19:38:02 +0000425All heap blocks were freed -- no leaks are possible
njna11b9b02005-03-27 17:05:08 +0000426</programlisting>
debad57fc2005-12-03 22:33:29 +0000427 when you know your program calls malloc(). The workaround is to
428 avoid statically linking your program.</para>
429 </answer>
njn3e986b22004-11-30 10:43:45 +0000430</qandaentry>
431
432
433<qandaentry id="faq.overruns">
debad57fc2005-12-03 22:33:29 +0000434 <question id="q-overruns">
435 <para>Why doesn't Memcheck find the array overruns in this
436 program?</para>
njn3e986b22004-11-30 10:43:45 +0000437<programlisting>
438int static[5];
439
440int main(void)
441{
442 int stack[5];
443
444 static[5] = 0;
445 stack [5] = 0;
446
447 return 0;
448}
449</programlisting>
debad57fc2005-12-03 22:33:29 +0000450 </question>
451 <answer id="a-overruns">
452 <para>Unfortunately, Memcheck doesn't do bounds checking on static
453 or stack arrays. We'd like to, but it's just not possible to do in
454 a reasonable way that fits with how Memcheck works. Sorry.</para>
455 </answer>
njn3e986b22004-11-30 10:43:45 +0000456</qandaentry>
457
de9bec93c2005-11-25 05:36:48 +0000458</qandadiv>
njn3e986b22004-11-30 10:43:45 +0000459
460
de9bec93c2005-11-25 05:36:48 +0000461
462<!-- Miscellaneous -->
463<qandadiv id="faq.misc" xreflabel="Miscellaneous">
njn3e986b22004-11-30 10:43:45 +0000464<title>Miscellaneous</title>
njn3e986b22004-11-30 10:43:45 +0000465
466<qandaentry id="faq.writesupp">
debad57fc2005-12-03 22:33:29 +0000467 <question id="q-writesupp">
468 <para>I tried writing a suppression but it didn't work. Can you
469 write my suppression for me?</para>
470 </question>
471 <answer id="a-writesupp">
472 <para>Yes! Use the <option>--gen-suppressions=yes</option> feature
473 to spit out suppressions automatically for you. You can then edit
474 them if you like, eg. combining similar automatically generated
475 suppressions using wildcards like <literal>'*'</literal>.</para>
njn3e986b22004-11-30 10:43:45 +0000476
debad57fc2005-12-03 22:33:29 +0000477 <para>If you really want to write suppressions by hand, read the
478 manual carefully. Note particularly that C++ function names must be
479 <literal>_mangled_</literal>.</para>
480 </answer>
njn3e986b22004-11-30 10:43:45 +0000481</qandaentry>
482
483
484<qandaentry id="faq.deflost">
debad57fc2005-12-03 22:33:29 +0000485 <question id="q-deflost">
njn1d0825f2006-03-27 11:37:07 +0000486 <para>With Memcheck's memory leak detector, what's the
debad57fc2005-12-03 22:33:29 +0000487 difference between "definitely lost", "possibly lost", "still
488 reachable", and "suppressed"?</para>
489 </question>
490 <answer id="a-deflost">
491 <para>The details are in the Memcheck section of the user
492 manual.</para>
njn3e986b22004-11-30 10:43:45 +0000493
debad57fc2005-12-03 22:33:29 +0000494 <para>In short:</para>
495 <itemizedlist>
496 <listitem>
497 <para>"definitely lost" means your program is leaking memory --
498 fix it!</para>
499 </listitem>
500 <listitem>
501 <para>"possibly lost" means your program is probably leaking
502 memory, unless you're doing funny things with pointers.</para>
503 </listitem>
504 <listitem>
505 <para>"still reachable" means your program is probably ok -- it
506 didn't free some memory it could have. This is quite common and
507 often reasonable. Don't use
508 <option>--show-reachable=yes</option> if you don't want to see
509 these reports.</para>
510 </listitem>
511 <listitem>
512 <para>"suppressed" means that a leak error has been suppressed.
513 There are some suppressions in the default suppression files.
514 You can ignore suppressed errors.</para>
515 </listitem>
516 </itemizedlist>
517 </answer>
njn3e986b22004-11-30 10:43:45 +0000518</qandaentry>
519
njn3fdb3622006-10-20 22:16:57 +0000520<qandaentry id="faq.undeferrors">
521 <question id="q-undeferrors">
522 <para>Memcheck's uninitialised value errors are hard to track down,
523 because they are often reported some time after they are caused. Could
524 Memcheck record a trail of operations to better link the cause to the
525 effect? Or maybe just eagerly report any copies of uninitialised
526 memory values?</para>
527 </question>
528 <answer id="a-undeferrors">
529 <para>We'd love to improve these errors, but we don't know how to do it
530 without huge performance penalties.</para>
531
532 <para>You can use the client request
533 <computeroutput>VALGRIND_CHECK_VALUE_IS_DEFINED</computeroutput> to help
534 track these errors down -- work backwards from the point where the
535 uninitialised error occurs, checking suspect values until you find the
536 cause. This requires editing, compiling and re-running your program
537 multiple times, which is a pain, but still easier than debugging the
538 problem without Memcheck's help.</para>
539
540 <para>As for eager reporting of copies of uninitialised memory values,
541 this has been suggested multiple times. Unfortunately, almost all
542 programs legitimately copy uninitialise memory values around (because
543 compilers pad structs to preserve alignment) and eager checking leads to
544 hundreds of false positives. Therefore Memcheck does not support eager
545 checking at this time.</para>
546 </answer>
547</qandaentry>
548
549
de9bec93c2005-11-25 05:36:48 +0000550</qandadiv>
njn3e986b22004-11-30 10:43:45 +0000551
de9bec93c2005-11-25 05:36:48 +0000552
553
554<!-- Further Assistance -->
555<qandadiv id="faq.help" xreflabel="How To Get Further Assistance">
556<title>How To Get Further Assistance</title>
557
558<qandaentry id="e-help">
debad57fc2005-12-03 22:33:29 +0000559 <!-- <question><para/></question> -->
560 <answer id="a-help">
de9bec93c2005-11-25 05:36:48 +0000561 <para>Please read all of this section before posting.</para>
562
563 <para>If you think an answer is incomplete or inaccurate, please
564 e-mail <ulink url="mailto:&vg-vemail;">&vg-vemail;</ulink>.</para>
debad57fc2005-12-03 22:33:29 +0000565
de97ab7e72005-11-27 18:19:40 +0000566 <para>Read the appropriate section(s) of the
567 <ulink url="&vg-bookset;">Valgrind Documentation</ulink>.</para>
de9bec93c2005-11-25 05:36:48 +0000568
de97ab7e72005-11-27 18:19:40 +0000569 <para>Read the
570 <ulink url="&vg-dist-docs;">Distribution Documents</ulink>.</para>
de9bec93c2005-11-25 05:36:48 +0000571
572 <para><ulink url="http://search.gmane.org">Search</ulink> the
573 <ulink url="http://news.gmane.org/gmane.comp.debugging.valgrind">valgrind-users</ulink> mailing list archives, using the group name
574 <computeroutput>gmane.comp.debugging.valgrind</computeroutput>.</para>
575
debad57fc2005-12-03 22:33:29 +0000576 <para>Only when you have tried all of these things and are still
577 stuck, should you post to the
578 <ulink url="&vg-users-list;">valgrind-users mailing list</ulink>. In
579 which case, please read the following carefully. Making a complete
580 posting will greatly increase the chances that an expert or fellow
581 user reading it will have enough information and motivation to
582 reply.</para>
de9bec93c2005-11-25 05:36:48 +0000583
debad57fc2005-12-03 22:33:29 +0000584 <para>Make sure you give full details of the problem, including the
njn1ac2f0d2005-12-04 19:26:00 +0000585 full output of <computeroutput>valgrind -v &lt;your-prog&gt;</computeroutput>, if
debad57fc2005-12-03 22:33:29 +0000586 applicable. Also which Linux distribution you're using (Red Hat,
587 Debian, etc) and its version number.</para>
de9bec93c2005-11-25 05:36:48 +0000588
debad57fc2005-12-03 22:33:29 +0000589 <para>You are in little danger of making your posting too long unless
590 you include large chunks of Valgrind's (unsuppressed) output, so err
591 on the side of giving too much information.</para>
de9bec93c2005-11-25 05:36:48 +0000592
debad57fc2005-12-03 22:33:29 +0000593 <para>Clearly written subject lines and message bodies are
594 appreciated, too.</para>
de9bec93c2005-11-25 05:36:48 +0000595
596 <para>Finally, remember that, despite the fact that most of the
debad57fc2005-12-03 22:33:29 +0000597 community are very helpful and responsive to emailed questions, you
598 are probably requesting help from unpaid volunteers, so you have no
599 guarantee of receiving an answer.</para>
de9bec93c2005-11-25 05:36:48 +0000600</answer>
601
602</qandaentry>
603</qandadiv>
604
605
606<!-- FAQ ends here -->
njn3e986b22004-11-30 10:43:45 +0000607</qandaset>
de9bec93c2005-11-25 05:36:48 +0000608
njn3e986b22004-11-30 10:43:45 +0000609
610
611<!-- template
de9bec93c2005-11-25 05:36:48 +0000612<qandadiv id="faq.installing" xreflabel="Installing">
613<title>Installing</title>
njn3e986b22004-11-30 10:43:45 +0000614
de9bec93c2005-11-25 05:36:48 +0000615<qandaentry id="faq.problem">
616 <question id="q-problem">
njn3e986b22004-11-30 10:43:45 +0000617 <para></para>
618 </question>
de9bec93c2005-11-25 05:36:48 +0000619 <answer id="a-problem">
njn3e986b22004-11-30 10:43:45 +0000620 <para></para>
621 </answer>
622</qandaentry>
623
de9bec93c2005-11-25 05:36:48 +0000624</qandadiv>
njn3e986b22004-11-30 10:43:45 +0000625-->
626
de9bec93c2005-11-25 05:36:48 +0000627</article>
njn3e986b22004-11-30 10:43:45 +0000628
629</book>