Paul Floyd [Thu, 21 Nov 2024 07:24:35 +0000 (08:24 +0100)]
Helgrind: fix unused result of write warnings
Thanks to GCC deciding that we can't ignore wur annotated
functions by casting to void we need to do otherwise. It was
either pragmas or adding an annotated unused local. Pragmas
seem to be the least awful.
Bart Van Assche [Mon, 18 Nov 2024 21:15:36 +0000 (13:15 -0800)]
drd: Split handle_client_request()
Make handle_client_request() easier to read by splitting it into two
functions: one for Valgrind core client requests and one for thread-
related client requests.
Mark Wielaard [Thu, 14 Nov 2024 11:25:27 +0000 (12:25 +0100)]
coregrind/m_gdbserver/remote-utils.c (prepare_resume_reply): Use memcpy
GCC8 (but apparently not later versions) complain about the use of
strncpy when not actually copying a string:
remote-utils.c:1140:14: warning: 'char* strncpy(char*, const char*, size_t)' output truncated before terminating nul copying 6 bytes from a string of the same length [-Wstringop-truncation]
strncpy (buf, "watch:", 6);
~~~~~~~~^~~~~~~~~~~~~~~~~~
This is "harmless" because buf is large enough and we will add more
chars (including a zero terminator) later. But using strncpy here is a
bit odd because we don't really want to copy a string, but an array of
6 chars. So use memcpy here to do so, simplyfing the code.
Mark Wielaard [Tue, 12 Nov 2024 12:34:09 +0000 (13:34 +0100)]
vgdb.c (fork_and_exec_valgrind): Fix another off-by-one error write
commit 646978d9adc5 ("vgdb: Handle EINTR and EAGAIN more
consistently") introduced another off-by-one issue trying to write
back the error from child to parent.
Instead of +1 it should have been +written (which initially is zero).
This is when the child needs to do a chdir and that chdir fails. If
that happens the parent would have gotten the wrong error code.
commit 646978d9adc5 ("vgdb: Handle EINTR and EAGAIN more
consistently") introduced an off-by-one issue trying to write back the
error from child to parent.
Instead of +1 it should have been +written (which initially is zero).
This is in an "should never happen" path, so hopefully didn't really
cause issues. But if it did happen the parent would have gotten the
wrong error code.
Andreas Arnez [Fri, 8 Nov 2024 13:52:11 +0000 (14:52 +0100)]
s390x regtest: Add missing register clobber in misc3.c
Depending on compiler options, the translation of test_mvcrl() in
`misc3.c' can misbehave because the inline assembly writes to r0 and
doesn't declare that.
Add a register clobber to fix this. Also, tell the compiler the actual
length of `from' and `to' instead of the decremented value.
Paul Floyd [Sun, 3 Nov 2024 19:42:43 +0000 (20:42 +0100)]
Bug 494327 - Crash when running Helgrind built with #define TRACE_PTH_FNS 1
Use write() rather than 'fprintf()' for the TRACE_PTH_FNS blocks for
pthread_mutex_lock and pthread_mutex_lock. Mixing FILE and fd isn't
great, but this is to stderr which gets flushed on every line, and
it is only for developer builds that modify that TRACE_PTH_FNS macro.
Report track-fd errors for fd used which was not opened or already closed
Add (optional) pathname, description, where_closed and where_opened
fields to struct FdBadUse. Print those fields when set in fd_pp_Error.
Add a new function ML_(find_OpenFd) that provides a recorded OpenFd
given an fd (or NULL when the fd was never recorded).
In ML_(fd_allowed) when using a file descriptor use ML_(find_OpenFd)
to see if the fd was ever created, if not create an "was never
created" FdBadUse error. If it was created, but already closed create
an "was closed already", filling in as much details as we can.
Add none/tests/use_after_close.vgtest to test, already closed, never
created, invalid, double (double) close and invalid close issues.
Adjust error message in none/tests/fdbaduse.stderr.exp.
Florian Krohm [Tue, 29 Oct 2024 15:24:31 +0000 (16:24 +0100)]
Bug 493959 - s390x: Fix regtest failure for op00 with /bin/dash
On different machines /bin/sh may be impersonated by different shells, and
those behave differently as to whether they write "Illegal instruction ..."
to stderr. While newer versions of bash do not, dash does.
For the op00 test case this means that an additional line may be written
to `op00.stderr.out', depending on which shell is being used. Hence
adding "Illegal instruction ..." as an expected line to `op00.stderr.exp'
wouldn't work on all systems.
Instead, fix this issue by adding the case of "illegal instruction" to the
general filtering logic in filter_stderr_basic.in, where various other
messages of this kind are already filtered out.
Carl Love [Wed, 23 Oct 2024 23:25:23 +0000 (18:25 -0500)]
PowerPC, dcbf instruction
ISA 2.7 and ISA 3.0 "accepts" L = 0 to 3, ISA 3.1 "accepts: L = 0 to 7.
Removed the L field check so valgrind will match the real hardware. For
the purposes of Valgrind the dcbf instruction is a NOP anyway so it will
not change the behavior of Valgrind.
Paul Floyd [Sat, 12 Oct 2024 07:10:21 +0000 (09:10 +0200)]
FreeBSD helgrind: temporary (?) fix for Bug 494337
FreeBSD 15 has added a pthread lock to exit() to ensure that atexit handling
is thread safe. Unfortunately that lock gets leaked which messes up just about
all of the Helgrind tests.
Supression won't work as the callstack is the same for both genuine leaks
and this deliberate leak.
This change simply turns off the check for FreeBSD >= 15.
I see two possible proper fixes. One would be to allow one lock on exit.
The problem with that is that we will need to tell apart a clean exit
(1 lock allowed) and any kind of abort that doesn't call exit (no locks
allowed). That's going to be tricky as the Helgrind check is done before
we get back to core and know whether it is an abort or a clean exit.
The other thing would be to hack the lock counting. If we can detect that
it's a pthread_mutex_lock called from exit() then we could ignore that for
counting purposes. That would mean a possibly significant overhead for
each call to pthread_mutex_lock on FreeBSD.
Introduce a new FdBadFd type with associated extra info struct.
Which for now just holds the fd number (no path or description).
fd_pp_Error and fd_update_extra have been updated to handle the
new type and produce xml when requested.
Rename showing_core_errors to showing_core_warning
(returns yes when the tools wants to show core errors,
-q isn't given and we aren't producing xml).
In ML_(fd_allowed) we now call VG_(maybe_record_error) to
generate a real error (that can be suppressed and shows up
in the xml output with full execution backtrace). For now
we also produce the legacy warnings when --track-fds=yes
isn't given.
Add none/tests/fdbaduse.vgtest to test the new FdBadUse
core error.
This is the first part of reporting bad fd usage errors.
We are also tracking already closed file descriptors which
should also produce errors like these. The current bad file
descriptors are just those that are negative or above the
current file limit of the process.
Andreas Arnez [Wed, 9 Oct 2024 15:10:08 +0000 (17:10 +0200)]
s390x: Add missing early-clobber to GET_STARTREGS
The inline assembly for GET_STARTREGS in m_libcassert.c writes to its
output before using the input argument. But since the compiler doesn't
know this, it is allowed to allocate the same register for both, causing
problems. This has been seen when compiling Valgrind with -O0, after
which memcheck/tests/leak-autofreepool-5 fails due to SIGSEGV.
Fix this by declaring the output as early-clobber, so the compiler knows
about the restriction.
Andreas Arnez [Wed, 9 Oct 2024 15:10:08 +0000 (17:10 +0200)]
Bug 493970 - s390x: Drop saving/restoring FPC upon helper call
Saving the FPC before each helper call and restoring it afterwards creates
unnecessary overhead, and it may also not be desirable.
Drop it. Also remove the functions in host_s390_defs.c responsible for
emitting LFPC and STFPC instructions. And since this frees up the FPC
save slot on the stack, adjust the stack layout accordingly.
Andreas Arnez [Wed, 9 Oct 2024 15:10:08 +0000 (17:10 +0200)]
Fix some issues with GSL for `make auxchecks'
When trying to reproduce Bug 423908, I ran into some trouble performing
`make auxchecks', due to problems in GSL:
Newer compilers complain about incompatible pointer types in argument
passing between
unsigned int *
and
size_t *
This affects the fifth argument of function gsl_eigen_jacobi() in
eigen/jacobi.c. Fix this by passing the right pointer type at invocation.
Also, the configure checks for IEEE comparisons and for IEEE denormalized
values don't work as intended, because they call exit() without declaring
it and thus fail independently from those features being supported. Fix
this by using `return' instead.
Paul Floyd [Tue, 8 Oct 2024 19:03:17 +0000 (21:03 +0200)]
macOS regtest: give up trying to build bug492210.c
macOS has to make everything difficult. Global names need
to be decorated with an underscore prefix. And you can't
just read from global variables, you have to do something
like a rip-relative lea.
Paul Floyd [Mon, 7 Oct 2024 05:34:59 +0000 (07:34 +0200)]
FreeBSD regtest: add FAKE macros for scalar
FreeBSD 15 removed the never-implemented sbrk syscall.
Arm64 also has a few missing syscalls (backward compat ones
that predate the arm64 port). Rather than having an ever
increasing number of expecteds the aim is to use these
FAKE macros. It's a bit fiddly to get the matching text.
Mark Wielaard [Sun, 22 Sep 2024 21:24:34 +0000 (23:24 +0200)]
Implement /proc/self/exe readlink[at] fallback in POST handler
Calling the readlink[at] syscall directly from the PRE handler defeats
the FUSE_COMPATIBLE_MAY_BLOCK (SfMayBlock) flag. Add a POST handler
that only explicitly calls the readlink[at] handler for the
/proc/self/exe fallback (this should be fine unless /proc is also
implemented as fuse in this process).
Adjust readlink[at] GENX_ and LINX_ syswrap macros to GENXY and LINXY.
Mark Wielaard [Sat, 21 Sep 2024 20:27:24 +0000 (22:27 +0200)]
Add missing FUSE_COMPATIBLE_MAY_BLOCKs
Various syscalls (in particular "at" variants) PRE handlers were
missing a FUSE_COMPATIBLE_MAY_BLOCK statement.
Add it to the generic PRE handlers of access and statfs64. And the
linux PRE handlers of mknodat, fchownat, futimesat, utimensat,
utimensat_time64, renameat, renameat2, readlinkat, fchmodat,
fchmodat2, faccessat and faccessat2.
Mark Wielaard [Sat, 31 Aug 2024 17:47:27 +0000 (19:47 +0200)]
Implement stable variant of sync_file ioctls
We implemented an old staging android variant of the sync_file
ioctls. But the data structures and ioctl numbers changed when these
were upstreamed in the table linux kernel.
This implements the SYNC_IOC_MERGE, SYNC_IOC_FILE_INFO and
SYNC_IOC_SET_DEADLINE ioctls. And makes sure to record the new file
descriptor created by SYNC_IOC_MERGE.
Andreas Arnez [Tue, 1 Oct 2024 11:12:44 +0000 (13:12 +0200)]
s390x: Add bug 440180 to NEWS
As reported in Bug 440180, the s390x disassembler could run into an
assertion failure due to the maximum mnemonic length being exceeded. This
was fixed with commit 67a2bb759a7c9c76fd6aa142bdb6fe342a5998e2.
Paul Floyd [Mon, 30 Sep 2024 19:09:15 +0000 (21:09 +0200)]
FreeBSD regtest: remove unneeded expected file
Previously I had #ifdef'd the freebsd7 compatibility syscalls
in the scalar test for all platforms when adding the arm64
port. They are now back for amd64 and x86 so the previous
expected also covers FreeBSD >= 14.0 and the extra expected
file is now superfluous and removed.
Paul Floyd [Sun, 29 Sep 2024 08:02:33 +0000 (10:02 +0200)]
FreeBSD procctl syscall: change arg name in error messages
The man page was inconsistent in the use of 'data' or 'arg'
for the fourth argument. I chose to use 'arg'. The manpage
has now been cleaned up and uses 'data'. So I'm switching to
use the same name.
Paul Floyd [Sat, 28 Sep 2024 06:20:25 +0000 (08:20 +0200)]
Compiler warning in ML_(check_elf_and_get_rw_loads)
GCC 12.2 complains that
previous_rw_a_phdr.p_vaddr + previous_rw_a_phdr.p_filesz
may be using p_filesz uninitialized
That's only possible if ML_(img_get) somehow fails to read all
of a program header such that p_memsz is greater than 0 but
p_filesz remains uninitialized. Hardly likely since p_memsz
comes after p_filesz in the structure.
Paul Floyd [Fri, 27 Sep 2024 20:18:24 +0000 (22:18 +0200)]
FreeBSD: remove code for FreeBSD 10
FreeBSD 10 was never really tested - fully working FreeBSD support
arrived around the time of FreeBSD 11.3 and 12.1. FreeBSD had
already been EOL around 2 years by then.