83 Commits

Author SHA1 Message Date
Philippe Waroquiers
8f0961e770 Change default value for --keep-stacktraces has been changed to alloc-and-free
Default value changed following discussion on valdev.

Giving more information for errors with freed blocks can help
when investigating difficult problems (e.g. double free, programs
using 'cleanup list' collecting different types of memory, ...)

Regression tested on various setup (x86, ppc64, s390x, amd64, debian or fedora)

Tests that have only one exp files have been updated to use the output
of the new default value in their .exp file.

Tests having more than one exp file have been changed so as to
specify explicitely the previous clo default value (i.e. adding
 --keep-stacktraces=alloc-then-free in the vgtest file).

Possibly, some tests might fail on non tested platforms
(e.g. mips, macos, solaris, tilegx).
Fixes should be straightforward, using one of the above fix techniques.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15597
2015-08-29 10:45:26 +00:00
Florian Krohm
2c79dd79f5 New memcheck command line option: --expensive-definedness-check
Pertains to BZ #340392


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15594
2015-08-27 17:50:47 +00:00
Philippe Waroquiers
b6876b9917 Fix 350202 - Add limited param to 'monitor block_list'
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15540
2015-08-13 22:49:32 +00:00
Philippe Waroquiers
33089164fa * Memcheck:
- A new monitor command 'xb <addr> <len>' shows the validity bits
    of <len> bytes at <addr>. Below the validity bits, the byte
    values are shown using a layout similar to the GDB command
    'x /<len>xb <addr>'. The monitor command 'xb' is easier to use
    (in particular on little endian computers) when you need to associate
    byte data value with their corresponding validity bits.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15483
2015-08-04 19:11:03 +00:00
Philippe Waroquiers
5f8b8d6918 Small doc improvement: make more clear that --show-leak-kinds and --errors-for-leak-kinds
have an effect only for a full leak search.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14852
2015-01-05 17:00:54 +00:00
Julian Seward
7566a219b0 Memcheck: add a new flag, --show-mismatched-frees=no|yes [yes], to
optionally disable allocator/deallocator mismatch checking.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14336
2014-08-22 19:26:23 +00:00
Philippe Waroquiers
6629c56543 Add a new heuristic 'length64' to detect interior pointers
pointing at offset 64bit of a block, when the first 8 bytes contains
the block size - 8. This is e.g. used by sqlite3MemMalloc.

Patch by Matthias Schwarzott (with small modif)



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14179
2014-07-21 19:55:11 +00:00
Florian Krohm
0e951964ef Provide a back trace when a function argument of a known allocation
function is presumably negative. Fixes BZ 79311.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14157
2014-07-13 14:41:55 +00:00
Florian Krohm
9700389dd9 Document return value of VALGRIND_MAKE_MEM_DEFINED and friends.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14089
2014-06-23 21:23:44 +00:00
Philippe Waroquiers
7d40b140ac Following svn r13758 (bug 328711), some further similar fixes,
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13759
2013-12-12 23:19:13 +00:00
Mark Wielaard
546e8d2c5c Bug 328711 valgrind.1 manpage "memcheck options" section is badly generated
Add missing para tags inside listitems. (Miroslav Franc, mfranc@redhat.com)

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13758
2013-12-12 21:20:48 +00:00
Julian Seward
e2bff1c182 Merge the following revisions from 3_9_BRANCH to trunk:
r13682  Initial cut at 3.9.0 release notes.
r13683  Remove duplicate NEWS entries for 3.9.0.
r13689  Minor docs/NEWS fixes
r13690  Documentation updates for 3.9.0.
r13691  More documentation updates, re leak-checker changes
r13692  NEWS: Note increased max mem size.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13724
2013-11-29 23:08:28 +00:00
Philippe Waroquiers
619be966db Allow tools to provide some statistics in suppression list produced at the end
Option -v outputs a list of used suppressions. This only gives
the nr of times a suppression was used.
For a leak search, this only gives the nr of loss records that
have been suppressed, but it does not give additional needed details
to understand more precisely what has been suppressed
(i.e. nr of blocks and nr of bytes).

=> Add in the tool interface update_extra_suppression_use and
print_extra_suppression_info functions to allow the tool to record
additioonal use statistics for a suppression. These statistics
can be done depending on the error (and its data) which is suppressed.

