Commit Graph

1118 Commits

Author SHA1 Message Date
Philippe Waroquiers
b53d2291e8 Add an optional 2nd arg to leak-autofreepool to test performance
e.g. using the beloz
for f in 1 2 3 4 5 6 7 8 9; do echo $f;  time ./vg-in-place -q ./memcheck/tests/leak-autofreepool 2 $(expr $f \* 100000); done

This shows that freeing a mempool with significant nr of elements
has a bad effect on performance

Note that no effort has been spent to avoid leaks in this
optional perf test. This is just to analyse the time taken to
free the pool.

The above loop shows that a medium size pool (e.g. < 1000000 elts)
can already take significant time, probably due to the quadratic
algorithm to clear the pool.
Note that the increase can vary a lot, probably depending on the
way the blocks are spread in the hash table: when lucky, the quadratic
algorithm probably somewhat becomes more linear if the elements
are 'properly' ordered in the hash table by deletion order.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15986
2016-09-29 20:04:43 +00:00
Philippe Waroquiers
4a12396ba8 Fix test so that leaked bytes is the same in 32 and 64 bits
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15985
2016-09-25 18:38:19 +00:00
Ivo Raisr
f2b34df721 Added meta mempool support into memcheck for describing a custom allocator which:
- Auto-frees all chunks assuming that destroying a pool destroys all
  objects in the pool
- Uses itself to allocate other memory blocks
Unit tests included.
Fixes BZ#367995
Patch by: Ruurd Beerstra <ruurd.beerstra@infor.com>



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15984
2016-09-24 21:15:44 +00:00
Ivo Raisr
98273bc5f4 Solaris: Add ioctl wrapper for MNTIOC_GETEXTMNTENT.
n-i-bz


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15981
2016-09-23 23:00:21 +00:00
Rhys Kidd
9c0d0908f9 Follow up to r15905, properly guard memcheck/tests/amd64/shr_edx on clang. n-i-bz.
“error in backend: 32-bit absolute addressing is not supported in 64-bit mode”

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15946
2016-09-11 04:33:20 +00:00
Mark Wielaard
a7d9347bdf Use -std=c++0x for big_debuginfo_symbol to appease older compilers.
gcc 4.4 doesn't know -std=c++11, but does recognize -std=c++0x.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15944
2016-09-05 13:13:12 +00:00
Mark Wielaard
2f1ec093bc Allow building vbit_test when srdir != builddir.
Link against libvex-<arch>-<os>.a in top_builddir.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15940
2016-08-26 13:10:14 +00:00
Carl Love
d2450cd776 Power PC test suite for ISA 3.0, part 5 of 5
The test suite support for the Power PC ISA 3.0 instructions added in
VEX commit 3244 is added in this commit.

