1292 Commits

Author SHA1 Message Date
Paul Floyd
49fe0dc74a Anticipate testcase problems with GCC 12
There will be a lot more to come.

On amd64 Linux
In faultstatus was seeing the division by zero and emitting a ud2 opcode.
In wrap3 a pair of mutually recursive functions were being inlined.
When forced not to be inlined GCC merged them into a single function.
It cannot see that the client requests have diffeent behaviour.
2021-11-23 23:37:02 +01:00
Paul Floyd
e484eee0bd Bug 445300 [PATCH] Fix building tests with Musl
Patch contributed by
   Alyssa Ross <hi@alyssa.is>
2021-11-22 08:42:53 +01:00
Mark Wielaard
8ad4c01880 memcheck/tests/libstdc++.supp: rename suppression
The name malloc-leaks-cxx-stl-string-classes-debug was confusing
since the suppression wasn't a leak, not part of stl, string,
classes or debug. Rename it to libstdcxx-emergency-eh-alloc-pool
to indicate it is part of the emergency exception handling memory
pool.

Note that suppression is only needed for some test cases, normally
the pool is cleaned up as part of cxx_freeres.
2021-11-19 15:00:30 +01:00
Paul Floyd
f13667b1ef Bug 445607 Unhandled amd64-freebsd syscall: 247
I can't find much in the way of documentation for this.
Added to scalar, but no specific tests.
2021-11-17 23:15:23 +01:00
Paul Floyd
83dda2b71a Bug 444925 fexecve syscall wrapper not properly implemented
Implement fexecve and a few testcases on FreeBSD.
2021-11-14 22:06:14 +01:00
Paul Floyd
39b4bbe3a1 Bugs 435732 and 403802 again
This time with debuginfo removed.

Also update the vgtest files for a couple of massif tests
(and also the expected because of the commmand line change).
Not yet tested these two with debuginfo installed.
2021-11-13 12:31:41 +01:00
Paul Floyd
7d47865aa7 No longer need FreeBSD expected for C++ demangle test 2021-11-13 00:25:43 +01:00
Paul Floyd
e24f3b6b21 Bugs 435732 and 403802
The problem is that the testcase specific suppression has stacks
that are too specific. This causes breakage with different versions
of GCC and libstdc++. The suppression only needs to mask the memory
pool used for standard io.

There are several suppression stanzas so future tweaks may still be
necessary.
2021-11-13 00:00:38 +01:00
Paul Floyd
c09706352a Make memcheck tests demangle and demangle-rust clang-friendly.
Clang uses CMOV for ternary operators which does not immediately
trigger an error. Using double free and new/free mismatch still
poses no problem with clang but still uses the demangling.

Also update .gitignore
2021-11-12 23:44:54 +01:00
Julian Seward
530df882b8 Bug 444399 - disInstr(arm64): unhandled instruction 0xC87F2D89 (LD{,A}XP and ST{,L}XP).
This is unfortunately a big and complex patch, to implement LD{,A}XP and
ST{,L}XP.  These were omitted from the original AArch64 v8.0 implementation
for unknown reasons.

(Background) the patch is made significantly more complex because for AArch64
we actually have two implementations of the underlying
Load-Linked/Store-Conditional (LL/SC) machinery: a "primary" implementation,
which translates LL/SC more or less directly into IR and re-emits them at the
back end, and a "fallback" implementation that implements LL/SC "manually", by
taking advantage of the fact that V serialises thread execution, so we can
"implement" LL/SC by simulating a reservation using fields LLSC_* in the guest
state, and invalidating the reservation at every thread switch.

(Background) the fallback scheme is needed because the primary scheme is in
violation of the ARMv8 semantics in that it can (easily) introduce extra
memory references between the LL and SC, hence on some hardware causing the
reservation to always fail and so the simulated program to wind up looping
forever.

For these instructions, big picture:

* for the primary implementation, we take advantage of the fact that
  IRStmt_LLSC allows I128 bit transactions to be represented.  Hence we bundle
  up the two 64-bit data elements into an I128 (or vice versa) and present a
  single I128-typed IRStmt_LLSC in the IR.  In the backend, those are
  re-emitted as LDXP/STXP respectively.  For LL/SC on 32-bit register pairs,
  that bundling produces a single 64-bit item, and so the existing LL/SC
  backend machinery handles it.  The effect is that a doubleword 32-bit LL/SC
  in the front end translates into a single 64-bit LL/SC in the back end.
  Overall, though, the implementation is straightforward.