Use this in memcheck for the leak suppressions, to maintain and output
the nr of blocks and bytes suppressed by a suppression during
the last leak search.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13651
2013-10-17 22:10:41 +00:00
Philippe Waroquiers
90902aaf13 Fix use of uninit heuristic set for monitor command
* initialise leak_check heuristic parameter in the leak_check monitor command
* show the default value (none heuristic) in the monitor help command
  (none value chosen as default as this gives a backward compatible
   behaviour).
* document the heuristic leak check parameter in memcheck manual
  monitor command section



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13631
2013-10-09 20:12:39 +00:00
Philippe Waroquiers
e2ba2f3671 add heuristics decreasing false possible "possible leaks" in c++ code.
The option --leak-check-heuristics=heur1,heur2,... can activate
various heuristics to decrease the number of false positive
"possible leaks" for C++ code. The available heuristics are
detecting valid interior pointers to std::stdstring, to new[] allocated
arrays with elements having destructors and to interior pointers pointing
to an inner part of a C++ object using multiple inheritance.

This fixes 280271 Valgrind reports possible memory leaks on still-reachable
std::string 

This has been tested on x86/amd64/ppc32/ppc64.

First performance measurements seems to show a neglectible impact on
the leak search.

More feedback welcome both on performance and functional aspects
(false positive 'possibly leaked' rate decrease and/or 
false negative 'possibly leaked' rate increase).

Note that the heuristic is not checking that the memory has been
allocated with "new" or "new[]", as it is expected that in some cases,
specific alloc fn are used for c++ objects instead of the standard new/new[].
If needed, we might add an option to check the alloc functions
to be new/new[].



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13582
2013-09-29 13:47:32 +00:00
Mark Wielaard
b81e3c86b6 Fix double 'the the' in documentation.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13363
2013-04-05 13:19:12 +00:00
Philippe Waroquiers
739ae0bcb6 Implement --keep-stacktraces=alloc|free|alloc-and-free|alloc-then-free|none
The option --keep-stacktraces controls which stack trace(s) to keep for
malloc'd and/or free'd blocks. This can be used to obtain more information
for 'use after free' errors or to decrease Valgrind memory and/or cpu usage
by recording less information for heap blocks.

This fixes 312913 Dangling pointers error should also report the alloc
stack trace.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13223
2013-01-12 19:53:08 +00:00
Philippe Waroquiers
1618b44d28 Fix 284540 and 307465
284540 Memcheck shouldn't count suppressions matching still-reachable allocations
307465 --show-possibly-lost=no should bring down the error count / exit code

Using the options --show-leak-kinds=kind1,kind2,.. and
--errors-for-leak-kinds=kind1,kind2,.., each leak kind (definite, indirect,
possible, reachable) can now be individually reported and/or counted as
an error.
In a leak suppression entry, an optional line 'match-leak-kinds:'
controls which leak kinds are suppressed by this entry.
This is a.o. useful to avoid definite leaks being "catched"
by a suppression entry aimed at suppressing possibly lost blocks.
Default behaviour is the same as 3.8.1

Old args (--show-reachable and --show-possibly-lost) are still accepted.

Addition of a new test (memcheck/tests/lks) testing the new args
and the new suppression line.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13170
2012-12-08 17:54:16 +00:00
Philippe Waroquiers
6ccb4c199e fix 299756 (for symmetry, --free-fill must be ignored for MEMPOOL_FREE and FREELIKE client requests).
Test program from goodell@mcs.anl.gov



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12560
2012-05-11 22:10:39 +00:00
Philippe Waroquiers
ce806ed31f (fixes bug 289939 wish: complete monitor cmd 'leak_check' with details
about leaked or reachable blocks)

This patch implements two new memcheck gdbserver monitor commands:
  block_list <loss_record_nr>
        after a leak search, shows the list of blocks of <loss_record_nr>
  who_points_at <addr> [<len>]
        shows places pointing inside <len> (default 1) bytes at <addr>
        (with len 1, only shows "start pointers" pointing exactly to <addr>,
         with len > 1, will also show "interior pointers")


Compiled and reg-tested on f12/x86, deb5/amd64, f16/ppc64.