bugzilla 364948

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15938
2016-08-15 21:54:04 +00:00
Ivo Raisr
2935e69718 Fix test memcheck/tests/descr_belowsp so as the stack
guard page is visible also on Solaris.
n-i-bz


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15919
2016-07-30 03:01:52 +00:00
Ivo Raisr
d04009b787 Fix test memcheck/tests/descr_belowsp a bit on Solaris.
On Solaris, '%p' outputs just a hexadecimal number
without '0x' prefix. This is perfectly valid but not
understood by VG_(strtok_get_address_and_size)().
Therefore use universal PRIxPTR.
n-i-bz


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15918
2016-07-29 20:52:21 +00:00
Philippe Waroquiers
2679aea160 Regression test for n-i-bz amd64: memcheck false positive with shr %edx
Valgrind side : reproducer for the false positive memcheck
+ announce the fix (VEX side in next commit)



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15905
2016-07-12 20:48:31 +00:00
Ivo Raisr
ed93dc1aea Unify expected output of memcheck/tests/solaris/scalar test case
on amd64 and x86 architectures.
n-i-bz


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15886
2016-05-29 17:28:00 +00:00
Ivo Raisr
fbaa6ad350 Solaris: Further refinement of r15882 for Solaris versions
which do not have <sys/sysnvl.h> header file.
n-i-bz


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15885
2016-05-29 12:10:58 +00:00
Ivo Raisr
d894770ee3 Solaris: Add ioctl wrappers for DINFOUSRLD and DINFOIDENT.
n-i-bz


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15884
2016-05-29 09:29:28 +00:00
Ivo Raisr
aad88ea2d0 Solaris: Add syscall modctl with several commands implemented.
n-i-bz


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15882
2016-05-28 22:05:43 +00:00
Philippe Waroquiers
268ff84f7b Document brk segment limitation, reference manual in limit reached msg.
The msg telling brk cannot be extended confuses some users
so improve the documentation and have the msg referencing the doc.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15880
2016-05-22 20:48:09 +00:00
Ivo Raisr
ffcb955c34 Solaris: Add wrapper for setparam subcode of the door syscall.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15879
2016-05-16 12:51:27 +00:00
Ivo Raisr
8ace9b4f06 Solaris ioctl: Add wrapper for I_FLUSH.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15878
2016-05-16 11:38:29 +00:00
Ivo Raisr
662eab632a Solaris ioctl: Add wrapper for I_FIND.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15877
2016-05-16 06:12:27 +00:00
Carl Love
b52e8b1c78 Power PC Fix V bit error in 128-bit BCD add and subtract instructions
The original code was using the bcdadd / bcdsub instruction on the operand
shadow bits to calculate the shadow bits for the result.  This introduced
non-zero bits shadow bits in the result.   The shadow bits for these
instructions should be set to all valid or all invalid.  If one of the
argument shadow bits was one, then all of the shadow bits of the result should
be one.  Otherwise the result shadow bits should be zero.

This patch fixes the above bug in memcheck/mc_translate.c

Fixing the above bug broke the v-bit test.  The issue is the v-bit tester 
assumes the shadow bits for the operands of a given Iop can be set to one
for testing purposes.  The implementation of the bcdadd and bcdsub was passing
a constant value for the variable ps.  The ps value is an argument to the
instruction that specifies how to set the sign code of the result.  The
implementation of the instructions was changed to issue the instruction with
ps=0.  Then the result of the instruction is updated in the VEX code if ps=1.
This changed also results in cleaning up the vbit test code.  

This patch also fixes the issues with the v-bit test program.

Valgrind commit 3218

Bugzilla 360035


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15871
2016-04-26 19:53:56 +00:00
Ivo Raisr
da7df0f276 Valgrind is able to read compressed debuginfo sections in two formats:
- zlib ELF gABI format with SHF_COMPRESSED flag (gcc option -gz=zlib)
  - zlib GNU format with .zdebug sections (gcc option -gz=zlib-gnu)