* for the fallback implementation, it is necessary to extend the guest state
  field `guest_LLSC_DATA` to represent a 128-bit transaction, by splitting it
  into _DATA_LO64 and DATA_HI64.  Then, the implementation is an exact
  analogue of the fallback implementation for single-word LL/SC.  It takes
  advantage of the fact that the backend already supports 128-bit CAS, as
  fixed in bug 445354.  As with the primary implementation, doubleword 32-bit
  LL/SC is bundled into a single 64-bit transaction.

Detailed changes:

* new arm64 guest state fields LLSC_DATA_LO64/LLSC_DATA_LO64 to replace
  guest_LLSC_DATA

* (ridealong fix) arm64 front end: a fix to a minor and harmless decoding bug
  for the single-word LDX/STX case.

* arm64 front end: IR generation for LD{,A}XP/ST{,L}XP: tedious and
  longwinded, but per comments above, an exact(ish) analogue of the singleword
  case

* arm64 backend: new insns ARM64Instr_LdrEXP / ARM64Instr_StrEXP to wrap up 2
  x 64 exclusive loads/stores.  Per comments above, there's no need to handle
  the 2 x 32 case.

* arm64 isel: translate I128-typed IRStmt_LLSC into the above two insns

* arm64 isel: some auxiliary bits and pieces needed to handle I128 values;
  this is standard doubleword isel stuff

* arm64 isel: (ridealong fix): Ist_CAS: check for endianness of the CAS!

* arm64 isel: (ridealong) a couple of formatting fixes

* IR infrastructure: add support for I128 constants, done the same as V128
  constants

* memcheck: handle shadow loads and stores for I128 values

* testcase: memcheck/tests/atomic_incs.c: on arm64, also test 128-bit atomic
  addition, to check we really have atomicity right

* testcase: new test none/tests/arm64/ldxp_stxp.c, tests operation but not
  atomicity.  (Smoke test).
2021-11-12 12:13:45 +01:00
Mark Wielaard
d151907e5d Add demangle-rust to check_PROGRAMS
The demangle-rust.vgtest would fail because the demangle-rust binary
wasn't build by default. Add it to check_PROGRAMS and define
demangle_rust_SOURCES to make sure it is always build.
2021-11-11 18:02:18 +01:00
Mark Wielaard
a0ee664023 Add scalar.stderr.exp-freebsd130-x86 to EXTRA_DIST 2021-11-10 09:05:20 +01:00
Mark Wielaard
c1bfa115f9 Add demangle-rust.vgtest demangle-rust.stderr.exp to EXTRA_DIST 2021-11-10 09:02:36 +01:00
Nicholas Nethercote
4831385c67 Fix Rust v0 demangling.
It's currently broken due to a silly test that prevents the v0
demangling code from even running.

The commit also adds a test, to avoid such problems in the future.
2021-11-10 10:03:06 +11:00
Paul Floyd
d1d74d7985 Some FreeBSD cleaning
Add a scalar expected for FreeBSD 13 i386
Add SIGLIBRT define
2021-11-09 23:19:19 +01:00
Mark Wielaard
f1afb63ffd vbit-test F16 Iops are tested on the wrong architectures
Because of what looks like some copy/paste issues the new F16 Iops
seem to be tested on the wrong architectures. They are only implemented
on arm64. So this patch only enables them for arm64.

https://bugs.kde.org/show_bug.cgi?id=444831
2021-11-08 17:12:12 +01:00
Paul Floyd
5675b90cc0 Previous fix was out by one version tag.
memalign must have been added with FreeBSD 12.2
2021-10-12 23:33:17 +02:00
Paul Floyd
79a1439786 Fix building memalign2 test on older FreeBSD 2021-10-12 21:47:45 +02:00
Mark Wielaard
0b86d267c6 filter_xml: Filter out '@*' from <fn> symbol names
With glibc 2.34 we would start seeing some function names ending in
'@*' this was already filtered out using drd/tests/filter_stderr.in
but not when using the drd xml tests. This would make
drd/tests/thread_name_xml and drd/tests/bar_bad_xml fail.

Filter this out in the memcheck/tests/filter_xml script, which is
also used by the drd test filters.

Tested against glibc 2.34, 2.33 and 2.17 on x86_64.
2021-10-12 20:01:52 +02:00
Paul Floyd
2269aeb76c Dnother iteration for getting the right expected line numbers. 2021-10-11 08:16:32 +02:00
Paul Floyd
46607a76bd memalign is available on FreeBSD as a non-portable interface
Remove #if block protecting memalign calls
2021-10-10 22:15:59 +02:00
Paul Floyd
8c0f72667e Fix the ramaining easily fixable warnings with clang
There's one remaining
memalign2.c:29:9: warning: unused variable 'piece' [-Wunused-variable]
because of a block of #if FreeBSD for memalign that looks unnecessary

