1405 Commits

Author SHA1 Message Date
Florian Krohm
55255ece42 Add expected results for 32-bit little endian platform.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12447
2012-03-17 17:27:17 +00:00
Philippe Waroquiers
825fdcf3cb 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
2012-03-11 17:59:00 +00:00
Julian Seward
cd43bae6a4 Change the behaviour of --partial-loads-ok=yes to avoid false
negatives, by marking the V bits that come from out of range parts of
the access as undefined; and hence any use of them leads to an value
error.  Prior to this they were marked as defined and could be used
without error.

Behaviour of --partial-loads-ok=no (the default case) is unchanged.

Also add some testing thereof.

Fixes #294523.  Modified version of a patch and testcase by Patrick
J. LoPresti (lopresti@gmail.com).



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12430
2012-03-08 14:51:01 +00:00
Julian Seward
2db1d0a8a2 Reinstate intercepts for plain "memcpy" and "memmove" on OSX <= 10.6
(not on Lion).  Fixes #285662.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12423
2012-03-07 15:26:50 +00:00
Florian Krohm
d58aa28f82 Avoid possibly unaligned memory access.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12415
2012-03-03 18:46:05 +00:00
Philippe Waroquiers
7ec5224de5 In case VALGRIND_MALLOCLIKE_BLOCK is wrongly used, output
the execontext where the overlapping blocks have been reported
before crashing.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12412
2012-03-01 22:00:36 +00:00
Philippe Waroquiers
704e5c19d1 Fix one more leak detected by running memcheck in memcheck
(started to run regression tests in an outer)



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12407
2012-02-27 21:52:45 +00:00
Philippe Waroquiers
1d7a774336 Fix some memory leaks found by running memcheck on annotated memcheck.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12405
2012-02-26 21:26:00 +00:00
Florian Krohm
0160d2dfc6 With the change in VEX r2258 the guest IA will now also be accessed
in the low word only. Adjust code accordingly.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12392
2012-02-20 15:03:02 +00:00
Julian Seward
036b1a4105 Change the garbage collection policy for the secondary VBit table
(that holds partially defined bytes), to GC more aggressively.
Details in the comments.  This largely avoids a sometimes massive
space leak, that has been observed (eg) running the Firefox test suite
on Memcheck.  Without this patch it cannot complete with 4 million
nodes in the table; with the patch it completes comfortably with 50000
ish nodes.  This reduces the total memory use needed for the run
from above 7GB down to 6.2GB.

Smaller improvements have been seen with other programs too.  Speed
does not appear to be negatively affected.

(Based on a patch, and analysis of the problem, by Philippe Waroquiers.)



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12383
2012-02-14 12:11:47 +00:00
Tom Hughes
74eb6fb3b4 Add support for process_vm_readv and process_vm_writev system calls.
Patch from Lénaïc Huard to fix BZ#292995.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12374
2012-02-10 09:39:37 +00:00
Philippe Waroquiers
b191da4da7 mc_main.c statistics has hard-coded logic to compute
the memory used by sec vbit table. This logic depends
on the way sec Vbit entries are maintained.
Due to the introduction of pool alloc, this logic has
to be changed to (more) correctly compute the memory.

Verified on f12/x86 by comparing the memory reported
by the memcheck stats with what is given by --profile-heap=yes.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12369
2012-02-08 22:23:55 +00:00
Florian Krohm
83845abd22 Add testcase for bugzilla #287260. Testcase by M.Welinder
(mwelinder@gmail.com). Announce bug fix.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12359
2012-01-29 02:23:07 +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
be97cddd7a 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
2012-01-17 21:16:30 +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
Florian Krohm
83e28c9beb Fix accounting for MC_(realloc). It was inconsistent as compared to
other wrappers in that it took place before the silly-args check. 
Testcase and patch by Yann Droneaud (yann@droneaud.fr).
Fixes #281482