Patch by: Aleksandar Rikalo <aleksandar.rikalo@imgtec.com>
Fixes BZ#303877



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15868
2016-04-23 20:28:27 +00:00
Ivo Raisr
91f7614767 Solaris: Add syscall wrapper for sysfs(84)
Fixes BZ#361926


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15862
2016-04-19 15:57:13 +00:00
Ivo Raisr
7407c16737 Fix compiler warnings on Solaris 12 about assigning a function pointer
of an incompatible type to signal handler.
Untyped function pointer sa_handler() is no longer available
so we leverage sa_sigaction(int, siginfo_t *, void *) instead.
n-i-bz


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15858
2016-04-17 19:28:04 +00:00
Ivo Raisr
e6a8721902 Fix build on newer illumos distributions which streamlined inclusion of sys/regset.h.
This means that sys/regset.h needs to be included explicitly now.
n-i-bz


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15857
2016-04-17 15:57:11 +00:00
Ivo Raisr
a91bd93900 Fix build on newer illumos distributions where struct fpchip_state
was renamed to _fpchip_state.
n-i-z


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15856
2016-04-17 10:05:29 +00:00
Mark Wielaard
a848da57ad Add arm64 scalar test. Enable tested syscalls.
The new memcheck/tests/arm64-linux/scalar test is based on the
memcheck/tests/x86-linux/scalar test and contains all syscalls
that are also available on arm64. To make comparison of exp results
easier the order of the tested syscalls is the same as on x86.
This enables a couple extra arm64 syscalls. Part of the fix for
bug #359503 - Add missing syscalls for aarch64 (arm64).

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15825
2016-03-09 16:18:36 +00:00
Ivo Raisr
6da8549607 Unbreak build of several regression tests on Solaris 12 with gcc 5.3
We need to move _XOPEN_SOURCE from 500 to 600 which
comes with '-std=c99'.
n-i-bz


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15821
2016-03-04 20:49:35 +00:00
Mark Wielaard
9c751d21ef Fix memcheck/tests/memalign_test expected output.
r15815 "Allow 8k and 32k page sizes" added an extra line in memalign_test.c.
This changed the line numbers in the output compared to the .exp file.
Just put everything on one (long) line to match expectations again.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15818
2016-02-28 10:37:55 +00:00
Petar Jovanovic
23ac24e19b mips: acquire exact page size using sysconf for unit_libcbase
Set exact value of VKI_PAGE_SIZE by calling sysconf(_SC_PAGESIZE).
This should set a correct value to this variable on MIPS systems with
different page sizes.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15817
2016-02-27 00:38:38 +00:00
Petar Jovanovic
e7e2cc219f Allow 8k and 32k page sizes
Allow 8k and 32k page sizes in memalign and other memory related tests.
This fixes crashes in the tests on systems with 8k or 32k pagesize.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15815
2016-02-26 16:05:29 +00:00
Philippe Waroquiers
4649a16580 Fix typo in Makefile.am : remove the second _
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15800
2016-02-18 21:41:01 +00:00
Philippe Waroquiers
76002f0b47 Add a test for bug 359133 Assertion 'eltSzB <= ddpa->poolSzB' failed
Test case provided by David Hallas



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15799
2016-02-18 21:32:46 +00:00
Ivo Raisr
9c83cafb93 Fix some compiler errors about accessing static variables
from non-static inline functions reported by gcc 5.3:
warning: "locf" is static but declared in inline function "fun_f" which is not static

While at it, silence also compiler warning about uninitialized
variable "result" when calling fun_a().

n-i-bz


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15797
2016-02-18 17:15:45 +00:00
Ivo Raisr
f71b442444 Solaris syscall: commands A_GETSTAT and A_SETSTAT
for auditon(2) subcode of the auditsys() syscall
were removed in Solaris 12.
However they stay for Solaris 11 and illumos.
n-i-bz


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15791
2016-02-17 18:11:32 +00:00
Ivo Raisr
2428a44b84 Fix scalar test case for llseek on x86/Solaris.
n-i-bz


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15786
2016-02-12 13:57:50 +00:00
Ivo Raisr
24e1e9f493 Solaris syscall: Add support for getrandom(143).
n-i-bz


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15782
2016-02-05 22:57:42 +00:00
Ivo Raisr
f18a40c2c8 Fix expected output of test memcheck/tests/leak_cpp_interior on Solaris 12.
C++ allocator from Solaris Studio allocates for std::string
57 bytes instead of former 40 bytes on 64-bit, and 45 bytes instead of 28 on 32-bit.
Confirmed with truss and --trace-alloc=yes.
n-i-bz


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15775
2016-01-26 10:34:16 +00:00
Ivo Raisr
8952c86a9c Fix compilation error on Solaris.
Include <sys/segments.h> only on x86/amd64 architecture.
n-i-bz



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15774
2016-01-26 04:31:04 +00:00
Philippe Waroquiers
c80f32e662 Change tests using --fullpath-after so as to work with ccache caching compiler
ccache sometimes causes the source file absolute name to be another
full path (not $PWD).
This means that the badfree3 and varinfo5 tests can fail due to
the full path after not being match on $PWD.
So, rather ask full path after a part of the path that is stable
even when ccache decides to reuse a already compiled object from
another directory.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15771
2016-01-22 22:06:02 +00:00
Mark Wielaard
dcb119cf41 Squash glibc warning about _BSD_SOURCE being deprecated tests.
glibc 2.20 deprecated _BSD_SOURCE and _SVID_SOURCE and now requires
_DEFAULT_SOURCE to be defined instead. Add _DEFAULT_SOURCE define to
prevent warnings like:

In file included from /usr/include/stdio.h:27:0,
                 from stack_switch.c:5:
/usr/include/features.h:148:3: warning: #warning "_BSD_SOURCE and _SVID_SOURCE are deprecated, use _DEFAULT_SOURCE" [-Wcpp]
 # warning "_BSD_SOURCE and _SVID_SOURCE are deprecated, use _DEFAULT_SOURCE"
   ^

See https://sourceware.org/glibc/wiki/Release/2.20#Packaging_Changes

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15768
2016-01-22 13:49:22 +00:00
Ivo Raisr
719b0574ea Fix expected stderr on Solaris for memcheck/tests/gone_abrt_xml.
On Solaris, the stack frame looks like:
  <stack>
    <frame>
      <ip>0x........</ip>
      <obj>/lib/amd64/libc.so.1</obj>
      <fn>kill</fn>
    </frame>
    <frame>
      <ip>0x........</ip>
      <obj>.../gdbserver_tests/gone</obj>
      <fn>(below main)</fn>
    </frame>
  </stack>

because Solaris libc does not currently contain DWARF CFI and
stack unwinder gets only return address from _start().



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15750
2015-12-15 10:43:25 +00:00
Philippe Waroquiers
21ec256b95 Fix 191069 Exiting due to signal not reported in XML output
Patch from  Matthias Schwarzott (slightly modified)



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15747
2015-12-13 16:53:46 +00:00
Petar Jovanovic
6b95752621 mips: add missing "memory" to the clobber list
Add "memory" to the clobber arguments of VALGRIND_DO_CLIENT_REQUEST_EXPR.

This fixes memcheck/tests/vbit-test/vbit-test.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15740
2015-11-27 14:51:33 +00:00
Carl Love
0201caa575 This is a fix to Bug 354797 which added the vbit test support for the
Power 8 instructions.

The patch for bug 354797 moved the declaration for rc outside of the
architecture #ifdef.  This results in an message about rc being unused
on architectures other then s390 and powerpc.  This commit eliminates
the issue by:

powerpc: move rc declaration into #ifdef for powerpc.
      Remove tab, put in missing break.

s390: remove rc declaration from inside case statement.  Put rc declaration
      before the switch statement but within the #ifdef for s390 so it will
      be declared for use in both case clauses.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15738
2015-11-25 17:48:25 +00:00
Ivo Raisr
d5266b32f7 Solaris syscall: Fix pset(getloadavg).
The buffer holds integers, not doubles.
n-i-bz


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15732
2015-11-19 09:34:29 +00:00
Ivo Raisr
68c788c973 Expected stderr of test cases wrapmalloc and wrapmallocstatic are overconstrained.
Fixes BZ#355455.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15727
2015-11-18 04:13:12 +00:00
Mark Wielaard
8b4dd5c47c BZ#355188 valgrind should intercept all malloc related global functions.
This implements the interception of all globally public allocation
functions by default. It works by adding a flag to the spec to say the
interception only applies to global functions. Which is set for the
somalloc spec. The librarypath to match is set to "*" unless the user
overrides it. Then each DiSym keeps track of whether the symbol is local
or global. For a spec which has isGlobal set only isGlobal symbols will
match.

Note that because of padding to keep the addresses in DiSym aligned the
addition of the extra bool isGlobal doesn't actually grow the struct.
The comments explain how the struct could be made more compact on 32bit
systems, but this isn't as easy on 64bit systems. So I didn't try to do
that in this patch.