Otherwise all that is left is a few like

warning: unknown warning option '-Wno-alloc-size-larger-than'; did you mean '-Wno-frame-larger-than='? [-Wunknown-warning-option]

because there is no standard for compiler arguments.
2021-10-10 21:56:49 +02:00
Mark Wielaard
bfd28bb9f8 Remove more warnings from tests
GCC12 catches various issues in tests at compile time that we want to
catch at runtime. Also glibc 2.34 deprecated various mallinfo related
functions. Add the relevant -Wno-foobar flags to those tests.  In one
case, unit_oset.c, the warning was correct and the uninitialized
variable was explicitly set.
2021-10-10 17:19:34 +02:00
Mark Wielaard
4015813336 Remove some warnings from tests
Various tests do things which we want to detect at runtime, like
ignoring the result of malloc or doing a deliberate impossibly large
allocation or operations that would result in overflowing or
truncated strings, that generate a warning from gcc.

In once case, mq_setattr called with new and old attrs overlapping,
this was explicitly fixed, in others -Wno-foobar was added to silence
the warning. This is safe even for older gcc, since a compiler will
ignore any -Wno-foobar they don't know about - since they do know they
won't warn for foobar.
2021-10-10 15:56:50 +02:00
Paul Floyd
d187106a76 Updating a few expecteds based on valgrind-testresults
I tried to work out what the expecteds should be based on the changes to
the testcase source so there may be a bit more to do.
2021-10-10 12:03:38 +02:00
Paul Floyd
1bbd829adb FreeBSD support, patch 10
Missing new expected file
2021-10-09 12:51:41 +02:00
Paul Floyd
7c5d720a2b FreeBSD support, patch 10
memcheck
No code changes. A few modified tests. Adds new FreeBSD specific tests.
2021-10-09 12:37:17 +02:00
Paul Floyd
e2583c02a5 FreeBSD support, patch 2
Files in the root directory
Several Makefile.am files that have dependencies on FreeBSD autoconf
variables. Included a few new filter files to act as placeholders
to create new freebsd subdirectories.

Updated NEWS with the FreeBSD bugzilla items plus a couple of other
items fixed indirectly.
2021-10-07 08:18:47 +02:00
Amanieu d'Antras
c2e0ab8694 Update libiberty demangler to support Rust v0 name mangling
Update the libiberty demangler using the auxprogs/update-demangler
script to the gcc git 01d92cfd79872e4cffc78bf233bb9b767336beb8.
Updates rust demangling to support the new v0 mangling scheme.

This includes the following changes:
- Update the update-demangler script to use gcc git instead of svn.
- The result of running the updated script to get an updated
  demangler and resolving the merge conflicts.
- A change to long_namespace_xml.stderr.exp because two overly long
  symbols aren't demangled anymore, but just returned as is.
- an update to the m_demangle/demangle.c source to deal with Rust
  demangling in cp_demangle, which now directly demangles old and
  new style rust symbols.
2021-09-26 12:42:26 +02:00
Andreas Arnez
62b7052ab5 s390x: Vec-enh-2, test cases
Add test cases for verifying the new/enhanced instructions in the
vector-enhancements facility 2.  For "vector string search" VSTRS add a
memcheck test case.
2021-09-01 14:44:16 +02:00
Assad Hashmi
c5331315d7 Bug 438038 Adds arm64 v8.2 FP compare & conditional compare instructions.
This patch adds half-precision floating-point support for the following:
FCCMP <Hn>, <Hm>, #<nzcv>, <cond>
FCCMPE <Hn>, <Hm>, #<nzcv>, <cond>
FCMEQ <Hd>, <Hn>, <Hm>
FCMEQ <Vd>.<T>, <Vn>.<T>, <Vm>.<T>
FCMGE <Hd>, <Hn>, <Hm>
FCMGE <Vd>.<T>, <Vn>.<T>, <Vm>.<T>
FCMGT <Hd>, <Hn>, <Hm>
FCMGT <Vd>.<T>, <Vn>.<T>, <Vm>.<T>

