History log of /external/valgrind/memcheck/mc_errors.c
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
f7ec77f53fd09a5682dbe6db049efe0746df7948 24-Nov-2014 philippe <philippe@a5019735-40e9-0310-863c-91ae7b9d1cf9> Change pub_tool_addrinfo.h AddrInfo and VG_(describe_addr) so as to describe
anonymous or file mmap-ed segments and shared memory segments.

* pub_tool_addrinfo.h:
new AddrTag Addr_SegmentKind // Client segment (mapped memory)
new struct SegmentKind in AddrInfo

* m_addrinfo.c:
If address is still undescribed, try to describe by findinf a client segment.

* update various tests

* mc_errors.c:
add a call to VG_(clear_addrinfo) in MC_(pp_describe_addr)
as the memory allocated in the local AddrInfo has to be cleared once
info is printed.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14779 a5019735-40e9-0310-863c-91ae7b9d1cf9
/external/valgrind/memcheck/mc_errors.c
8e3fbb5cd8276a7d07d5712bc05f9b3376d81a6a 20-Oct-2014 florian <florian@a5019735-40e9-0310-863c-91ae7b9d1cf9> Constify the tool interface.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14642 a5019735-40e9-0310-863c-91ae7b9d1cf9
/external/valgrind/memcheck/mc_errors.c
3e81b8bed1f7ab6848a83f5507487131a6f9d778 07-Oct-2014 florian <florian@a5019735-40e9-0310-863c-91ae7b9d1cf9> Merge revisions 14230, 14602, and 14604 from the BUF_REMOVAL branch to trunk.
The change eliminates the fixed size buffers in gen_suppression and
show_used_suppressions. This is achieved by changing the return type from
VG_TDICT_CALL(tool_get_extra_suppression_info and
VG_TDICT_CALL(tool_print_extra_suppression_use from Bool to SizeT.
A return value of 0 indicates that nothing (except the terminating '\0'
which is always inserted) was written to the buffer. This corresponds to the
previous False return value. A return value which is equal to the buffer
size (that was passed in as function argument) indicates that the buffer was
not large enough. The caller then resizes the buffer and retries.
Otherwise, the buffer was large enough.
Regtested with a resize value of 1.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14606 a5019735-40e9-0310-863c-91ae7b9d1cf9
/external/valgrind/memcheck/mc_errors.c
cf6e734a9f88b521a5116b7ca119b3a26aede1a8 28-Sep-2014 florian <florian@a5019735-40e9-0310-863c-91ae7b9d1cf9> Merge r14229 from the BUF_REMOVAL branch to trunk.
Function MC_(snprintf_delta) requires a buffer of size 31 or larger to
avoid overflow.Add an assert, change and document the buffer size and
fix all call sites. Remove magic constants along the way.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14583 a5019735-40e9-0310-863c-91ae7b9d1cf9
/external/valgrind/memcheck/mc_errors.c
659efdee5b18c6c0ca3e6a1ff395be813ebb4a72 12-Sep-2014 florian <florian@a5019735-40e9-0310-863c-91ae7b9d1cf9> Fix a memory leak found by IBM's BEAM checker.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14527 a5019735-40e9-0310-863c-91ae7b9d1cf9
/external/valgrind/memcheck/mc_errors.c
e4200b5083e7bb1b81cb98de1744a0c0f3663e56 02-Sep-2014 philippe <philippe@a5019735-40e9-0310-863c-91ae7b9d1cf9> Fix wrong operator = (instead of ==) in assertion
Assertion had a side effect (detected by Coverity)


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14435 a5019735-40e9-0310-863c-91ae7b9d1cf9
/external/valgrind/memcheck/mc_errors.c
ec905f7ed1659f2251045114c785659fbb11ea88 17-Aug-2014 philippe <philippe@a5019735-40e9-0310-863c-91ae7b9d1cf9> The attached patch cleanups the clo processing
of clo which are (or should be) 'enum set'.

* pub_tool_options.h : add new macrox VG_USET_CLO and VG_USETX_CLO to
parse an 'enum set' command line option (with or without "all" keyword).

* use VG_USET_CLO for existing enum set clo options:
memcheck --errors-for-leak-kinds, --show-leak-kinds, --leak-check-heuristics
coregrind --vgdb-stop-at

* change --sim-hints and --kernel-variants to enum set
(this allows to detect user typos: currently, a typo in a sim-hint
or kernel variant is silently ignored. Now, an error will be given
to the user)

* The 2 new sets (--sim-hints and --kernel-variants) should not make
use of the 'all' keyword => VG_(parse_enum_set) has a new argument
to enable/disable the use of the "all" keyword.

* The macros defining an 'all enum' set definition was duplicating
all enum values (so addition of a new enum value could easily
give a bug). Removing these macros as they are unused
(to the exception of the leak-kind set).
For this set, the 'all macro' has been replaced by an 'all function',
coded using parse_enum_set parsing the "all" keyword.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14301 a5019735-40e9-0310-863c-91ae7b9d1cf9
/external/valgrind/memcheck/mc_errors.c
0c9ac8d0deca2f2a552fb2b0cab24efe6191bac7 18-Jul-2014 philippe <philippe@a5019735-40e9-0310-863c-91ae7b9d1cf9> Patch adding (or showing the proper/not confusing) helgrind thread nr for block
and stack address description.

* A race condition on an allocated block shows the stacktrace, but
does not show the thread # that allocated the block.
This patch adds the output of the thread # that allocated the block.

* The patch also fixes the confusion that might appear between
the core threadid and the helgrind thread nr in Stack address description:
A printed stack addrinfo was containing a thread id, while all other helgrind
messages are using (supposed to use) an 'helgrind thread #' which
is used in the thread announcement.

Basically, the idea is to let a tool set a "tool specific thread nr'
in an addrinfo.
The pretty printing of the addrinfo is then by preference showing this
thread nr (if it was set, i.e. different of 0).
Currently, only helgrind uses this addrinfo tnr.

Note: in xml mode, the output is matching the protocol description.
I.e., GUI should not be impacted by this change, if they properly implement
the xml protocol.


* Also, make the output produced by m_addrinfo consistent:
The message 'block was alloc'd at' is changed to be like all other
output : one character indent, and starting with an uppercase



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14175 a5019735-40e9-0310-863c-91ae7b9d1cf9
/external/valgrind/memcheck/mc_errors.c
7b6899dd211aafa1e0d3e3a0dc0cf798ea882768 13-Jul-2014 florian <florian@a5019735-40e9-0310-863c-91ae7b9d1cf9> 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 a5019735-40e9-0310-863c-91ae7b9d1cf9
/external/valgrind/memcheck/mc_errors.c
6a90cfb1b6f4f8ab35295e316b3cba5b18418f1b 26-Jun-2014 florian <florian@a5019735-40e9-0310-863c-91ae7b9d1cf9> Fix a couple of format string mixups.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14108 a5019735-40e9-0310-863c-91ae7b9d1cf9
/external/valgrind/memcheck/mc_errors.c
07c08527f05caeb0062b42ca9a58ee774ec5fba1 14-May-2014 philippe <philippe@a5019735-40e9-0310-863c-91ae7b9d1cf9> Factorises the address code description and printing
of memcheck and helgrind in a common module:
pub_tool_addrinfo.h pub_core_addrinfo.h m_addrinfo.c

At the same time, the factorised code is made usable by other
tools also (and is used by the gdbserver command 'v.info location'
which replaces the helgrind 'describe addr' introduced 1 week ago
and which is now callable by all tools).

The new address description code can describe more addresses
(e.g. for memcheck, if the block is not on the free list anymore,
but is in an arena free list, this will also be described).

Similarly, helgrind address description can now describe more addresses
when --read-var-info=no is given (e.g. global symbols are
described, or addresses on the stack are described as
being on the stack, freed blocks in the arena free list are
described, ...).
See e.g. the change in helgrind/tests/annotate_rwlock.stderr.exp
or locked_vs_unlocked2.stderr.exp

The patch touches many files, but is basically a lot of improvements
in helgrind output files.
The code changes are mostly refactorisation of existing code.




git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13965 a5019735-40e9-0310-863c-91ae7b9d1cf9
/external/valgrind/memcheck/mc_errors.c
6d0e77bd100add36475334b3451586582d179021 08-May-2014 philippe <philippe@a5019735-40e9-0310-863c-91ae7b9d1cf9> * document the %ps / %pS extensions to printf
* remove (from memcheck) emiN, as PRINTF_CHECK can be done properly


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13942 a5019735-40e9-0310-863c-91ae7b9d1cf9
/external/valgrind/memcheck/mc_errors.c
0c2923fb395e1dd3aa43e36d73a164e5718dcad6 19-Apr-2014 philippe <philippe@a5019735-40e9-0310-863c-91ae7b9d1cf9> Factorise enum set parsing code
* add a function Bool VG_(parse_enum_set) in pub_tool_libcbase.h/m_libcbase.c
(close to Bool VG_(parse_Addr)
* Implement Bool MC_(parse_leak_heuristics) and MC_(parse_leak_kinds)
as a call to VG_(parse_enum_set)



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13898 a5019735-40e9-0310-863c-91ae7b9d1cf9
/external/valgrind/memcheck/mc_errors.c
0f157ddb404bcde7815a1c5bf2d7e41c114f3d73 18-Oct-2013 sewardj <sewardj@a5019735-40e9-0310-863c-91ae7b9d1cf9> Update copyright dates (20XY-2012 ==> 20XY-2013)


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13658 a5019735-40e9-0310-863c-91ae7b9d1cf9
/external/valgrind/memcheck/mc_errors.c
4e32d67a5b880bf1d871c5141822078d4dcdc3ac 18-Oct-2013 philippe <philippe@a5019735-40e9-0310-863c-91ae7b9d1cf9> 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 a5019735-40e9-0310-863c-91ae7b9d1cf9
/external/valgrind/memcheck/mc_errors.c
362441db825242200142a91bb07c4a0300b36a3e 23-Jul-2013 philippe <philippe@a5019735-40e9-0310-863c-91ae7b9d1cf9> fix incorrect lineno in supp error msgs+ -v give filename+lineno of used supp.

If a suppression file contains an error, the lineno reported could be wrong.
Also, give filename and lineno of the used suppressions in -v debugging output.

The fix consists in ensuring that tool specific read_extra function gets
the Int* lineno pointer, together with other VG_(get_line) parameters.






git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13469 a5019735-40e9-0310-863c-91ae7b9d1cf9
/external/valgrind/memcheck/mc_errors.c
dfa54a53736ab016611db71c37b3e34a96d9f604 13-Mar-2013 philippe <philippe@a5019735-40e9-0310-863c-91ae7b9d1cf9> Fix 316535 Use of |signed int| instead of (unsigned) |size_t| in messages...
* when SEGV trapped, report the main thread size as an unsigned size_t
* Similar for memcheck overlap errors
For example, for the 2 calls:
memcpy(&a, &a, 2147483648UL);
memcpy(&a, &a, -1); // silently accepted by gcc 4.4.4 -Wall
// while the 3rd arg is supposed to be a size_t
we now obtain (on a 32 bit system)
Source and destination overlap in memcpy(0xbe97113f, 0xbe97113f, 2147483648)
Source and destination overlap in memcpy(0xbef6d13f, 0xbef6d13f, 4294967295)
instead of
Source and destination overlap in memcpy(0xbe8e012f, 0xbe8e012f, -2147483648)
Source and destination overlap in memcpy(0xbe8e012f, 0xbe8e012f, -1)

Do not ask me why
memcpy(&a, &a, -1);
is supposed to be accepted/acceptable/valid code.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13326 a5019735-40e9-0310-863c-91ae7b9d1cf9
/external/valgrind/memcheck/mc_errors.c
8617b5b8f16570c9003379464d60e8572a801a8c 12-Jan-2013 philippe <philippe@a5019735-40e9-0310-863c-91ae7b9d1cf9> 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 a5019735-40e9-0310-863c-91ae7b9d1cf9
/external/valgrind/memcheck/mc_errors.c
2193a7c20b74867de85a5ac10e7db5c7038f7c8a 08-Dec-2012 philippe <philippe@a5019735-40e9-0310-863c-91ae7b9d1cf9> 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 a5019735-40e9-0310-863c-91ae7b9d1cf9
/external/valgrind/memcheck/mc_errors.c
6bd9dc18c043927c1196caba20a327238a179c42 23-Nov-2012 florian <florian@a5019735-40e9-0310-863c-91ae7b9d1cf9> Changes to allow compilation with -Wwrite-strings. That compiler option
is not used for testcases, just for valgrind proper.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13137 a5019735-40e9-0310-863c-91ae7b9d1cf9
/external/valgrind/memcheck/mc_errors.c
19f91bbaedb4caef8a60ce94b0f507193cc0bc10 10-Nov-2012 florian <florian@a5019735-40e9-0310-863c-91ae7b9d1cf9> Fix more Char/HChar mixups. Closing in...


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13119 a5019735-40e9-0310-863c-91ae7b9d1cf9
/external/valgrind/memcheck/mc_errors.c
dbb3584f591710a15a437918c0fc27e300993566 27-Oct-2012 florian <florian@a5019735-40e9-0310-863c-91ae7b9d1cf9> More Char/HChar fixes and constification.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13088 a5019735-40e9-0310-863c-91ae7b9d1cf9
/external/valgrind/memcheck/mc_errors.c
e543f3024ace2925a0fb81985e9fcfc95b8c555a 21-Oct-2012 florian <florian@a5019735-40e9-0310-863c-91ae7b9d1cf9> First round of Char/HChar fixups for coregrind and memcheck.
Little bit of ripple in tools, too.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13074 a5019735-40e9-0310-863c-91ae7b9d1cf9
/external/valgrind/memcheck/mc_errors.c
a5f894c271248c13e0bb387e5ca33fa122b4819c 21-Oct-2012 florian <florian@a5019735-40e9-0310-863c-91ae7b9d1cf9> First round of Char/HChar fixes for memcheck.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13071 a5019735-40e9-0310-863c-91ae7b9d1cf9
/external/valgrind/memcheck/mc_errors.c
03f8d3fc25f5a45c5826259d1b33b7f310117279 05-Aug-2012 sewardj <sewardj@a5019735-40e9-0310-863c-91ae7b9d1cf9> Update copyright dates to include 2012.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12843 a5019735-40e9-0310-863c-91ae7b9d1cf9
/external/valgrind/memcheck/mc_errors.c
d99c26a4bc18fd3b17c4626c9c1fbd1583388660 01-Aug-2012 philippe <philippe@a5019735-40e9-0310-863c-91ae7b9d1cf9> Implement --redzone-size and --core-redzone-size

* For tools replacing the malloc library (e.g. Memcheck, Helgrind, ...),
the option --redzone-size=<number> allows to control the padding
blocks (redzones) added before and after each client allocated block.
Smaller redzones decrease the memory needed by Valgrind. Bigger
redzones increase the chance to detect blocks overrun or underrun.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12807 a5019735-40e9-0310-863c-91ae7b9d1cf9
/external/valgrind/memcheck/mc_errors.c
11cc9cecfee993abfdf1e6e4c9731f46fd4276d1 11-Mar-2012 philippe <philippe@a5019735-40e9-0310-863c-91ae7b9d1cf9> Ensure VALGRIND_MALLOCLIKE_BLOCK protects the red zones.

* Redzones for custom alloc were not protected by VALGRIND_MALLOCLIKE_BLOCK.
mc_main.c client request handling completed with protection
of the redzones.
* custom_alloc.c test modified to test this case.
* mc_errors.c modified so as to first search for a malloc-ed block
bracketting the error : for a custom allocator, a recently freed
block can have just been re-allocated.
In such a case, describing the address (e.g. in case of error)
points to the block freed rather than to the block just allocated.
If there is *also* a recently freed block bracketting the address,
the block description is changed to indicate that.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12439 a5019735-40e9-0310-863c-91ae7b9d1cf9
/external/valgrind/memcheck/mc_errors.c
a22f59db02284784a1e5e51587e2ce09db3a2a18 27-Jan-2012 philippe <philippe@a5019735-40e9-0310-863c-91ae7b9d1cf9> (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 a5019735-40e9-0310-863c-91ae7b9d1cf9
/external/valgrind/memcheck/mc_errors.c
6643e96a72e8530a7c8830c02ffb2fb4aee74c88 17-Jan-2012 philippe <philippe@a5019735-40e9-0310-863c-91ae7b9d1cf9> Fixes 282230 group allocator for small fixed size, use it for MC_Chunk/SEc vbit

* new files include/pub_tool_groupalloc.h and coregrind/m_groupalloc.c
implementing a group allocator (based on helgrind group alloc).
* include/Makefile.am coregrind/Makefile.am : added pub_tool_groupalloc.h
and m_groupalloc.c
* helgrind/libhb_core.c : use pub_tool_groupalloc.h/m_groupalloc.c
instead of the local implementation.
* include/pub_tool_oset.h coregrind/m_oset.c : new function
allowing to create an oset that will use a pool allocator.
new function allowing to clone an oset (so as to share the pool alloc)
* memcheck/tests/unit_oset.c drd/tests/unit_bitmap.c : modified
so that it compiles with the new m_oset.c
* memcheck/mc_main.c : use group alloc for MC_Chunk
memcheck/mc_include.h : declare the MC_Chunk group alloc
* memcheck/mc_main.c : use group alloc for the nodes of the secVBitTable OSet
* include/pub_tool_hashtable.h coregrind/m_hashtable.c : pass the free node
function in the VG_(HT_destruct).
(needed as the hashtable user can allocate a node with its own alloc,
the hash table destroy must be able to free the nodes with the user
own free).
* coregrind/m_gdbserver/m_gdbserver.c : pass free function to VG_(HT_destruct)
* memcheck/mc_replace_strmem.c memcheck/mc_machine.c
memcheck/mc_malloc_wrappers.c memcheck/mc_leakcheck.c
memcheck/mc_errors.c memcheck/mc_translate.c : new include needed
due to group alloc.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12341 a5019735-40e9-0310-863c-91ae7b9d1cf9
/external/valgrind/memcheck/mc_errors.c
ec062e8d96a361af9905b5447027819dfbfee01a 23-Oct-2011 sewardj <sewardj@a5019735-40e9-0310-863c-91ae7b9d1cf9> Update all copyright dates, from 20xy-2010 to 20xy-2011.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12206 a5019735-40e9-0310-863c-91ae7b9d1cf9
/external/valgrind/memcheck/mc_errors.c
403d8aada736841ca05764ffe12ca78435c01d3a 22-Oct-2011 sewardj <sewardj@a5019735-40e9-0310-863c-91ae7b9d1cf9> 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 a5019735-40e9-0310-863c-91ae7b9d1cf9
/external/valgrind/memcheck/mc_errors.c
b3af9cf0b234d0d188347d92944e04ac9c8fbcd0 06-Oct-2011 bart <bart@a5019735-40e9-0310-863c-91ae7b9d1cf9> Format functions: change format specifier %t into %pS. Remove the _no_f_c formatting function variants.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12108 a5019735-40e9-0310-863c-91ae7b9d1cf9
/external/valgrind/memcheck/mc_errors.c
30b3eca94e609214d9ac8dabfee9be3f3ab46d85 28-Jun-2011 sewardj <sewardj@a5019735-40e9-0310-863c-91ae7b9d1cf9> 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 a5019735-40e9-0310-863c-91ae7b9d1cf9
/external/valgrind/memcheck/mc_errors.c
6e9de463ef677f093e9f24f126e1b11c28cf59fd 28-Jun-2011 sewardj <sewardj@a5019735-40e9-0310-863c-91ae7b9d1cf9> Delete the AIX5 port. The last release this worked for is 3.4.1,
and then only on AIX 5.2 and 5.3.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@11842 a5019735-40e9-0310-863c-91ae7b9d1cf9
/external/valgrind/memcheck/mc_errors.c
c8bd1df6c23e2409512e1e50616e7dc3bae501a2 26-Jun-2011 sewardj <sewardj@a5019735-40e9-0310-863c-91ae7b9d1cf9> 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 a5019735-40e9-0310-863c-91ae7b9d1cf9
/external/valgrind/memcheck/mc_errors.c
3b290486cd4cd601b20e04340e593c9ed9717e5f 06-May-2011 sewardj <sewardj@a5019735-40e9-0310-863c-91ae7b9d1cf9> Implement a GDB server in Valgrind. See #214909.
(Philippe Waroquiers, philippe.waroquiers@skynet.be)



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@11727 a5019735-40e9-0310-863c-91ae7b9d1cf9
/external/valgrind/memcheck/mc_errors.c
913473803432ee37d6edaf232e21978d4f426125 25-Mar-2011 bart <bart@a5019735-40e9-0310-863c-91ae7b9d1cf9> Add VALGRIND_RESIZEINPLACE_BLOCK() and hence close #267819.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@11666 a5019735-40e9-0310-863c-91ae7b9d1cf9
/external/valgrind/memcheck/mc_errors.c
62b9104a05dede4b9cabfaa483da76480131127e 23-Jan-2011 sewardj <sewardj@a5019735-40e9-0310-863c-91ae7b9d1cf9> Improve error reports for addressing errors in the presence of
mempools: try and relate an invalid address to known mempool
allocated blocks, and if that fails, to malloc'd blocks that
back the mempool. See #254420.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@11509 a5019735-40e9-0310-863c-91ae7b9d1cf9
/external/valgrind/memcheck/mc_errors.c
7d751b2b72d806d1ef747f8ee661aeb52e7563aa 21-Jul-2010 sewardj <sewardj@a5019735-40e9-0310-863c-91ae7b9d1cf9> Make the --workaround-gcc296-bugs kludge take into account the stack
redzone size. Fixes #238208.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@11217 a5019735-40e9-0310-863c-91ae7b9d1cf9
/external/valgrind/memcheck/mc_errors.c
9eecbbb9a9cbbd30b903c09a9e04d8efc20bda33 03-May-2010 sewardj <sewardj@a5019735-40e9-0310-863c-91ae7b9d1cf9> Update copyright dates to 2010.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@11121 a5019735-40e9-0310-863c-91ae7b9d1cf9
/external/valgrind/memcheck/mc_errors.c
588adeffafa8102adcfa7a1c035ae272b35cf86d 16-Aug-2009 sewardj <sewardj@a5019735-40e9-0310-863c-91ae7b9d1cf9> When generating XML output for suppressions, print the suppression
both wrapped up in XML tags (as before) but also in plain text in a
sequence of CDATA blocks. Normally only one, but in the worst case
the raw data will have ]]> in it, in which case it needs to be split
across two CDATA blocks.

This apparently simple change involved a lot of refactoring of the
suppression printing machinery:

* in the core-tool iface, change "print_extra_suppression_info" (which
prints any auxiliary info) to "get_extra_suppression_info", which
parks the text in a caller-supplied buffer. Adjust tools to match.

* VG_(apply_StackTrace): accept a void* argument, which is passed to
each invokation of the functional parameter (a poor man's closure
implementation).

* move PRINTF_CHECK into put_tool_basics.h, where it should have been
all along

* move private printf-into-an-XArray-of-character functions from
m_debuginfo into m_xarray, and make them public

* gen_suppression itself: use all the above changes. Basically we
always generate the plaintext version into an XArray. In text mode
that's just printed. In XML mode, we print the XMLery as before,
but the plaintext version is dumped into a CDATA block too.

* update the Protocol 4 specification to match all this.

This still isn't 100% right in the sense that the CDATA block data
needs to be split across multiple blocks if it should ever contain the
CDATA end mark "]]>". The Protocol 4 spec has this right even though
the implementation currently doesn't.

Fixes #191189.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@10822 a5019735-40e9-0310-863c-91ae7b9d1cf9
/external/valgrind/memcheck/mc_errors.c
b6267bd61a3802bb2a16ef993c94bf834d0e2d2e 12-Aug-2009 njn <njn@a5019735-40e9-0310-863c-91ae7b9d1cf9> Output tweaks:
- Always print a blank line after significant messages (eg. errors). This
makes the handling of blank lines much simpler.

- Don't print full stops at the end of messages. We mostly don't do it, so
I got rid of all the remaining ones I could find for consistency.

- Use --leak-check=full rather than --leak-check=yes, for consistency with
docs and other messages.

- Update partiallydefinedeq.stderr.exp2 for older changes.

This commit only updates the code. Test updates will follow shortly. (I'm
separating them so the code changes aren't swamped by the test changes in
the SVN logs.)


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@10783 a5019735-40e9-0310-863c-91ae7b9d1cf9
/external/valgrind/memcheck/mc_errors.c
18afe5d1c3dc9e4e16d3e10617d6afa4bf9fcd40 10-Aug-2009 njn <njn@a5019735-40e9-0310-863c-91ae7b9d1cf9> Try to fix error_counts.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@10768 a5019735-40e9-0310-863c-91ae7b9d1cf9
/external/valgrind/memcheck/mc_errors.c
4a76c5e1e1a62a7d14299a066687aad28f67bcae 10-Aug-2009 njn <njn@a5019735-40e9-0310-863c-91ae7b9d1cf9> Count leak as errors. Fixes bug 152393.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@10767 a5019735-40e9-0310-863c-91ae7b9d1cf9
/external/valgrind/memcheck/mc_errors.c
e3f1e5988a94af9230f67273ca9236c4d7e8b8da 31-Jul-2009 sewardj <sewardj@a5019735-40e9-0310-863c-91ae7b9d1cf9> (almost completely just function renaming):

* VG_(find_seginfo): incrementally rearrange the DebugInfo list, like
most of the other list-searching functions do.

* rename all VG_(*seginfo*) functions exported from m_debuginfo to
VG_(*DebugInfo*). "seginfo" was a historical name which was mostly
but not completely, done away with some time back.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@10678 a5019735-40e9-0310-863c-91ae7b9d1cf9
/external/valgrind/memcheck/mc_errors.c
050eec553cdcb2ebeaefbb267aeb0828be7121e5 27-Jul-2009 bart <bart@a5019735-40e9-0310-863c-91ae7b9d1cf9> Fixed a bug in the code for reading suppression files: the line numbers
reported in error messages were not correct. As an example, the following
output was produced before this patch (not correct):
$ ./vg-in-place --tool=helgrind --num-callers=1 /bin/true
...
FATAL: in suppressions file ".in_place/default.supp" near line 893:
suppression must contain at least one location line which is not "..."
exiting now.
$ ./vg-in-place --tool=drd --num-callers=1 /bin/true
FATAL: in suppressions file ".in_place/default.supp" near line 475:
suppression must contain at least one location line which is not "..."
exiting now.

After having applied this patch the above commands display line numbers
1104 and 619, referring to the first suppression pattern containing
three dots for the topmost stack frame, as expected.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@10632 a5019735-40e9-0310-863c-91ae7b9d1cf9
/external/valgrind/memcheck/mc_errors.c
35db56c19847654f22b62da059083d41ff4258c5 24-Jul-2009 njn <njn@a5019735-40e9-0310-863c-91ae7b9d1cf9> A fix for bug 186796: suppression symbol names were being truncated if they
were longer than 200 chars. Now dynamic memory is used and so they can be
arbitrarily long in theory, although in practice it bombs out at 100,000 for
sanity purposes. This required adjusting the core/tool interface for
read_extra_suppression_info().


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@10581 a5019735-40e9-0310-863c-91ae7b9d1cf9
/external/valgrind/memcheck/mc_errors.c
6b523cd2df025375e86b161de9995187edf2fcb6 15-Jul-2009 sewardj <sewardj@a5019735-40e9-0310-863c-91ae7b9d1cf9> Merge memcheck/ changes from branches/MESSAGING_TIDYUP r10464.
See trunk r10465 commit message for details.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@10467 a5019735-40e9-0310-863c-91ae7b9d1cf9
/external/valgrind/memcheck/mc_errors.c
f76d27a697a7b0bf3b84490baf60623fc96a23af 28-May-2009 njn <njn@a5019735-40e9-0310-863c-91ae7b9d1cf9> Merge the DARWIN branch onto the trunk.

I tried using 'svn merge' to do the merge but it did a terrible job and
there were bazillions of conflicts. So instead I just took the diff between
the branch and trunk at r10155, applied the diff to the trunk, 'svn add'ed
the added files (no files needed to be 'svn remove'd) and committed.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@10156 a5019735-40e9-0310-863c-91ae7b9d1cf9
/external/valgrind/memcheck/mc_errors.c
29a5c01528ca7cffe17880a038b4563de920f08d 06-May-2009 njn <njn@a5019735-40e9-0310-863c-91ae7b9d1cf9> Fix bug #191182, where printing the leak checker results was really slow if
there were a lot of loss records.

The fix was:
- Avoid the O(m * n) looping over the chunks when creating the loss
records, by putting loss records into an OSet instead of a list, which
makes duplicate detection for each chunk an O(log n) operation instead of
an O(n) operation.
- Avoid the looping over loss records which was used to do a poor
man's sort, but was O(n^2). Instead copy pointers to the loss records
from the OSet into an array and sort it normally with VG_(ssort) (n log n,
usually) before printing.

This approach was similar to that used in the patch Philippe attached to the
bug report.

Other changes:
- Added Philippe's test programs in the new memcheck/perf directory. It
used to take 57s on my machine, now it takes 1.6s.
- Cleaned up massif/perf/Makefile.am to be consistent with other Makefiles.
- Improved some comments relating to VgHashTable and OSet.
- Avoided a redundant traversal of the hash table in VG_(HT_to_array), also
identified by Philippe..
- Made memcheck/tests/mempool's results independent of the pointer size, and
thus was able to remove its .stderr.exp64 file.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@9781 a5019735-40e9-0310-863c-91ae7b9d1cf9
/external/valgrind/memcheck/mc_errors.c
b7a4e2ea4e1adfda6bf2d7e3c448f663c5d173a9 01-May-2009 njn <njn@a5019735-40e9-0310-863c-91ae7b9d1cf9> Renamed various things for clarity. Added some comments. And fixed the
dubious find-minimum-loss-record loop in print_results(), which was using an
inconsistent mixture of szB and szB+indirect_szB.

Two test results changed, just different sort orders for same-sized loss
records.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@9704 a5019735-40e9-0310-863c-91ae7b9d1cf9
/external/valgrind/memcheck/mc_errors.c
9f207460d70d38c46c9e81996a3dcdf90961c6db 10-Mar-2009 njn <njn@a5019735-40e9-0310-863c-91ae7b9d1cf9> Updated copyright years.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@9344 a5019735-40e9-0310-863c-91ae7b9d1cf9
/external/valgrind/memcheck/mc_errors.c
8225cc0de2ccf390127b5910dceb7c6185091a38 09-Mar-2009 njn <njn@a5019735-40e9-0310-863c-91ae7b9d1cf9> 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 a5019735-40e9-0310-863c-91ae7b9d1cf9
/external/valgrind/memcheck/mc_errors.c
1dcee097db02f9ef3ba355162c4373d90d0e895c 24-Feb-2009 njn <njn@a5019735-40e9-0310-863c-91ae7b9d1cf9> Remove a number of unused parameters, found with -Wunused-parameter.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@9248 a5019735-40e9-0310-863c-91ae7b9d1cf9
/external/valgrind/memcheck/mc_errors.c
c4431bfe04c7490ea2d74939d222d87f13f30960 15-Jan-2009 njn <njn@a5019735-40e9-0310-863c-91ae7b9d1cf9> Introduce a new type, PtrdiffT. Replace lots of uses of OffT (all those
that are memory offsets) with PtrdiffT; OffT should only be used for file
sizes and offsets.

Change Off64T from a ULong to a Long, as it should be. Replace some uses
of ULong in the address space manager with Off64T to match.

Also add a comment explaining the meanings of the basic types like Addr,
OffT, SizeT, etc.

Also fix the prototype for VG_(pread) -- the last arg is an OffT, not an
Int.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@8959 a5019735-40e9-0310-863c-91ae7b9d1cf9
/external/valgrind/memcheck/mc_errors.c
9c606bd8634cd6b67bb41fa645b5c639668cfa2d 18-Sep-2008 sewardj <sewardj@a5019735-40e9-0310-863c-91ae7b9d1cf9> Merge all remaining changes from branches/PTRCHECK. These are some
relatively minor extensions to m_debuginfo, a major overhaul of
m_debuginfo/readdwarf3.c to get its space usage under control, and
changes throughout the system to enable heap-use profiling.

The majority of the merged changes were committed into
branches/PTRCHECK as the following revs: 8591 8595 8598 8599 8601 and
8161.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@8621 a5019735-40e9-0310-863c-91ae7b9d1cf9
/external/valgrind/memcheck/mc_errors.c
a0b6b2cf9abc7b0d87be1215a245eaccc0452af9 07-Jul-2008 bart <bart@a5019735-40e9-0310-863c-91ae7b9d1cf9> Merged FORMATCHECK branch (r8368) to trunk.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@8369 a5019735-40e9-0310-863c-91ae7b9d1cf9
/external/valgrind/memcheck/mc_errors.c
56adc358fd23a1b1d9e331ca63f773aca1ec0953 02-May-2008 sewardj <sewardj@a5019735-40e9-0310-863c-91ae7b9d1cf9> Minor cleanups:

* remove 'extern' in all the headers, as that is irrelevant and wastes
horizontal space

* fix some 64-bit uncleanness in client(-defined) block handling

* remove unneeded #includes



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@7987 a5019735-40e9-0310-863c-91ae7b9d1cf9
/external/valgrind/memcheck/mc_errors.c
7ce7166aeae2d8401f2b3b1f9e6f60be9ae9dd72 02-May-2008 sewardj <sewardj@a5019735-40e9-0310-863c-91ae7b9d1cf9> Move the error management code for Memcheck into a new file,
mc_errors.c, as it is relatively self contained. This reduces the
size of mc_main.c by about 1350 lines.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@7986 a5019735-40e9-0310-863c-91ae7b9d1cf9
/external/valgrind/memcheck/mc_errors.c