]> git.ipfire.org Git - thirdparty/valgrind.git/log
thirdparty/valgrind.git
14 months agonightly/bin/nightly: Use grep -E instead of egrep
Mark Wielaard [Sun, 14 Apr 2024 19:42:12 +0000 (21:42 +0200)] 
nightly/bin/nightly: Use grep -E instead of egrep

14 months agoEnsure gdbserver tests work with a recent git version of GDB
Philippe Waroquiers [Sun, 14 Apr 2024 19:58:11 +0000 (21:58 +0200)] 
Ensure gdbserver tests work with a recent git version of GDB

Tested with GDB 12, 13, 14 and 15.0.50.20240414

14 months agoensure error output of vgdb relay mode is shown to the GDB user
Philippe Waroquiers [Sun, 14 Apr 2024 19:15:24 +0000 (21:15 +0200)] 
ensure error output of vgdb relay mode is shown to the GDB user

With GDB14.1, when there is more than one valgrind process, 'target remote | vgdb' shows:
  (gdb) tar rem | vgdb
  Remote debugging using | vgdb
  no --pid= arg given and multiple valgrind pids found:
  use --pid=913621 for ./Inst/bin/valgrind --vgdb-stop-at=startup ./gdbserver_tests/sleepers
  use --pid=913622 for ./Inst/bin/valgrind --vgdb-stop-at=startup ./gdbserver_tests/sleepers
  Remote communication error.  Target disconnected: Connection reset by peer.
  (gdb)

With GDB 15.0.50.20240414-git, we obtain:
  (gdb) tar rem | vgdb
  Remote debugging using | vgdb
  Remote communication error.  Target disconnected: error while reading: Connection reset by peer.
  (gdb)

This looks like a race condition:

When vgdb exits due to several pid or due to any other error (e.g. an argument
error), GDB gets a SIGPIPE and closes the pipe to/from vgdb.  To avoid losing
the error messages In such cases, have vgdb wait for the first packet from GDB
before exiting.

With this change, the early errors of vgdb are shown to the user.

Tested on debian, with GDB 12, 13, 15 and 15.0.50.20240414-git.