Fixes https://bugs.kde.org/show_bug.cgi?id=438038
2021-06-29 10:10:54 -04:00
Assad Hashmi
f048559cb0 Bug 436873 Added arm64 v8.2 vector FABD, FACGE, FACGT and FADD
This patch adds FP half-precision support for the following:
FADD <Vd>.<T>, <Vn>.<T>, <Vm>.<T>
FABD <Vd>.<T>, <Vn>.<T>, <Vm>.<T>
FACGT <Vd>.<T>, <Vn>.<T>, <Vm>.<T>
FACGE <Vd>.<T>, <Vn>.<T>, <Vm>.<T>

Fixes https://bugs.kde.org/show_bug.cgi?id=436873
2021-06-08 12:02:06 -04:00
Assad Hashmi
3ac8615140 Bug 436411 Added arm64 v8.2 scalar FABD, FACGE, FACGT and FADD
This patch adds FP half-precision support for the following:
FADD <Hd>, <Hn>, <Hm>
FABD <Hd>, <Hn>, <Hm>
FACGT <Hd>, <Hn>, <Hm>
FACGE <Hd>, <Hn>, <Hm>

Fixes https://bugs.kde.org/show_bug.cgi?id=436411
2021-06-08 06:20:58 -04:00
Andreas Arnez
cae5062b05 s390x: Add missing stdout.exp for vector string memcheck test
The file vistr.stdout.exp was missing from commit 32312d588.  Add it.
2021-05-07 18:13:17 +02:00
Andreas Arnez
32312d588b Bug 434296 - s390x: Add memcheck test cases for vector string insns
Bug 434296 addresses memcheck false positives with the vector string
instructions VISTR, VSTRC, VFAE, VFEE, and VFENE.  Add test cases that
verify the fix for that bug.  Without the fix, memcheck yields many
complains with these tests, most of which are false positives.
2021-05-07 17:16:57 +02:00
Andreas Arnez
d74a637206 Bug 433863 - s390x: Remove memcheck test cases for cs, cds, and csg
The fix for bug 429864 - "s390x: C++ atomic test_and_set yields
false-positive memcheck diagnostics" changes the memcheck behavior at
various compare-and-swap instructions.  The comparison between the old and
expected value now always yields a defined result, even if the input
values are (partially) undefined.  However, some existing test cases
explicitly verify that memcheck complains about the use of uninitialised
values here.  These test cases are no longer valid.  Remove them.
2021-04-28 19:26:03 +02:00
Bart Van Assche
7cd4d78163 memcheck/tests/linux/stack_changes: Only run this test if setcontext() is available
See also https://bugs.kde.org/show_bug.cgi?id=434775 .
2021-03-28 20:48:22 -07:00
Mark Wielaard
3751e963fa Add memcheck/tests/linux/debuginfod-check.pl to EXTRA_DIST
debuginfod-check.pl is necessary as pre-check for make regtest.
2021-03-15 15:47:54 +01:00
Paul Floyd
f9ee4517a0 Modify cxx17_aligned_new testcase to accommdate clang.
Explicitly use ordinary scalar delete and update the expecteds.
Otherwise g++ uses sized scalar delete whilse clang uses
ordinary scalar delete which causes a diff.
2021-03-02 17:48:14 +01:00
Paul Floyd
e42badd060 Bug 388787 - Support for C++17 new/delete
These over-aligned new and delete operators were added in C++ 17.
2021-03-02 13:32:22 +01:00
Mark Wielaard
24a94df738 VG_(get_fnname_kind): Recognize gcc "optimized" below main functions.
The VG_(get_fnname_kind) function detects some special "below main"
function names. Specifically __libc_start_main and generic_start_main
both of which are used to call the actual main () function from the
application. We already recognized one variant, generic_start_main.isra.0,
but only for powerpc. Recognize all possibly specialed optimized variants
gcc can produce by simply checking for the function name with dot as
prefix. This fixes the memcheck/tests/supp_unknown.vgtest and
massif/tests/deep-D.vgtest with gcc 11.

We can now also get rid of the special cases in
massif/tests/deep-D.post.exp-ppc64 and memcheck/tests/supp_unknown.supp.

https://bugs.kde.org/show_bug.cgi?id=430158
2021-03-01 00:26:00 +01:00
Aaron Merey
fd4e3fb0ff PR432215 Add debuginfod functionality
debuginfod is an HTTP server for distributing ELF/DWARF debugging
information.  When a debuginfo file cannot be found locally, Valgrind
is able to query debuginfod servers for the file using its build-id.

readelf.c: Add debuginfod_find_debug_file(). Spawns a child process to
exec `debuginfod-find` in order to query servers for the debuginfo
file. Also add helper debuginfod_find_path().