The 'block_list' command is implemented on top of the 
lr_array/lc_chunks/lc_extras arrays used during the last leak search.
NB: no impact on the memory for the typical Valgrind usage where a leak
search is only done at the end of the run.
Printing the block_list of a loss record simply consists in scanning the
lc_chunks to find back the chunks corresponding to the loss record for which
block lists is requested.

The 'who_points_at' command is implemented by doing a scan similar to 
(but simpler than) the leak search scan.
lc_scan_memory has been enhanced to have a mode to search for a specific
address, rather than to search for all allocated blocks.
VG_(apply_to_GP_regs) has been enhanced to also provide the ThreadId and
register name in the callback function.

The patch touches multiple files (but most changes are easy/trivial or factorise
existing code).

Most significant changes are in memcheck/mc_leakcheck.c :
    * changed the LC_Extra struct to remember the clique for indirect leaks
      (size of structure not changed).
    * made lr_array a static global
    * changed lc_scan_memory:
        to have a search mode for a specific address (for who_points_at)
        (for leak search) to pass a 'current clique' in addition to the clique
         leader
         so as to have a proper clique hierarchy for indirectly leaked blocks.
    * print_results: reset values at the beginning of the print_result of the
      next leak search, rather than at the end of print_results of the previous
       leak search.
      This allows to continue showing the same info for loss records till a new
      leak search is done.
    * new function print_clique which recursively prints a group of leaked
      blocks, starting from the clique leader.
    * new function MC_(print_block_list) : calls print_clique for each clique
      leader found for the given loss record.
    * static void scan_memory_root_set : code extracted from
      MC_(detect_memory_leaks) (no relevant change)
    * void MC_(who_points_at) : calls scan_memory_root_set, lc_scan_memory
        and VG_(apply_to_GP_regs)(search_address_in_GP_reg) to search 
        pointers to the given address.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12357
2012-01-26 23:13:52 +00:00
Philippe Waroquiers
48046f6940 Added a new parameter to the memcheck 'leak_check' GDB monitor command
to let the user specify a max nr of loss records to output : on huge
applications, interactive display of a lot of records in gdb can
take a lot of time.


* mc_include.h : 
  - added UInt max_loss_records_output; to LeakCheckParams structure
  - avoid passing LeakCheckParams by struct copy.
* modified test gdbserver_tests/mcleak to test the new parameter
* mc_main.c : parse or set max_loss_records_output in leak_check cmd
  handling and calls.
* mc-manual.xml : document new leak_check parameter
* mc_leakcheck.c : 
  - extract printing rules logic in its own function
  - in print_results, if there is a limit in LeakCheckParam,
    compute from where the printing of loss records has to start

 



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12329
2012-01-14 13:53:13 +00:00
Julian Seward
ae9c958f70 Improvements in freelist handling for Memcheck. See #250065.
(Philippe Waroquiers, philippe.waroquiers@skynet.be)

This patch provides three improvements in the way the free list is 
handled in memcheck.

First improvement: a new command line option --freelist-big-blocks
(default 1000000) specifies the size of "free list big blocks". 
Such big blocks will be put on the free list, but will be re-cycled first
(i.e. in preference to block having a smaller size).
This fixes the bug https://bugs.kde.org/show_bug.cgi?id=250065.
Technically, the freed list is divided in two lists : small
and big blocks. Blocks are first released from the big block list.

Second improvement: the blocks of the freed list are re-cycled before
a new block is malloc-ed, not after a block is freed.
This gives better error messages for dangling pointer errors
when doing many frees without doing malloc between the frees.
(this does not uses more memory).

Third improvement: a block bigger than the free list volume will be
put in the free list (till a malloc is done, so as the needed memory
is not bigger than before) but will be put at the beginning of the
free list, rather than at the end. So, allocating then freeing such a
block does not cause any blocks in the free list to be released.

Results of the improvements above, with the new regression test
memcheck/test/big_blocks_freed_list: with the patch, 7 errors
are detected, 6 are giving the (correct) allocation stack.
Without the patch, only 6 errors are detected, 5 errors without
allocation stack, 1 with a (wrong) allocation stack.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12202
2011-10-22 19:48:57 +00:00
Julian Seward
97c113e7e0 valgrind and tool mon. cmds prefixes changes + doc fixes + new vgdb option
--cmd-time-out