14 months agoBug 485148 - vfmadd213ss instruction is instrumented incorrectly (the remaining part...
Paul Floyd [Sun, 14 Apr 2024 15:59:30 +0000 (17:59 +0200)] 
Bug 485148 - vfmadd213ss instruction is instrumented incorrectly (the remaining part of the register is cleared instead of kept unmodified)

Initial version contributed by Bruno Lathuilière <bruno.lathuiliere@edf.fr>
Initial test contributed by Petr <kobalicek.petr@gmail.com>

14 months agoFreeBSD syscall: aio_error fails with EINVAL if the aiocb pointer is not accessible.
Paul Floyd [Sun, 14 Apr 2024 14:54:43 +0000 (16:54 +0200)] 
FreeBSD syscall: aio_error fails with EINVAL if the aiocb pointer is not accessible.

14 months agoAvoid format '%u' expect unsigned int warning
Philippe Waroquiers [Sun, 14 Apr 2024 14:28:37 +0000 (16:28 +0200)] 
Avoid format '%u' expect unsigned int warning

14 months agoFreeBSD regtest: fix for scalar sigaltstack
Paul Floyd [Sun, 14 Apr 2024 13:32:41 +0000 (15:32 +0200)] 
FreeBSD regtest: fix for scalar sigaltstack

I was lazy and using pointers to the same struct for the new and old
data (which isn't allowed, the new is 'restrict'). The current gets
copied to the old first so under Valgrind it worked. In the kernel
there are separate structs (which get copied in and copied out) and
it doesn't work.

Maybe we should consider changing VG_(do_sys_sigaltstack) to have at
least one local copy in order to behave like the kernel.

14 months agoAllow to see more details about suppressed errors.
Philippe Waroquiers [Sun, 14 Apr 2024 13:35:16 +0000 (15:35 +0200)] 
Allow to see more details about suppressed errors.

Extend --show-error-list=no|yes with all to allow to look also the
list of suppressed errors and see which supp entry is suppressing it.
Add an option also_suppressed in the monitor command 'c.vinfo all_errors'
to similarly be able to show the suppressed errors.

Small fix in check_makefile_consistency: avoid it considers emacs ~ files.

14 months agoFreeBSD regtest: setcontext only reads the context
Paul Floyd [Sun, 14 Apr 2024 13:31:22 +0000 (15:31 +0200)] 
FreeBSD regtest: setcontext only reads the context

14 months agoIllumos: also has wcpncpy
Paul Floyd [Sat, 13 Apr 2024 19:35:49 +0000 (21:35 +0200)] 
Illumos: also has wcpncpy

14 months agoregtest arm64: add a test for frinta and frintn
Paul Floyd [Sat, 13 Apr 2024 16:19:25 +0000 (18:19 +0200)] 
regtest arm64: add a test for frinta and frintn

Round ties above 0 (frinta) and to even (frintn). Both only scalar.
Vector not yet implemented.

14 months agoUpdate NEWS for bug476025
Paul Floyd [Sat, 13 Apr 2024 14:39:24 +0000 (16:39 +0200)] 
Update NEWS for bug476025

14 months agoamd64: Implement VFMADD213 for Iop_MAddF32 and Iop_MAddF64
Mark Wielaard [Sat, 13 Apr 2024 12:33:19 +0000 (14:33 +0200)] 
amd64: Implement VFMADD213 for Iop_MAddF32 and Iop_MAddF64

Speed up F32 and F64 FMA on amd64. Add priv/host_amd64_maddf.c
implementing h_amd64_calc_MAddF32_fma4 and h_amd64_calc_MAddF64_fma4
to be used instead of the generic variants h_generic_calc_MAddF32
and h_generic_calc_MAddF64 when host has VEX_HWCAPS_AMD64_FMA4.
Add fma3 and fma4 detection m_machine.c (machine_get_hwcaps).

This patch also fixes the memcheck/tests/vcpu_fnfns and
none/tests/amd64/fma testcases when run on a x86-64-v3 system.

Patch contributed by Grazvydas Ignotas <notasas@gmail.com> and
Bruno Lathuilière <bruno.lathuiliere@edf.fr>

https://bugs.kde.org/show_bug.cgi?id=481127
https://bugs.kde.org/show_bug.cgi?id=463463
https://bugs.kde.org/show_bug.cgi?id=463458

14 months agoAdd gethostbyname2_r to glibc-2.X-helgrind.supp.in
Mark Wielaard [Sat, 13 Apr 2024 01:03:26 +0000 (03:03 +0200)] 
Add gethostbyname2_r to glibc-2.X-helgrind.supp.in

This fixes helgrind/tests/getaddrinfo with glibc-2.28 which might
use gethostbyname2_r.

14 months agoregtest arm64: fixes for arm64 clang, part 5
Paul Floyd [Fri, 12 Apr 2024 18:50:39 +0000 (20:50 +0200)] 
regtest arm64: fixes for arm64 clang, part 5

last one for now
clang assembler not accepting sqrdmlah v0.4h, v1.4h, v2.4h[0]
It wants sqrdmlah v0.4h, v1.4h, v2.h[0]

14 months agoregtest arm64: fixes for arm64 clang, part 4
Paul Floyd [Fri, 12 Apr 2024 18:43:18 +0000 (20:43 +0200)] 
regtest arm64: fixes for arm64 clang, part 4

clang assembler being picky about unneeded annotations such as
LSL #0 but then insisting on a .0 that gas infers.

14 months agoregtest arm64: fixes for arm64 clang, part 3
Paul Floyd [Fri, 12 Apr 2024 18:28:05 +0000 (20:28 +0200)] 
regtest arm64: fixes for arm64 clang, part 3

clang assembler refuses to accept scvtf with q regs where v regs
should be used (again the arm manual agrees).

14 months agoregtest arm64: fixes for arm64 clang, part 2
Paul Floyd [Fri, 12 Apr 2024 18:14:18 +0000 (20:14 +0200)] 
regtest arm64: fixes for arm64 clang, part 2

More clang moans about using int where long long is expected
Also clang assembler refuses to accept opcodes like sub x21,x22,x23,sxtb
According to the arm manual it is right and it should be
sub x21,x22,w23,sxtb.
I asked on the LLVM discourse and they said they preferred to be strict
and unambiguous.

14 months agoregtest arm64: fixes for arm64 clang, part 1
Paul Floyd [Fri, 12 Apr 2024 17:59:35 +0000 (19:59 +0200)] 
regtest arm64: fixes for arm64 clang, part 1

clang warns about using integers where long longs are expected.
Secondly a few of the tests read the executable text. clang uses
different registers than GCC which causes a diff. Hence another
expected. The tests are potentially flaky so if we see instability
we need to modify the test.

14 months agolinux arm64: fix build with clang
Paul Floyd [Fri, 12 Apr 2024 10:50:07 +0000 (12:50 +0200)] 
linux arm64: fix build with clang

Same issue as https://bugs.kde.org/show_bug.cgi?id=421321
but with clang.

14 months agoAdd new helgrind race suppression for pth_mempcpy_false_races
Mark Wielaard [Fri, 12 Apr 2024 13:18:51 +0000 (15:18 +0200)] 
Add new helgrind race suppression for pth_mempcpy_false_races

In glibc 2.39+ the internal __printf_buffer_write might use memmove
instead of a memcpy variant. Add an extra suppression variant using
memmove.

This makes pth_mempcpy_false_races pass again.

See also https://bugs.kde.org/show_bug.cgi?id=450962

14 months agoAdd support for expensive cmpgt into vbits
Eyal Soha [Wed, 25 Oct 2023 03:52:56 +0000 (21:52 -0600)] 
Add support for expensive cmpgt into vbits

14 months agoAdd __set_vma_name suppression to drd/tests/std_thread2.supp
Mark Wielaard [Thu, 11 Apr 2024 17:48:22 +0000 (19:48 +0200)] 
Add __set_vma_name suppression to drd/tests/std_thread2.supp

glibc uses a atomic var to set whether the kernel supports
PR_SET_VMA_ANON_NAME. This looks like a conflicting access to drd.
Suppress it for this testcase.

14 months agoAdd memcheck/tests/linux/capget.stderr.exp4 variant
Mark Wielaard [Thu, 11 Apr 2024 16:29:01 +0000 (18:29 +0200)] 
Add memcheck/tests/linux/capget.stderr.exp4 variant

Add an expect file for capget where the inheritable bits are set,
when run as root.

14 months agoFreeBSD Helgrind: suppression for libstdc++ std::mutex::lock()
Paul Floyd [Mon, 8 Apr 2024 18:43:10 +0000 (20:43 +0200)] 
FreeBSD Helgrind: suppression for libstdc++ std::mutex::lock()

14 months agoDon't call vg_assert inside sync_signalhandler_from_kernel
Mark Wielaard [Fri, 5 Apr 2024 13:23:32 +0000 (15:23 +0200)] 
Don't call vg_assert inside sync_signalhandler_from_kernel

Calling vg_assert inside a core signal handler will mess up the core
backtrace. Making it even harder to find bugs in the core.

14 months agoUpdate libiberty demangler
Mark Wielaard [Wed, 3 Apr 2024 21:13:02 +0000 (23:13 +0200)] 
Update libiberty demangler

Update the libiberty demangler using the auxprogs/update-demangler
script to gcc git commit ca2f7c84927f85b95f0f48f82b93f1460c372db4.

This update includes:

* c++: mangle noexcept-expr [PR70790]
* c++: Fix templated convertion operator demangling
* c++: constrained hidden friends [PR109751]
* c++: mangle function template constraints
* Update copyright years.
* c++, demangle: Implement
  https://github.com/itanium-cxx-abi/cxx-abi/issues/148
  non-proposal
* libiberty: Invoke D demangler when --format=auto

14 months agoregtest: Add arm64 dir to DIST_SUBDIR
Paul Floyd [Wed, 3 Apr 2024 18:03:29 +0000 (20:03 +0200)] 
regtest: Add arm64 dir to DIST_SUBDIR

New directory was missing in memcheck/tests/Makefile.am

14 months agoBug 484935 - [patch] Valgrind reports false "Conditional jump or move depends on...
Paul Floyd [Wed, 3 Apr 2024 06:32:12 +0000 (08:32 +0200)] 
Bug 484935 - [patch] Valgrind reports false "Conditional jump or move depends on uninitialised value" errors for aarch64 signal handlers

Patch contributed by Peter Edwards <peadar@arista.com>

Testcase modified and added to a new directory, memcheck/tests/arm64

14 months agolinux regtest: merge the two prereq lines in memcheck sys-preadv2_pwritev2.vgtest
Paul Floyd [Tue, 2 Apr 2024 17:15:47 +0000 (19:15 +0200)] 
linux regtest: merge the two prereq lines in memcheck sys-preadv2_pwritev2.vgtest

I think only the last one gets used.

14 months agoregtest: fixes for old GCC versions
Paul Floyd [Tue, 2 Apr 2024 11:36:31 +0000 (13:36 +0200)] 
regtest: fixes for old GCC versions

Seen on arm64 with GCC 4.8.2

14 months agoregtest: one last change to none fdleak filter for arm64 linux
Paul Floyd [Mon, 1 Apr 2024 18:06:32 +0000 (20:06 +0200)] 
regtest: one last change to none fdleak filter for arm64 linux

14 months agoregtest: another fdleak filter in none/tests
Paul Floyd [Mon, 1 Apr 2024 17:59:20 +0000 (19:59 +0200)] 
regtest: another fdleak filter in none/tests

14 months agoFreeBSD DRD and Helgrind: add sem_clockwait_np wrappers
Paul Floyd [Sun, 31 Mar 2024 16:04:04 +0000 (18:04 +0200)] 
FreeBSD DRD and Helgrind: add sem_clockwait_np wrappers

Helgrind wrapper was complicated because sem_wait calls
sem_clockwait_np.

14 months agoDarwin: fix warning about unused Helgrind sem_timedwait wrapper
Paul Floyd [Sun, 31 Mar 2024 09:23:49 +0000 (11:23 +0200)] 
Darwin: fix warning about unused Helgrind sem_timedwait wrapper

14 months agoBug 484480 - False positives when using sem_trywait
Paul Floyd [Sat, 30 Mar 2024 15:31:12 +0000 (16:31 +0100)] 
Bug 484480 - False positives when using sem_trywait

14 months agoSolaris regtest: fix build of none socket_close
Paul Floyd [Sat, 30 Mar 2024 14:16:55 +0000 (15:16 +0100)] 
Solaris regtest: fix build of none socket_close

Also add to filter_fdleak

14 months agoSolaris: remove syscall close POST
Paul Floyd [Sat, 30 Mar 2024 12:25:13 +0000 (13:25 +0100)] 
Solaris: remove syscall close POST

And move the extra stuff that it did into PRE

15 months agoDarwin: add missing necp pieces
Paul Floyd [Fri, 29 Mar 2024 15:18:41 +0000 (16:18 +0100)] 
Darwin: add missing necp pieces

15 months agoDarwin regtest: add prereq for helgrind/tests/bug322621
Paul Floyd [Fri, 29 Mar 2024 14:50:03 +0000 (15:50 +0100)] 
Darwin regtest: add prereq for helgrind/tests/bug322621

It needs pthread_barrier which Darwin doesn't have

15 months agoDarwin: Helgrind suppressions for macOS 10.13
Paul Floyd [Fri, 29 Mar 2024 13:16:06 +0000 (14:16 +0100)] 
Darwin: Helgrind suppressions for macOS 10.13

15 months agoFreeBSD regtest: timerfd_settime has 4 args not 3
Paul Floyd [Fri, 29 Mar 2024 07:56:04 +0000 (08:56 +0100)] 
FreeBSD regtest: timerfd_settime has 4 args not 3

15 months agoregtest: rename none/tests/arm64/memory
Paul Floyd [Fri, 29 Mar 2024 06:33:29 +0000 (07:33 +0100)] 
regtest: rename none/tests/arm64/memory

This directory now contains a C++ test. 'memory' is also the name
of a C++ header. The include paths include ".". All that means that
if 'memory' builds before 'bug484426' then bug484426.cpp will try to
include the binary executable file 'memory' from the same directory
and not the header somewhere under /usr/include.

15 months agoBug 484426 - aarch64: 0.5 gets rounded to 0
Paul Floyd [Thu, 28 Mar 2024 19:55:38 +0000 (20:55 +0100)] 
Bug 484426 - aarch64: 0.5 gets rounded to 0

15 months agos390x: Update tracking of implemented insns for z16
Andreas Arnez [Wed, 27 Mar 2024 18:35:43 +0000 (19:35 +0100)] 
s390x: Update tracking of implemented insns for z16

List the instructions first introduced with z16 in s390-opcodes.csv.  Also
mention the unimplemented ones in guest_s390_toIR.c and add new extended
mnemonics to the script s390-check-opcodes.pl.  For ease of use, add
support for invoking the script without command line arguments.

15 months agos390x: Add support for NNPA facility vector instructions
Andreas Arnez [Wed, 27 Mar 2024 11:44:37 +0000 (12:44 +0100)] 
s390x: Add support for NNPA facility vector instructions

Add support for the vector instructions introduced with the NNPA facility,
i.e, VCNF, VCLFNH, VCFN, VCLFNL, and VCRNF.  These instructions convert
floating-point data between the usual binary FP format (IEEE) and the
NNPA-specific format.  Implement them with dirty helpers.

The NNPA instruction itself will be addressed with a separate patch.

15 months agocoverity: one dead code, one unread assignment and one NULL check
Paul Floyd [Thu, 28 Mar 2024 16:14:14 +0000 (17:14 +0100)] 
coverity: one dead code, one unread assignment and one NULL check

15 months agocoverity: dead code and overflows
Paul Floyd [Thu, 28 Mar 2024 08:06:23 +0000 (09:06 +0100)] 
coverity: dead code and overflows

Overflows deliberate. Dead code probably not.

15 months agoDarwin syscall: and now necp_client_action
Paul Floyd [Wed, 27 Mar 2024 20:09:11 +0000 (21:09 +0100)] 
Darwin syscall: and now necp_client_action

Also from Louis Brunner and also on 10.13 at least

15 months agoDarwin: add syswrap for necp_open
Paul Floyd [Wed, 27 Mar 2024 20:01:20 +0000 (21:01 +0100)] 
Darwin: add syswrap for necp_open

From Louis Brunner. It's marked for 10.15 in his repo but I get
--50575-- WARNING: unhandled amd64-darwin syscall: unix:501
on 10.13

15 months agoDarwin DRD: suppressions for macOS 10.13
Paul Floyd [Wed, 27 Mar 2024 19:51:02 +0000 (20:51 +0100)] 
Darwin DRD: suppressions for macOS 10.13

15 months agoDawrin regtest: mostly more filtering
Paul Floyd [Wed, 27 Mar 2024 14:53:42 +0000 (15:53 +0100)] 
Dawrin regtest: mostly more filtering

Changed str_tester to always call memcmp. Apple clang 10 seems
to evaluate some of these at compile time, and gets it wrong.
The runtime gets it right.

15 months agoDarwin regtest: add suppression for zone memalign
Paul Floyd [Wed, 27 Mar 2024 12:52:02 +0000 (13:52 +0100)] 
Darwin regtest: add suppression for zone memalign

15 months agoDarwin: merge some fixes for macOS up to 10.13
Paul Floyd [Wed, 27 Mar 2024 12:41:37 +0000 (13:41 +0100)] 
Darwin: merge some fixes for macOS up to 10.13

From https://github.com/LouisBrunner/valgrind-macos
Thanks, Louis Brunner

Before
== 742 tests, 312 stderr failures, 93 stdout failures, 0 stderrB failures, 0 stdoutB failures, 4 post failures ==

After
== 748 tests, 293 stderr failures, 71 stdout failures, 0 stderrB failures, 0 stdoutB failures, 4 post failures ==

15 months agoregtest: filter line numbers from memcheck tests that count suppressions
Paul Floyd [Wed, 27 Mar 2024 12:38:21 +0000 (13:38 +0100)] 
regtest: filter line numbers from memcheck tests that count suppressions

Now only one suppression file needed per test - no need for 32bit
versions. Need to use the same tag for each suppression variant though.

15 months agoDarwin regtest: fix build of memcheck rh2257546_128 and rh2257546_256
Paul Floyd [Wed, 27 Mar 2024 09:38:28 +0000 (10:38 +0100)] 
Darwin regtest: fix build of memcheck rh2257546_128 and rh2257546_256

No malloc.h

15 months agoBug 474160 - If errors-for-leak-kinds is specified, exit-on-first-error should only...
Eyal Soha [Tue, 2 Mar 2021 21:42:38 +0000 (14:42 -0700)] 
Bug 474160 - If errors-for-leak-kinds is specified, exit-on-first-error should only exit on one of the listed errors.

It's possible for the user to specify in the memcheck that some errors
should not cause an exit with the error-exitcode value.  For those
errors which would not cause an error exitcode, do not count them for
the purposes of exiting after the first error.

15 months agoBug 484002 - Add suppression for invalid read in glibc's __wcpncpy_avx2() via wcsxfrm()
Paul Floyd [Wed, 20 Mar 2024 20:22:37 +0000 (21:22 +0100)] 
Bug 484002 - Add suppression for invalid read in glibc's __wcpncpy_avx2() via wcsxfrm()

This needed a redirect, not a suppression.

15 months agoFreeBSD regtest: make bug483786 test a bit safer
Paul Floyd [Sun, 17 Mar 2024 07:36:08 +0000 (08:36 +0100)] 
FreeBSD regtest: make bug483786 test a bit safer

The uninit struct timespec can have large values so set it to 0
and use VALGRIND_MAKE_MEM_UNDEFINED to trigger the error.

15 months agoFreeBSD regtest: add a test for interrupted clock_nanosleep
Paul Floyd [Sun, 17 Mar 2024 07:01:48 +0000 (08:01 +0100)] 
FreeBSD regtest: add a test for interrupted clock_nanosleep

Also add missing files for bug483786

15 months agoBug 483786 -- Incorrect parameter indexing in FreeBSD clock_nanosleep syscall wrapper
Paul Floyd [Sun, 17 Mar 2024 06:41:42 +0000 (07:41 +0100)] 
Bug 483786 -- Incorrect parameter indexing in FreeBSD clock_nanosleep syscall wrapper

15 months agoFreeBSD regtest: change scalar so it runs OK in vgtest and a shell
Paul Floyd [Sun, 17 Mar 2024 06:07:43 +0000 (07:07 +0100)] 
FreeBSD regtest: change scalar so it runs OK in vgtest and a shell

15 months agoregtest: broaden one expected and one test suppression file
Paul Floyd [Sat, 16 Mar 2024 18:49:57 +0000 (19:49 +0100)] 
regtest: broaden one expected and one test suppression file

For linux arm.

15 months agoregtest: use in 'if' in memcheck/tests/manuel1
Paul Floyd [Sat, 16 Mar 2024 16:00:17 +0000 (17:00 +0100)] 
regtest: use in 'if' in memcheck/tests/manuel1

clang tends to use cmov and csel instructions with the result
that the undefinedness propagates into the printf with a variable
number of errors.

15 months agoAdd rh2257546_* to .gitignore
Paul Floyd [Sat, 16 Mar 2024 08:22:18 +0000 (09:22 +0100)] 
Add rh2257546_* to .gitignore

15 months agoregtest: add creat64 to debuginfo sdleak filters
Paul Floyd [Sat, 16 Mar 2024 07:48:10 +0000 (08:48 +0100)] 
regtest: add creat64 to debuginfo sdleak filters

All tests in none for pass for me on F39 amd64 with debuginfo
installed.

15 months agoresgtest: close inherited file desctiptors in none file_dclose and socket_close
Paul Floyd [Fri, 15 Mar 2024 21:15:25 +0000 (22:15 +0100)] 
resgtest: close inherited file desctiptors in none file_dclose and socket_close

15 months agoregtest: change rh2257546_256 prereq
Paul Floyd [Fri, 15 Mar 2024 18:56:20 +0000 (19:56 +0100)] 
regtest: change rh2257546_256 prereq

Need to check for machine cpu capabilities. configure will build
avx and avx2 as long as the assembler supports them.

15 months agoHandle gcc __builtin_strcmp using 128/256 bit vectors with sse4.1, avx/avx2
Julian Seward [Mon, 11 Mar 2024 16:53:14 +0000 (17:53 +0100)] 
Handle gcc __builtin_strcmp using 128/256 bit vectors with sse4.1, avx/avx2

* amd64 front end: redo the translation into IR for PTEST, so as to
  use only IROps which we know Memcheck can do exact instrumentation
  for.  Handling for both the 128- and 256-bit cases is has been
  changed.

* ir_opt.c: add some constant folding rules to support the above.  In
  particular, for the case `ptest %reg, %reg` (the same reg twice), we
  want rflags.C to be set to a defined-1 even if %reg is completely
  undefined.  Doing that requires folding `x and not(x)` to zero when
  x has type V128 or V256.

* memcheck/tests/amd64/rh2257546_{128,256}.c: new test cases

https://bugzilla.redhat.com/show_bug.cgi?id=2257546

15 months agoAdjust filter_fdleak for glibc debuginfo
Mark Wielaard [Fri, 15 Mar 2024 12:03:58 +0000 (13:03 +0100)] 
Adjust filter_fdleak for glibc debuginfo

With glibc debuginfo installed we might see syscal-template.S or
close.c replace that with "in ...libc...".

15 months agoMake sure socket file is created in socket_close testcase
Mark Wielaard [Fri, 15 Mar 2024 11:55:23 +0000 (12:55 +0100)] 
Make sure socket file is created in socket_close testcase

If the socket file already existed the path name wouldn't be recorded.
Explicitly unlink it before opening and binding the socket.  Adjust
none/tests/socket_close.stderr.exp for new path name and line numbers.

15 months agofdleaks: remove a VG(printf)
Paul Floyd [Fri, 15 Mar 2024 07:01:30 +0000 (08:01 +0100)] 
fdleaks: remove a VG(printf)

This was causing a few regtest failures for me

15 months agoregtest: un-inline fdleak close_inherited
Paul Floyd [Thu, 14 Mar 2024 07:12:23 +0000 (08:12 +0100)] 
regtest: un-inline fdleak close_inherited

I don't understand why but clang on FreeBSD arm64 seemed to
optimize away the 'stat' check. That caused failures due
to incorrect duplicate close errors.

15 months agoFreeBSD DRD: remove pthread_create suppression
Paul Floyd [Wed, 13 Mar 2024 21:16:31 +0000 (22:16 +0100)] 
FreeBSD DRD: remove pthread_create suppression

This is far too general. If a suppression is needed it needs to be much
more specific.

15 months agoFreeBSD syscall: improve closefrom to make it similar to cloase_range
Paul Floyd [Wed, 13 Mar 2024 20:34:08 +0000 (21:34 +0100)] 
FreeBSD syscall: improve closefrom to make it similar to cloase_range

Was missing ML_(record_fd_close) calls for the fds.

15 months agoUpdate gitignore for fdleak tests
Paul Floyd [Wed, 13 Mar 2024 19:32:40 +0000 (20:32 +0100)] 
Update gitignore for fdleak tests

15 months agoFreeBSD regtest: update filters for fdleak tests
Paul Floyd [Wed, 13 Mar 2024 19:30:47 +0000 (20:30 +0100)] 
FreeBSD regtest: update filters for fdleak tests

15 months agos390x: Fix definedness of syscall return value register
Andreas Arnez [Wed, 13 Mar 2024 16:47:59 +0000 (17:47 +0100)] 
s390x: Fix definedness of syscall return value register

The memcheck test case for the close_range syscall showed that Valgrind on
s390x doesn't correctly set the definedness of the return value register
after having invoked a system call.  Fix this.

15 months agoWith --track-fds=yes warn when file descriptor is closed a second time
Alexandra Hájková [Wed, 28 Feb 2024 08:02:15 +0000 (09:02 +0100)] 
With --track-fds=yes warn when file descriptor is closed a second time

We moved the record_fd_close call from POST to PRE sys_close handler,
because the POST handler is only called on success. Even if the close
syscall fails the file descriptor is still really closed/invalid.
In the PRE handler the file descriptor is about to be closed, but hasn't
been yet so we can capture also the description.

This patch add new field fd_closed to OpenFd structure to record if
the file descriptor was already closed.

We now capture a backtrace when closing file descriptors to be able to
print it in a case of a double close.  Always add '<' brackets '>' around
"unbound" in the description for consistency.

getsockdetails now takes and returns a buffer describing the socket
because we want to record it, not just print it.

Note that close_range is handled similar to closing each descriptor
individually. But the case when the close_range is called with an
infinite end (~0U) is treated special. Add a new record_fd_close_range
function which handles close_range with an infinite end so double
close by close_range isn't an error because we don't want to loop
over such a wide range.

Add a new test cases:
 - none/tests/socket_close.vgtest
   - tests double closing a socket
 - none/tests/double_close_range.vgtest
   - uses close_range to double close the file descriptors
 - none/tests/file_dclose.vgtest
   - double closing regular file with regular close syscall

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

Co-Authored-By: Mark Wielaard <mark@klomp.org>
15 months agoFreeBSD: fixed file mappings revisited
Paul Floyd [Wed, 13 Mar 2024 08:06:31 +0000 (09:06 +0100)] 
FreeBSD: fixed file mappings revisited

Revert to using the ELF fixed file flag, but keep the first
mapping so that it gets recorded to keep parse_procselfmaps
and ML_(read_elf_object) happy with what they see.

15 months agoFreeBSD regtest: make get_set_context platform independent with a filter
Paul Floyd [Sat, 9 Mar 2024 14:34:52 +0000 (15:34 +0100)] 
FreeBSD regtest: make get_set_context platform independent with a filter

Don't want to keep adding expecteds

15 months agoRegtest: add a prereq to check that close_range built
Paul Floyd [Fri, 8 Mar 2024 21:13:43 +0000 (22:13 +0100)] 
Regtest: add a prereq to check that close_range built

15 months agoFreeBSD syscall: fix PRE_MEM_READ for utrace
Paul Floyd [Fri, 8 Mar 2024 11:48:22 +0000 (12:48 +0100)] 
FreeBSD syscall: fix PRE_MEM_READ for utrace

15 months agoRegtest: fix a warning with older gcc with memcheck memalign_args
Paul Floyd [Fri, 8 Mar 2024 07:00:10 +0000 (08:00 +0100)] 
Regtest: fix a warning with older gcc with memcheck memalign_args

I guess that newer GCC extensions include more stuff.

15 months agoMove close_range in .gitignore
Paul Floyd [Thu, 7 Mar 2024 21:01:27 +0000 (22:01 +0100)] 
Move close_range in .gitignore

15 months agoMove close_range test from memcheck/tests/freebsd to memcheck/tests
Mark Wielaard [Thu, 7 Mar 2024 16:40:54 +0000 (17:40 +0100)] 
Move close_range test from memcheck/tests/freebsd to memcheck/tests

The close_range call is also available under linux and we already
have an appropriate configure call to test it. The only difference
is how the syscall arguments are called.

15 months agoFreeBSD syscall: fixes for semctl
Paul Floyd [Wed, 6 Mar 2024 20:19:23 +0000 (21:19 +0100)] 
FreeBSD syscall: fixes for semctl

On FreeBSD, the libc semctl function takes a union semun argument
for commands that take 4 arguments. It then gets that argument
via va_args and takes a pointer to it. That's what gets passed
to the sysctl - a pointer to union semun.

Previously we were handling the 4th argument as if it were
directly a union semun. This seems to have worked OK for years,
possibly due to luck concerning the way that va_args works
and/or the fact that the union is basically a union of
pointers. Recently I've been working on arm64 and there it
most definitely does not work.

15 months agoFreeBSD and macOS: change detection of when carry flag is being set
Paul Floyd [Mon, 4 Mar 2024 20:09:16 +0000 (21:09 +0100)] 
FreeBSD and macOS: change detection of when carry flag is being set

FreeBSD and macOS syscalls both have two return registers and
use the carry flag for the status. So syscall for client
needs to set the carry flag in the VexGuestArchState. That's
a bit much to do all in asm so we call VEX funtions.

But that doesn't play well with interrupts. There are labels
in ML_(do_syscall_for_client_WRK) so that we can work out
what to do if we get interrupted there. But there are no asm
labels in the VEX functions. Getting the address of the start
of the extern function is easy. There's no way in C to get
the length, and getting the address for the static helpers
is also messy.

I did bodge a solution whereby I put a dummy function in the
source file and scientifically crossed my fingers and hoped
that the compiler would lay out the object file in the same
way. And it did, at least for amd64 FreeBSD amd64 Darwin and
x86 FreeBSD (I don't have easy access to Darwin with working
x86).

Still, it's UB.

I recently tried the same thing for arm64 FreeBSD. And there
the functions are all over the shop in the object file.

So, time to do something a bit cleaner. I've removed all of
the hacky dummy functions and put a flag in the guest vex
state. For both amd64 and x86 there were spare padding
UInts that I've used. Arm64 won't be so lucky when I get there,
no spare padding words.

15 months agoFreeBSD regtest: add wildcards to none/tests/freebsd diffs
Paul Floyd [Sat, 2 Mar 2024 17:16:34 +0000 (18:16 +0100)] 
FreeBSD regtest: add wildcards to none/tests/freebsd diffs

15 months agoComment: explain why v.info location no longer detects stack guard pages on FreeBSD
Paul Floyd [Wed, 28 Feb 2024 21:00:37 +0000 (22:00 +0100)] 
Comment: explain why v.info location no longer detects stack guard pages on FreeBSD

Workaround: sysctl security.bsd.stack_guard_page=0

15 months agoFreeBSD regtest: fix value of CLOSE_RANGE_CLOEXEC in close_range test
Paul Floyd [Wed, 28 Feb 2024 19:01:05 +0000 (20:01 +0100)] 
FreeBSD regtest: fix value of CLOSE_RANGE_CLOEXEC in close_range test

Spotted by Mark Wielaard, thanks.

15 months agoFreeBSD regtest: add a test with sanity lvel 3 and threads
Paul Floyd [Wed, 28 Feb 2024 18:57:05 +0000 (19:57 +0100)] 
FreeBSD regtest: add a test with sanity lvel 3 and threads

15 months agoFreeBSD regtest: filter sanity level >= 3 warnings about transparent stack mmaps
Paul Floyd [Wed, 28 Feb 2024 18:37:02 +0000 (19:37 +0100)] 
FreeBSD regtest: filter sanity level >= 3 warnings about transparent stack mmaps

16 months agoAdd Unlicense to coregrind/m_debuginfo/tinfl.c
Mark Wielaard [Tue, 27 Feb 2024 12:36:39 +0000 (13:36 +0100)] 
Add Unlicense to coregrind/m_debuginfo/tinfl.c

The tinfl.c file comes from the public domain miniz project.
Upstream added an explicit Public Domain declaration using
the Unlicense. No other changes were made, so all our valgrind
specific changes still apply. This doesn't really change the
license as used for our derived version, which is distributed
under GPLv2+. But it adds some history and a legal statement
that is more clear than just saying "public domain".

This is the upstream commit:

commit e8dfb6599a2294584571ad4806dc4e300323858c
Author: Rich Geldreich <richgel99@gmail.com>
Date:   Sat May 28 22:15:49 2011 +0000

    added unlicense.org statement

16 months agoFreeBSD: experimental fix for --sanity-level=3 and above
Paul Floyd [Sun, 25 Feb 2024 18:10:37 +0000 (19:10 +0100)] 
FreeBSD: experimental fix for --sanity-level=3 and above

Previously this failed due to split mmap mappings for MAP_STACK.
This change tries to piece together such stack mappings. This
mainly affects multithreaded apps when they create their thread
stacks.

16 months agoFreeBSD: clean up guest stack creation code
Paul Floyd [Sun, 25 Feb 2024 13:50:57 +0000 (14:50 +0100)] 
FreeBSD: clean up guest stack creation code

At one time I thought of using sysctls to get the same stack
max size and growth size as the OS uses. But that won't work
for x86 on amd64. So I've just cleaned the code a bit and
added more comments explaining what is going on.

16 months agolinux arm64: fix a couple of clang warnings about word length
Paul Floyd [Sat, 24 Feb 2024 12:57:58 +0000 (13:57 +0100)] 
linux arm64: fix a couple of clang warnings about word length

16 months agoarm64 regtest: add regtest leftovers to gitignore
Paul Floyd [Sat, 24 Feb 2024 12:56:22 +0000 (13:56 +0100)] 
arm64 regtest: add regtest leftovers to gitignore

16 months agolinux regtest: helgrind bar_bad expected for ppc64le
Paul Floyd [Sat, 24 Feb 2024 08:03:35 +0000 (09:03 +0100)] 
linux regtest: helgrind bar_bad expected for ppc64le

16 months agolinux regtest: update helgrind bar_bad
Paul Floyd [Fri, 23 Feb 2024 21:04:02 +0000 (22:04 +0100)] 
linux regtest: update helgrind bar_bad