For ELF symbols keeping track of which are global is trivial. For pdb I
had to guess and made only the "Public" symbols global. I don't know
how/if macho keeps track of global symbols or not. For now I just mark
all of them local (which just means things work as previously on platforms
that use machos, no non-system symbols are matches by default for somalloc
unless the user explicitly tells which library name to match).

Included are two testcases for shared libraries (wrapmalloc) and staticly
linked (wrapmallocstatic) malloc/free overrides that depend on the new
default. One existing testcase (new_override) was adjusted to explicitly
not use the new somalloc default because it depends on a user defined
new implementation that has side-effects and should explicitly not be
intercepted.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15726
2015-11-15 16:50:43 +00:00
Carl Love
79c80505d3 Add ISA 2.07 vbit test support
The ISA 2.07 support adds new Iops as well as support for some existing
Iops.  None of these Iops have been enabled in the vbit tester.  This commit
adds the needed support to the files in memcheck/tests/vbit-test.   
These changes add support for additional immediate operands and additional
undefined bit checking functions.

There are additional changes to files VEX/priv/ir_inject.c and VEX/pub/libvex.h
that are in VEX commit 3202

Bugzilla 354797 was created for this issue.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15720
2015-11-03 17:48:04 +00:00
Ivo Raisr
e7be5069c3 Solaris syscall: Add support for lwp_cond_signal(171).
Fixes BZ#354392.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15718
2015-10-26 16:13:05 +00:00
Philippe Waroquiers
6b5a479bda Fix 353891 Assert 'bad_scanned_addr < VG_ROUNDDN(start+len, sizeof(Addr))' failed
All memory dereferences during leak search are checked either with
aspacemgr or using the VA-bits.
So, in theory, no memory fault should occur.
However, the leak search is done so as to resist to e.g.
- desynchronisation between the real pages mapped and the aspacemgr state.
- client pages mprotected against reading
- any other reason why dereferencing a client address would fail.

So, the function lc_scan_memory installs a fault catcher that
is called if a memory fault signal is raised during memory scan.
However, memory dereference is also done in the function heuristic_reachedness.
So, this function must also resist to memory fault.

This patch also installs a fault catcher for the function heuristic_reachedness.

More in details, the following changes are done:
* pub_tool_signal.h and m_signals.c :
  VG_(set_fault_catcher) now returns the previously set fault catcher.
  This is needed so that heuristic_reachedness/lc_scan_memory can save
  and restore the previous fault catcher.

* mc_leakcheck.c:
  Addition of leak_search_fault_catcher that contains the common
  code for the (currently 2) fault catchers used during leak search.

* Modification of heuristic_reachedness and lc_scan_memory:
  Add 2 (small) specific fault catcher that are calling the common
  leak_search_fault_catcher.

* The way sigprocmask is handled has been changed:
  Before this patch, lc_scan_memory was saving/restoring the procsigmask
  for each scanned block (and was restoring it when the fault catcher
  was longjmp-ing back to lc_scan_memory in case of SEGV or BUS.
  This was causing 2 system calls for each block scanned.

  Now, lc_scan_memory and  heuristic_reachedness are not saving/restoring
  the procmask: the work to reset the sigprocmask is only done
  in leak_search_fault_catcher. This is more efficient as no syscall
  anymore is done during leak search, except for (normally) unfrequent
  SIGSEGV/BUS. It is also simpler as signal handling is now done at
  a single place.
  
  It is ok to reset the procmask (in fact, just remove the caught signal
  from the process sigmask) as during leak search, no other activity than
  the leak search is on-going, and so no other SEGV/BUS can be received
  while the handler runs.

This gives moderate speed improvements for applications allocating a lot of
blocks (about 10% improvement when leak searching in 1 million small blocks).

Test case (slightly modified) by Matthias Schwarzott.
  
  
  



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15716
2015-10-22 19:14:30 +00:00