* changed prefixes of Valgrind core monitor commands from vg. to v.
* removed prefixes of Tool monitor commands
* memcheck leak_check 'leakpossible' arg renamed to 'possibleleak'
* memcheck make_memory 'ifaddressabledefined' arg renamed to
'Definedifaddressable'
    (with uppercase D to avoid confusion with 'defined' arg).
* vgdb options
  - Some doc updates : more logical option order documentation,
       specify 'standalone' for options aimed at standalone usage.
  - added option --cmd-time-out for standalone vgdb
     (comment of Josef Weindendorfer, needed to interface with a callgrind GUI)
* updated tests according to the above.
* updated documentation according to the above.
* some additional minor doc fixes/clarifications

(Philippe Waroquiers, philippe.waroquiers@skynet.be).  Bug 214909
comment 111.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@11844
2011-06-28 08:20:39 +00:00
Julian Seward
5c1e65aa42 Memcheck:
* add delta leak checking functionality
* some editing of related manual sections
(Philippe Waroquiers, philippe.waroquiers@skynet.be).  Bug 214909
comment 105.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@11838
2011-06-26 12:41:33 +00:00
Julian Seward
e5bd8ec4c8 Minor documentation fixes for the GDB server. (Philippe Waroquiers,
philippe.waroquiers@skynet.be).  Bug 214909 comment 106.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@11834
2011-06-25 10:05:28 +00:00
Julian Seward
48d69a241a Move the GDBserver documentation from the "Valgrind core" chapter
to the "Valgrind core: advanced topics" chapter.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@11821
2011-06-17 08:31:22 +00:00
Julian Seward
2ee9e90486 Implement a GDB server in Valgrind. See #214909.
(Philippe Waroquiers, philippe.waroquiers@skynet.be)



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@11727
2011-05-06 21:02:55 +00:00
Julian Seward
47be27ff77 Fix minor documentation nits (Michael Snyder, msnyder@vmware.com)
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@11577
2011-02-28 10:26:42 +00:00
Julian Seward
a8ee66085e Fix up out of date documentation for VALGRIND_CREATE_BLOCK and
VALGRIND_DISCARD.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@11508
2011-01-22 11:21:58 +00:00
Nicholas Nethercote
71e0b2a3f8 Clarify some details about "possibly lost" heap blocks.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@11491
2011-01-04 23:46:07 +00:00
Julian Seward
b43eec1219 Documentation update for 3.6.0 (not including NEWS).
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@11440
2010-10-13 21:47:29 +00:00
Bart Van Assche
8122b2aaef Added new memcheck command-line option --show-possibly-lost. Closes #201170.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@11292
2010-08-26 10:56:27 +00:00
Nicholas Nethercote
226deeb16d Don't count leaks as errors with --leak-check=summary, because the results
can be confusing.  Document the behaviour.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@10798
2009-08-13 00:02:30 +00:00
Nicholas Nethercote
794810cd02 wibble
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@10762
2009-08-10 04:07:54 +00:00
Nicholas Nethercote
4e495edf4a Make "option" terminology consistent some more. Also tweaked the mempool
Memcheck section a little.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@10759
2009-08-10 01:29:14 +00:00
Nicholas Nethercote
439594978f Various fix-ups for Memcheck's manual chapter.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@10716
2009-08-05 06:34:27 +00:00
Nicholas Nethercote
8da3d6fbc0 Move command-line option details after the description of Memcheck's error
messages, since that's an order that will make more sense for a newbie.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@10715
2009-08-05 05:11:02 +00:00
Nicholas Nethercote
ec073bad3d Added documentation for --ignore-ranges. It's not very good, though, if
anyone can explain clearly why it's useful and wants to add that information
that would be helpful.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@10713
2009-08-05 04:57:44 +00:00
Nicholas Nethercote
e06d3b4893 Put Memcheck's command line options in the manual in the same order as its
usage message.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@10712
2009-08-05 04:54:51 +00:00
Nicholas Nethercote
daa35cac73 Various clean-ups, mostly in chapter 3.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@10705
2009-08-04 05:24:46 +00:00
Nicholas Nethercote
d5b384f852 Various manual fix-ups:
- Use "heap blocks" rather than "malloc'd blocks" as heap blocks covers
  calloc, realloc, new, new[], memalign, etc.