Also included is a related fix to MC_(new_block). Incrementing the
alloc counter and updating the allocated memory amount should
occur under the same condition (allocation succeeded).


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12324
2011-12-30 03:09:45 +00:00
Philippe Waroquiers
225138a663 Avoid buffer overrun in percentify call.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12322
2011-12-27 18:43:32 +00:00
Philippe Waroquiers
c953f410c8 Fix 247386 make perf does not run all performance tests :
* move memcheck/perf/many-loss-records test to perf directory
       massif/perf/many-xpts test to perf directory
* modified many-loss-records.vgperf and many-xpts.vgperf,
  so as to have tool specific options prefixed with their tool
* remove directory memcheck/perf and massif/perf (containing no test anymore)



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12315
2011-12-23 11:42:20 +00:00
Bart Van Assche
2796d1b9be RHEL 4 build fix
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12263
2011-11-09 17:31:54 +00:00
Julian Seward
d2daafda62 Use normal setjmp/longjmp, not the __builtin_ ones, as LLVM pretty
much treats the latter kind as no-ops.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12254
2011-10-31 10:59:31 +00:00
Florian Krohm
b0ee68529f Give function copy_input_until_stop the noinline atribute.
At least one of the compilers for s390x nightly builds was inlining it.
Update exp files accoordingly. This should fix any residual back-trace 
noise for this testcase.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12235
2011-10-26 15:27:41 +00:00
Julian Seward
68cf6ae28d Some fixes for Android:
* initial support for Pandaboard/Linaro
* on Android/ARM, ask for non-executable stacks in the executables
* disable Memcheck's strcasestr intercept; its use of tolower()
  causes the dynamic linker to fail.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12234
