2071 Commits

Author SHA1 Message Date
Petar Jovanovic
c6fbcbb12d mips64: change memcheck/tests/mips64/filter_stderr
This change removes backtrace line (posix_fadvise64.c) that is not always in
output of the failing test (fadvise64).
It fixes memcheck/tests/mips64/fadvise64 on MIPS64 platforms with glibc 2.27
or newer.

Patch by Dimitrije Nikolic.
2018-08-09 12:43:57 +02:00
Ivo Raisr
410d736a99 Ability to add suppressions based on source file name and line number.
Fixes BZ#390471.
Patch based on work by: Jeff Frontz <jeff.frontz@gmail.com> and Joseph M Link.
2018-06-26 06:36:12 +02:00
Petar Jovanovic
1910188124 Add processing of sized delete operators into filter_libc
C++14 introduces sized delete operators and Valgrind support is added
by 6ef6f73. In addition, stderr filter which is used by Regtest should
be able to recognize this particular form in error report (just like
the other kinds of delete operators) in order to provide uniform output.

Fixes memcheck/tests/mismatches failure on non C++14 builds.

Patch by Aleksandar Rikalo.
2018-06-21 11:59:51 +02:00
Petar Jovanovic
58c1c98db4 mips64: update tests for N32 ABI
Fix n32/n64 types mismatch in none, memcheck and helgrind tests.

BZ issue - #345763.

Contributed by:
  Dimitrije Nikolic, Aleksandar Rikalo, Tamara Vlahovic.
2018-06-14 17:40:08 +00:00
Petar Jovanovic
9a6cf7a41c mips64: add N32 ABI support
Adding MIPS N32 ABI support.

BZ issue - #345763.

Contributed and maintained by mulitple people over the years:
  Crestez Dan Leonard, Maran Pakkirisamy, Dimitrije Nikolic,
  Aleksandar Rikalo, Tamara Vlahovic.
2018-06-14 17:40:08 +00:00
Rhys Kidd
92d6a53886 Fix missing kevent_qos syscall (macOS 10.11). bz#383723
Based upon patch from Alexandru Croitor.
2018-06-03 12:53:18 -04:00
Philippe Waroquiers
6ef6f738ac Fix 372347 - Replacement problem of the additional c++14/c++17 new and delete operators
Patch by Paul Floyd, with comments slightly updated.

At the same time, cleanup of the trailing whitespaces in the whole file.

memcheck/tests/mismatches now shows the 'operator delete(void*, unsigned long)'
in the stacktrace, so updated the test expected output.
2018-05-29 21:10:13 +02:00
Philippe Waroquiers
cd65782db6 Add missing EXTRA_DIST file libstdc++.supp
Otherwise leak_cpp_interior test fails from a make dist tarball
2018-04-22 23:31:54 +02:00
Philippe Waroquiers
d9204e9eed Fix 393099 - posix_memalign() invalid write if alignment == 0
Bug and analysis by Gabriel Ganne
2018-04-15 08:06:43 +02:00
Philippe Waroquiers
ab773096df Fix 338252 - building valgrind with -flto (link time optimisation) fails
* Addition of a new configure option --enable-lto=yes or --enable-lto=no
  Default value is --enable-lto=no, as the build is significantly slower,
  so is not appropriate for valgrind development : this should be used
  only on buildbots and/or by packagers.

* Some files containins asm functions have to be compiled without lto:
    coregrind/m_libcsetjmp.c
    coregrind/m_main.c
  If these are compiled with lto, that gives undefined symbols at link time.
  The files to compile without lto are
    coregrind/m_libcsetjmp.c
    coregrind/m_main.c

  To compile these files with other options, a noinst target lib is defined.
  The objects of this library are then added to the libcoregrind.

* memcheck/mc_main.c : move the handwritten asm helpers to mc_main_asm.c.
  This avoids undefined symbols on some toolchains. Due to this,
  the preprocessor symbols that activate the fast or asm memcheck helpers
  are moved to mc_include.h
  Platforms with handwritten helpers will also have the memcheck primary
  map defined non static.

* In VEX, auxprogs/genoffsets.c also has to be compiled without lto,
  as the asm produced by the compiler is post-processed to produce
  pub/libvex_guest_offsets.h. lto not producing asm means the generation
  fails if we used -flto to compile this file.