pub_core_pathscan.h: Moved from priv_initimg_pathscan.h in order to use
VG_(find_executable)() in readelf.c.

docs: Add information regarding debuginfod to valgrind.1

memcheck/tests/linux: Add new test debuginfod-check.

tests/vg_regtest.in: Clear $DEBUGINFOD_URLS before running any tests.

https://bugs.kde.org/show_bug.cgi?id=432215
2021-02-26 01:38:42 +01:00
Carl Love
affeb57ccd PPC64: ISA 3.1 (new Iops) 128-bit Binary Integer Operations
Add support for:

  dcffixqq DFP Convert From Fixed Quadword Quad
  dctfixqq DFP Convert To Fixed Quadword Quad

  vdivesq Vector Divide Extended Signed Quadword
  vdiveuq Vector Divide Extended Unsigned Quadword
  vdivsq Vector Divide Signed Quadword
  vdivuq Vector Divide Unsigned Quadword

  vmodsq Vector Modulo Signed Quadword
  vmoduq Vector Modulo Unsigned Quadword
  vmulesd Vector Multiply Even Signed Doubleword
  vmuleud Vector Multiply Even Unsigned Doubleword
  vmulosd Vector Multiply Odd Signed Doubleword
  vmuloud Vector Multiply Odd Unsigned Doubleword
  vmsumcud Vector Multiply-Sum & write Carry-out Unsigned Doubleword

  xscvqpsqz VSX Scalar Convert with round to zero Quad-Precision to Signed
    Quadword
  xscvqpuqz VSX Scalar Convert with round to zero Quad-Precision toUnsigned
    Quadword
  xscvsqqp VSX Scalar Convert Signed Quadword to Quad-Precision
  xscvuqqp VSX Scalar Convert Unsigned Quadword to Quad-Precision
2021-02-25 11:15:06 -06:00
Allison Karlitskaya
dec3050653 Linux: Add wrapper for fcntl(F_{GET,ADD}_SEALS)
Add also a testcase to memcheck/tests/linux, enabled according to a new
check for memfd_create() in configure.ac.

https://bugs.kde.org/show_bug.cgi?id=361770
2021-02-20 21:04:12 +01:00
Mark Wielaard
1c9a0bf58a PR217695 malloc/calloc/realloc/memalign failure doesn't set errno to ENOMEM
When one of the allocation functions in vg_replace_malloc failed
they return NULL, but didn't set errno. This is slightly tricky since
errno is implementation defined and might be a macro. In the case of
glibc ernno is defined as:

  extern int *__errno_location (void) __THROW __attribute__ ((__const__));
  #define errno (*__errno_location ())

We can use the same trick as we use for __libc_freeres in
coregrind/vg_preloaded.c. Define the function as "weak". This means
it will only be defined if another library (glibc in this case)
actually provides a definition. Otherwise it will be NULL.
So we will only call it if it is defined and one of the allocation
functions failed, returned NULL.

Include a new linux only memcheck testcase, enomem.vgtest.

https://bugs.kde.org/show_bug.cgi?id=217695
2021-02-17 13:14:41 +01:00
Assad Hashmi
7593a47739 Bug 432161 Addition of arm64 v8.2 FADDP, FNEG and FSQRT
This patch adds FP half-precision support for the following:
FABS <Hd>, <Hn>
FABS <Vd>.<T>, <Vn>.<T>
FNEG <Hd>, <Hn>
FNEG <Vd>.<T>, <Vn>.<T>
FSQRT <Hd>, <Hn>
FSQRT <Vd>.<T>, <Vn>.<T>

Fixes https://bugs.kde.org/show_bug.cgi?id=432161
2021-01-29 08:38:40 -05:00
Julian Seward
3b1710d38c Bug 413547 - regression test does not check for Arm 64 features.
Patches from/by Assad Hashmi (assad.hashmi@linaro.org).
2021-01-07 08:34:14 +01:00
Paul Floyd
5db136ee36 Add an extra suppression.
On Fedora 33 with gcc (GCC) 10.2.1 20201125 (Red Hat 10.2.1-9)
it looks like fun:__static_initialization_and_destruction_0 is
now inlined which causes the existing suppression for the
same reachable to no longer match.
2020-12-30 13:57:39 +01:00
Paul Floyd
6e5213028c Make memcheck/tests/sized_delete conditional upon the compiler having -fsized-deallocators, add 384729 to NEWS 2020-11-10 14:52:19 +01:00
Paul Floyd
e300cb0d8d Pushed binary by mistake 2020-11-09 16:10:52 +01:00