2011-10-26 15:10:49 +00:00
Julian Seward
084b7cb10b Fix #284384 (clang 3.1 -Wunused-value warnings in valgrind.h,
memcheck.h) by changing a bunch of VALGRIND_DO_CLIENT_REQUEST_EXPR
into VALGRIND_DO_CLIENT_REQUEST_STMT for cases where the return value
of the former would be unused.  (Bart Van Assche, bart.vanassche@gmail.com)



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12226
2011-10-24 13:21:57 +00:00
Julian Seward
daa6c4607b Change the behaviour of VALGRIND_CHECK_MEM_IS_DEFINED slightly, so
that if the range is partially non-addressable and it contains
undefined data, both errors are reported.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12222
2011-10-24 05:59:54 +00:00
Julian Seward
c96096ab24 Update all copyright dates, from 20xy-2010 to 20xy-2011.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12206
2011-10-23 07:32:08 +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
b9b6742e1f Add an excessively minimal testcase, from #279698, pertaining to the
propagation of V bits through saturated narrowing operations.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12194
2011-10-22 09:55:37 +00:00
Julian Seward
ef4bea6bb5 Change and simplify the way that Memcheck instruments saturating
narrowing operations.  The previous scheme was simply wrong and could
cause false negatives, by causing some narrowing operations to have a
defined output even when the inputs are undefined.  This was what
#279698 reported.  This patch is a fix for that bug.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12190
2011-10-22 09:29:41 +00:00
Julian Seward
1fd197db11 Add a replacement for strcasestr, along with test case. Fixes #282979.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12187
2011-10-21 08:07:13 +00:00
Florian Krohm
086294dbed Add missing filter scripts to Makefile.am so they are included in
the tarball generated by "make dist".
With this change running regtest from the tarball produces the same
results as a regtest on a checked out repository (on x86 that is).


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12172
2011-10-20 01:17:12 +00:00
Julian Seward
6af4478c60 Handle new Iop_CmpEQ64x2 introduced in vex r2218.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12165
2011-10-19 15:24:55 +00:00
Bart Van Assche
399aea2c1b memcheck/tests/linux/Makefile.am: Add four .vgtest files to the distribution tarball and remove the capget binary
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12155
2011-10-14 09:32:46 +00:00
Bart Van Assche
64f66e209a Revert r12128 because it triggers an assertion failure on one of the nightly build systems
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12133
2011-10-11 10:56:11 +00:00
Florian Krohm
5f2312e2a9 First round of changes to get make dist working again.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12131
2011-10-09 23:28:47 +00:00
Bart Van Assche
972d2598ed memcheck/tests/err_disable4: Increase thread stack size a little
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12128
2011-10-09 08:05:08 +00:00
Bart Van Assche
31a228d817 memcheck/tests/unit_libcbase.c: Convert from old-style gcc designated
initializers to C99-style designated initializers. According to the gcc manual,
the former syntax is obsolete since gcc 2.5
(see also http://gcc.gnu.org/onlinedocs/gcc-4.6.1/gcc/Designated-Inits.html).


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12113
2011-10-07 09:45:14 +00:00
Bart Van Assche
64639894d6 memcheck/tests/err_disable4: Reduce memory footprint further.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12112
2011-10-07 09:41:58 +00:00
Bart Van Assche
7dab1bd66a Avoid that using any of the VALGRIND_DISABLE_ERROR_REPORTING,
VALGRIND_ENABLE_ERROR_REPORTING, VALGRIND_DO_ADDED_LEAK_CHECK,
VALGRIND_DO_CHANGED_LEAK_CHECK macros causes gcc 4.6 to print
a warning message about assigning a value to an unused variable.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12110
2011-10-07 09:39:56 +00:00
Bart Van Assche
71a513f01a 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
2011-10-06 19:08:37 +00:00
Florian Krohm
dc608b4b58 Declare _exit as "noreturn". This will avoid a GCC warning.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12104
2011-10-05 14:36:00 +00:00
Florian Krohm
ddd11cf638 Change the filter order. Filename base backtrace filtering
must come first before the filename gets changed to bogus.S
This should unbreak the failure on x86_64. But I can't test it.
We shall see.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12099
2011-10-05 03:09:01 +00:00
Florian Krohm
7a5d4dd13a Update exp files for memcheck's supp_unknown testcase.
Promote the s390x exp file to be the golden one because it has the
correct result. Add an exp-kfail file for those platforms where the testcase
fails (x86).


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12098
2011-10-05 02:34:33 +00:00
Florian Krohm
8d6e98bdfd Rewrite badjump and badjump2 such that the error occurs now on the
same line for all architectures.
Promote the s390x exp file to be the golden one because it has the
correct result. Add exp-kfail files for those platforms where the testcases
fail (x86).


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12097
2011-10-04 20:14:59 +00:00
Florian Krohm
15d93bd860 Fix execve2 testcase.
First, due to a typo in Makefile.am it was compiled with the wrong flags.
Secondly, the testcase gives an incorrect backtrace on x86 (missing the
line where the error occurs). Updated the generic exp to contain the
correct result and added exp-kfail for platforms where this test fails.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12094
2011-10-04 03:55:04 +00:00
Florian Krohm
d2b0c7d982 Turns out there is at least one version of glibc tat contains
a file name writev.c. This screws our filename based backtrace
filtering. Rename writev to writev1 to avoid that problem.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12093
2011-10-04 03:33:59 +00:00
Florian Krohm
c8d25c1a22 The testcases execve1 and fwrite actually fail on x86 in the sense that
they produce an incomplete backtrace. Added exp-kfail files to capture the
results with the incomplete backtraces. Updated the generic exp files.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12092
2011-10-04 03:15:38 +00:00
Florian Krohm
ad7a355b4a Improve filtering of backtrace noise in the memcheck bucket
and update exp files accordingly. This works well for x86
and all testcases pass on my machine.
New file filter_memcheck to do the work. 
There is a bit of a ripple here as filter_memcheck requires
command line arguments to be passed in. So all users of 
filter_memcheck (direct or indirect) were updated as well.
filter_stderr was simplified as was filter_libc.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12091
2011-10-03 23:39:54 +00:00
Florian Krohm
d13b1b34c8 Rename testcase from execve to execve1.
The reason is that the point of failure is in glibc
in a file named execve.c  The backtrace filtering
(which is filename based) cannot distinguish the
two execve.c file names. Renaming the testcsae does the
trick.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12090
2011-10-03 23:05:56 +00:00
Julian Seward
ef47922e1a Limit number of backtrace frames to 3 so as to avoid junk frames.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12087
2011-10-03 16:15:16 +00:00