* all the various Makefile*am are modified to use LTO_CFLAGS for
  (most) targets. LTO_CFLAGS is empty when --enable-lto=no,
  otherwise is set to the flags needed for gcc.
  If --enable-lto=no, LTO_AR and LTO_RANLIB are the standard AR and RANLIB,
  otherwise they are the lto capable versions (gcc-ar and gcc-ranlib).

* This has been tested on:
    debian 9.4/gcc 6.3.0/amd64+x86
    rhel 7.4/gcc 6.4.0/amd64
    ubuntu 17.10/gcc 7.2.0/amd64+x86
    fedora26/gcc 7.3.1/s390x

  No regressions on the above.
2018-03-18 13:53:38 +01:00
Philippe Waroquiers
1eaff3bbd7 remove obsolete/non working ways to modify CFLAGS in memcheck/Makefile.am
memcheck/Makefile.am contains 2 CFLAGS modifications lines that
are not working.
Remove these confusing lines.

(I have checked that the proper flags are still used for the 2 involved files)
2018-03-10 13:54:24 +01:00
Petar Jovanovic
2671481a5f add Iops Iop_Rotx32 and Iop_Rotx64
Part of MIPS32/64 Revision 6 changes.

Contributed by:
  Tamara Vlahovic, Aleksandar Rikalo and Aleksandra Karadzic.

Related BZ issue - #387410.
2018-02-01 18:09:56 +01:00
Petar Jovanovic
817011f8f7 mips: add support for Iop_Shr16 and Iop_Sar16
This should fix memcheck/tests/vbit-test/vbit-test on mips32/64 platforms.
2018-01-31 17:27:13 +01:00
Mark Wielaard
ea1c229392 Remove all extra -std=c99 flags from Makefiles.
Configure now makes sure we build everything in c99 mode already.
No need to have extra special cases in the Makefiles.
2018-01-19 13:52:29 +01:00
Mark Wielaard
190c93d454 Refix dlclose_leak.c test.
By introducing an extra line to declare int i; we broke the expected
line numbers in the test. Just declare i on the same line as the for loop.
2018-01-16 11:31:43 +01:00
Mark Wielaard
400ad0e36e Fix memcheck/tests/linux/dlclose_leak.c build under -std=gnu90.
Older gcc (4.8) default to GNU C90. Causing:

dlclose_leak.c:14:5: error: ‘for’ loop initial declarations are only
                     allowed in C99 mode

Fix by declaring int i before the loop.
2018-01-16 11:08:59 +01:00
Julian Seward
f8ae2f95d6 Bug 79362 - Debug info is lost for .so files when they are dlclose'd. Followup fix to avoid assertion failure when dlopening an object that has previously been dlclosed.
As reported by Matthias Schwarzott <zzam@gentoo.org>.  Testcase patch from him.  The fix is
for check_CFSI_related_invariants() to avoid checking for overlaps against DebugInfos that are
in 'archived' status, since -- if a previously dlopened-and-then-dlclosed object is later
re-dlopened -- this may cause an overlap between the active and archived DebugInfos, which
is of no consequence.  If the kernel maps the object to the same VMA the second time around
then there will *certainly* be an overlap.
2018-01-15 11:25:12 +01:00
Julian Seward
cceed053ce Bug 79362 - Debug info is lost for .so files when they are dlclose'd. Majorly reworked by Philippe Waroquiers. 2018-01-11 19:40:12 +01:00
Julian Seward
f1a49eeb42 Bug 385408 - s390x: z13 vector "support" instructions not implemented. Patch from Vadim Barkov (vbrkov@gmail.com).
(from bug 385408 comment 0):
Valgrind currently lacks support for the z/Architecture vector "support"
instructions introduced with z13.  These are documented in the
z/Architecture Principles of Operation, Eleventh Edition (March, 2015),
chapter 21: "Vector Overview and Support Instructions".
2018-01-11 18:20:27 +01:00
Julian Seward
0f18cfc986 Fix memcheck/tests/vbit-test (the vbit test program) to track changes in bug 387664.
Bug 387664 changes the default settings for accurate definedness checking
for {Add,Sub}{32,64} and {CmpEQ,CmpNE}{8,16,32,64}.  This fix updates the
vbit tester (memcheck/tests/vbit-test) to test the accurate versions of
these, and thereby fixes a regression caused by
e847cb5429927317023d8410c3c56952aa47fb08 as committed for bug 387664.
2018-01-03 11:55:44 +01:00
Julian Seward
f16ba15391 expensiveAddSub(): Fix incorrect comment. No functional change. 2018-01-03 11:38:14 +01:00
Julian Seward
e847cb5429 Bug 387664 - Memcheck: make expensive-definedness-checks be the default
Memcheck tries to accurately track definedness at the bit level, at least
for scalar integer operations.  For many operations it is good enough to use
approximations which may overstate the undefinedness of the result of an
operation, provided that fully defined inputs still produce a fully defined
output.  For example, the standard analysis for an integer add is

   Add#(x#, y#) = Left(UifU(x#, y#))