- Used "GDB" and "GCC" throughout rather than "gcc" and "gdb".

- Made various tag uses more consistent.

- Greatly clarified the instructions on --xml=yes and its friends.

- Lots of other little improvements and fixes to out-of-date things and
  Linux-centric things, mostly in Section 2.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@10701
2009-08-04 01:16:01 +00:00
Nicholas Nethercote
ac7761261a We currently use a mix of <option> and <computeroutput> tags for command
line options.  This commit changes them to all <option>.

Also make consistent how options with multiple names (eg. -h --help) are
shown.

Also, remove section describing --help and --version in Callgrind's chapter;
these aren't necessary and are presumably a hangover from when Callgrind was
a separate tool.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@10659
2009-07-30 02:57:52 +00:00
Nicholas Nethercote
78b2e5c83e Started overhauling the documentation:
- There were detailed descriptions of all the tools in the Quick Start
  Guide, the Manual introduction, and the start of each tool chapter.  To
  avoid duplication/overlap, I removed these altogether from the Quick Start
  Guide, and shortened them in the intro.

- Improved the description of what errors Memcheck can find.

- Made all tool chapters start with "Overview" section, for consistency.

- Made the "run with --tool=XXX" bit consistent in each tool chapter.

- Made all tool chapter titles match the description given when running them.

- Added BBV to the User Manual intro.

- Generally clarified, updated, and future-proofed various bits of text in
  the Quick Start Guide and User Manual introduction. 

Also:
- Changed Nulgrind's start-up description to "the minimal Valgrind tool".

- Fixed some punctuation in the usage message.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@10652
2009-07-29 02:36:21 +00:00
Bart Van Assche
b83aa02475 Fixed XML syntax.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@10487
2009-07-19 09:19:58 +00:00
Nicholas Nethercote
3758ff85e8 Add details about an interior-pointer case that can occur with C++.
Addresses bug 136230.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@10462
2009-07-15 07:18:16 +00:00
Nicholas Nethercote
7e075c243f Make --leak-resolution=high the default. Fixes bug 197929.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@10423
2009-07-10 08:16:29 +00:00
Bart Van Assche
06eb5d4a25 Applied the patch attached to http://bugs.kde.org/show_bug.cgi?id=165468: fixed some formatting inconsistencies.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@10381
2009-06-26 19:03:53 +00:00
Nicholas Nethercote
7f0f76c228 Fix some broken XML tags.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@9901
2009-05-18 23:03:52 +00:00
Nicholas Nethercote
28084aaff9 Tweak the Memcheck manual, fixing bug #157154 in the process.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@9341
2009-03-10 21:40:46 +00:00
Nicholas Nethercote
bafed25ae9 This commit completely overhauls the leak checker. In particular:
- It heavily refactors the code:  uses better names for things, splits up
  complex functions that behaved very differently depending on how they were
  called, removes some redundancies, and generally makes it much simpler and
  easier to follow.

- It adds lots of comments, both inline, and also a big explanatory one at
  the top which makes it clear exactly how the leak checker works and also
  exactly what is meant by definite, possible, and indirect leaks.  It also
  has some ideas for future improvements.

- All tabs have been converted to spaces.

It also improves the functionality:

- Previously if you did --leak-check=summary, indirect and suppressed
  blocks were counted as definite leaks.  Now they are done properly, and so
  the summary results from --leak-check=summary match those from
  --leak-check=yes.

- Previously, some possibly reachable blocks were miscategorised as
  definitely reachable, because only the pointer to the block itself was
  considered, not any preceding pointers in the chain.  This is now fixed.

- Added memcheck/tests/leak-cases, which fully tests all the possible
  combinations of directly/indirectly reachable and possibly/definitely
  reachable.

And it improves the manual quite a bit, and the FAQ a little bit.

This doesn't fix the leak checker to handle MALLOCLIKE_BLOCK works that have
been taken from within malloc'd blocks, but I think I know how to do it and
hope to do so in a subsequent commit.

It also changes all instances of "<constant>memcheck</constant>" in the
Memcheck manual to "Memcheck", for consistency and because "Memcheck" is
easier to write.  There's one similar case for DRD but I didn't change that.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@9330
2009-03-09 22:52:24 +00:00