which (as explained in the USENIX 05 paper
http://valgrind.org/docs/memcheck2005.pdf) means: for an add, worst-case
carry propagation is assumed.  So all bits to the left of, and including,
the rightmost undefined bit in either operand, are assumed to be undefined.

As compilers have become increasingly aggressive, some of these
approximations are no longer good enough.  For example, LLVM for some years
has used Add operations with partially undefined inputs, when it knows that
the carry propagation will not pollute important parts of the result.
Similarly, both GCC and LLVM will generate integer equality comparisons with
partially undefined inputs in situations where it knows the result of the
comparison will be defined.  In both cases, Memcheck's default strategies
give rise to false uninitialised-value errors, and the problem is getting
worse as time goes by.

Memcheck already has expensive (non-default) instrumentation for integer
adds, subtracts, and equality comparisons.  Currently these are only used if
you specify --expensive-definedness-checks=yes, and in some rare cases to do
with inlined string operations, as determined by analysing the block to be
instrumented, and by default on MacOS.  The performance hit from them can be
quite high, up to 30% lossage.

This patch makes the following changes:

* During instrumentation, there is much finer control over which IROps get
  expensive instrumentation.  The following groups can now be selected
  independently for expensive or cheap instrumentation:

     Iop_Add32
     Iop_Add64
     Iop_Sub32
     Iop_Sub64
     Iop_CmpEQ32 and Iop_CmpNE32
     Iop_CmpEQ64 and Iop_CmpNE64

  This makes it possible to only enable, on a given platform, only the minimal
  necessary set of expensive cases.

* The default set of expensive cases can be set on a per-platform basis.
  This is set up in the first part of MC_(instrument).

* There is a new pre-instrumentation analysis pass.  It identifies Iop_Add32
  and Iop_Add64 uses for which the expensive handling will give the same
  results as the cheap handling.  This includes all adds that are used only
  to create memory addresses.  Given that the expensive handling of adds is,
  well, expensive, and that most adds merely create memory addresses, this
  more than halves the extra costs of expensive Add handling.

* The pre-existing "bogus literal" detection (0x80808080, etc) pass
  has been rolled into the new pre-instrumentation analysis.

* The --expensive-definedness-checks= flag has been changed.  Before, it
  had two settings, "no" and "yes", with "no" being the default.  Now, it
  has three settings:

   no -- always use the cheapest handling

   auto -- use the minimum set of expensive handling needed to get
           reasonable results on this platform, and perform
           pre-instrumentation analysis so as to minimise the costs thereof

   yes -- always use the most expensive handling

  The default setting is now "auto".  The user-visible effect of the new
  default is that there should (hopefully) be a drop in false positive rates
  but (unfortunately) also some drop in performance.
2017-12-12 10:22:51 +01:00
Julian Seward
0e7c46401b Fix this test to work properly with accurate CmpEQ/NE definedness tracking
Memcheck reports an error on "if (n == 42)" in this test.  Unless, that is,
accurate CmpEQ/NE definedness tracking is enabled.  If you stare at this
long enough it is possible to see that the test "n == 42" isn't actually
undefined, because |n| is only ever zero or one, and only its least
significant bit is undefined.  So the equality comparison against 42 is
defined because there are corresponding bits in the two operands that are
different and are both defined.

This commit fixes that by comparing with 1, which forces the result to
really depend on the only undefined bit in |n|.

I also added robustification:

* return arbitrary values from gcc_cant_inline_me(), so as to avoid gcc
  simply copying the input to the output or otherwise deleting the
  conditional branch.

* marking gcc_cant_inline_me() as un-inlineable

* Putting compiler barriers in the second conditional in main(), so gcc
  can't simply ignore the result of the call to gcc_cant_inline_me() and
  then delete the call entirely.
2017-12-07 13:31:38 +01:00
Julian Seward
ad92845f6b Rearrange sections in mc_translate.c. No functional change.
Rearrange big sections in mc_translate.c, so that the "main" instrumentation
function is at the end of the file rather than in the middle.  The previous
layout never made much sense.  The new layout is, roughly:

* stuff for baseline (level 2, non-origin tracking) instrumentation
* stuff for origin tracking (level 3) instrumentation
* the "final tidying" pass
* the main instrumentation function (and soon, a new pre-instrumentation
  analysis pass)
2017-12-05 12:04:17 +01:00
Julian Seward
c470e0c23c arm(32)-linux: add support for the TPIDRURW system register. Fixes #386425. 2017-11-20 11:43:55 +01:00
Ivo Raisr
6fbb3ddfe5 Add .stderr.exp file for memcheck/tests/linux/capget when running inside Docker container. 2017-11-15 23:37:17 +01:00
Ivo Raisr
c46053cc38 Optionally exit on the first error with --exit-on-first-error=<yes|no>.
Fixes BZ#385939.
Slightly modified patch by: Fauchet Gauthier <gauthier.fauchet@free.fr>
2017-11-04 14:31:22 +01:00
Philippe Waroquiers
2f9cceafa3 introduce a test for n-i-bz fix bug in strspn replacement
c1eace647ca4f670ef9bec0d0fe72cdd25a96394 fixed a bug in strspn replacement.
Add a test to cover this fix.
2017-10-28 15:02:11 +02:00
Petar Jovanovic
4686886774 mips: add support for MSA regs in Memcheck
Add support for MSA registers in Memcheck.

Contributed by:
  Tamara Vlahovic, Aleksandar Rikalo and Aleksandra Karadzic.

Related BZ issue - #382563.
2017-10-27 16:27:24 +02:00
Petar Jovanovic
91373819a3 mips: new Iops added to support MSA
New Iops are defined:
  Iop_Scale2_32Fx4, Iop_Scale2_64Fx2,
  Iop_Log2_32Fx4, Iop_Log2_64Fx2,
  Iop_F32x4_2toQ16x8, Iop_F64x2_2toQ32x4,
  Iop_PackOddLanes8x16, Iop_PackEvenLanes8x16,
  Iop_PackOddLanes16x8, Iop_PackEvenLanes16x8,
  Iop_PackOddLanes32x4, Iop_PackEvenLanes32x4.

Contributed by:
  Tamara Vlahovic, Aleksandar Rikalo and Aleksandra Karadzic.

Related BZ issue - #382563.
2017-10-27 16:27:24 +02:00
Carl Love
7fce2c5269 PPC64, Add support for the Data Stream Control Register (DSCR) 2017-10-03 12:03:22 -05:00
Petar Jovanovic
da3987aa18 mips32: add BE-exp files for several tests
This fixes several tests on mips32 BE platforms:

memcheck/tests/mips32/fadvise64
drd/tests/tc19_shadowmem
helgrind/tests/tc19_shadowmem
2017-10-02 14:54:20 +02:00
Petar Jovanovic
9fa2d21857 mips: fix typos for the recently added test
Correct name of the recently added test in Makefile.am.
2017-09-27 16:52:05 +02:00
Petar Jovanovic
8227e4a763 mips: new Memcheck test, bad_sioc
Check if Memcheck is able to recognize errors related to uninitialized
parameters in ioctl(SIOCSPGRP / SIOCATMARK) calls.

Test by Aleksandar Rikalo.
2017-09-27 15:55:16 +02:00
Philippe Waroquiers
f053756e28 Follow up to 345307 - Warning about "still reachable" memory when using libstdc++ from gcc 5
The bug itself was solved in 3.12 by the addition of __gnu_cxx::__freeres
in the libstdc++ and have valgrind calling it before exit.

However, depending on the version of the libstdc++, the test leak_cpp_interior
was giving different results.

This commit adds some filtering specific to the test, so as to not depend
anymore of the absolute number of bytes leaked, and adds a suppression entry to
ignore the memory allocated by libstdc++.

This allows to have only 2 .exp files, instead of 4 (or worse, if
we would have to handle yet other .exp files depending on the libstdc++
version).
2017-09-22 23:50:35 +02:00
Petar Jovanovic
211b0c303a mips: add clearing $ra to CLEAR_CALLER_SAVED_REGS macro
Return address register belongs to caller saved registers, and compiler can
use it to store temporary values. Clear it.
2017-09-15 16:04:18 +02:00
Rhys Kidd
55fe390c7a Fix missing pselect syscall (OS X 10.11). bz#379748
Based upon patch from Louis Brunner.
2017-09-03 12:55:52 -04:00
Julian Seward
5cc18ff30b Improve the implementation of expensiveCmpEQorNE.
.. so that the code it creates runs in approximately half the time it did
before.  This is in support of making the cost of expensive (exactly)
integer EQ/NE as low as possible, since the day will soon come when we'll
need to enable this by default.
2017-08-31 11:11:25 +02:00
Ivo Raisr
74b0936752 Mention AddrCheck at Memcheck's command line option --undef-value-errors=no 2017-08-28 12:43:34 +02:00
Petar Jovanovic
a1e5547a44 mips: remove incorrect implementation of several Iops
Remove incorrect implementation of
  Iop_DivModU64to32
  Iop_DivModS64to32
  Iop_DivModU128to64
  Iop_DivModS128to64
2017-08-22 16:05:00 +02:00
Petar Jovanovic
5f3cc6c828 mips: reimplement handling of div, divu and ddivu
Previous implementation misused some opcodes, and a side effect was
dead code emission.
To reimplement handling of these instructions, three new IoPs have been
introduced:

      Iop_DivModU64to64, // :: I64,I64 -> I128
                         // of which lo half is div and hi half is mod
      Iop_DivModS32to32, // :: I32,I32 -> I64
                         // of which lo half is div and hi half is mod
      Iop_DivModU32to32, // :: I32,I32 -> I64
                         // of which lo half is div and hi half is mod

Patch by Aleksandra Karadzic and Tamara Vlahovic.
2017-08-22 15:53:15 +02:00
Petar Jovanovic
9f3c890a9c mips: mute 'uninitialized' value compiler warning
fadvise64.c deliberately uses uninitialized value.
This patch removes the following warning:

warning: 'x' is used uninitialized in this function
2017-08-17 19:13:47 +02:00
Philippe Waroquiers
dc0fb705e9 Various minor fixes and correction in user manual and monitor command help
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@16466
2017-08-01 20:21:38 +00:00
Ivo Raisr
dfbf6cca38 Fix the Solaris build after development trunk has been renamed.
Effectively Solaris 12 is now becoming Solaris 11.4.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@16464
2017-07-31 15:24:08 +00:00
Mark Wielaard
2b5eab6a8d memcheck/tests: Use ucontext_t instead of struct ucontext
glibc 2.26 does not expose struct ucontext anymore.

Signed-off-by: Khem Raj <raj.khem@gmail.com>

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@16457
2017-06-29 15:26:30 +00:00
Mark Wielaard
3ac87cf927 epoll_pwait can have a NULL sigmask.
According to the epoll_pwait(2) man page:

       The  sigmask  argument  may  be  specified  as  NULL,  in  which  case
       epoll_pwait() is equivalent to epoll_wait().

But doing that under valgrind gives:

==13887== Syscall param epoll_pwait(sigmask) points to unaddressable byte(s)
==13887==    at 0x4F2B940: epoll_pwait (epoll_pwait.c:43)
==13887==    by 0x400ADE: main (syscalls-2007.c:89)
==13887==  Address 0x0 is not stack'd, malloc'd or (recently) free'd

This is because the sys_epoll_pwait wrapper has:

   if (ARG4)
      PRE_MEM_READ( "epoll_pwait(sigmask)", ARG5, sizeof(vki_sigset_t) );

Which looks like a typo (ARG4 is timeout and ARG5 is sigmask).

This shows up with newer glibc which translates an epoll_wait call into
an epoll_pwait call with NULL sigmask.

Fix typo and add a testcase.

https://bugs.kde.org/show_bug.cgi?id=381289

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@16451
2017-06-17 13:49:22 +00:00
Ivo Raisr
2cc0e531ec Port changes from r16407 to Solaris OS.
n-i-bz


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@16411
2017-05-23 21:37:50 +00:00
Ivo Raisr
f8a8e3de4d Fix expected output of brk tests after r16407.
n-i-bz


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@16410
2017-05-23 21:22:31 +00:00
Philippe Waroquiers
f488879e5f Removes a useless part of a condition, as discussed in bug 375415
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@16402
2017-05-20 16:13:33 +00:00
Petar Jovanovic
6618bb12bc mips32: remove assembler warning in memcheck/leak* tests
Use .set noat directive to prevent assembler from complaining about
subsequent instructions that use register $at.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@16400
2017-05-19 13:51:02 +00:00