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.
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.
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.
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".
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.
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.
Paul Floyd [Fri, 23 Feb 2024 20:43:16 +0000 (21:43 +0100)]
FreeBSD: another load of changes for FreeBSD 15
One more default suppession.
The new libsys.so was causing problems, and it needs to be
loaded before libthr.so in order to be able to get the tid
for the main thread on startup.
The bar_bad testcase for both helgrind and drd was giving a lot of
trouble (inclusing an assert in DRD_(barrier_pre_wait) ). The
sleeps in the testcase were not assuring the expected order.
So I changed the sleeps to 1ms nanosleeps in loops. That's a
bit more realistic and it also gives much more chances to the
scheduler to context switch.
Paul Floyd [Fri, 23 Feb 2024 19:07:53 +0000 (20:07 +0100)]
FreeBSD: updates for FreeBSD 15 libsys
FreeBSD 15 has moved all libc functions that are just syscall
wrappers into libsys. That changes quite a few callstacks, so
I've added a load of filtering to make it look like the old
libc callstacks.
I'm also seeing new conflicts in _umtx_op_err for both DRD
and Helgrind that needed supressing.
Paul Floyd [Fri, 23 Feb 2024 08:33:24 +0000 (09:33 +0100)]
FreeBSD: changes for building with GCC
Use MARK_STACK_NO_EXEC (it's a null macro on non-linux platforms).
GCC complains if it's not used.
parse_procselfmaps yet again.
The hack that I added in 6fdd59afb5e473b30e7ad1fbadcf9a397253fed4
only works for clang/ld.lld. This change makes it also work with
GCC/ld.bfd. Still a hack though.
Paul Floyd [Sat, 17 Feb 2024 20:37:00 +0000 (21:37 +0100)]
Darwin: various fixes
Fix building a couple of regtests.
bmi.c - Apple clang puts a funky underscore before symbols which you
have to add explicitly in asm.
mmap_o_direct.c - there is no O_DIRECT on macOS
syswrap - make csrctl messages a bit more userland-y rather than
kernel-y
Paul Floyd [Fri, 16 Feb 2024 20:35:11 +0000 (21:35 +0100)]
linux arm regtest: add an expected for leak_cpp_interior
For this code
ptr2 = new MyClass[0]; // "interior but exterior ptr".
// ptr2 points after the chunk, is wrongly considered by memcheck as definitely leaked.
there's a possible leak rather than a definite one.
I tried adding the clobber macro but that didn't change anything.
So I'm still not too sure why memcheck is finding the pointer for
this.
Paul Floyd [Fri, 16 Feb 2024 12:08:03 +0000 (13:08 +0100)]
linux arm regtest: fix test and stdout expected
The three diffs that I noticed earlier were really due to typos
in the testcase. They should have been using d0 d1 d2 d3 but
instead were using d0 d1 d2 d4.
Fix gdbserver tests failing due to 'warning: ' prefix in syscall-template.S line
At least on debina 12.5, with GDB 13.1 and GDB 14.1, 2 gdbserver tests
fails due to a 'warning: ' word appearing in from of a line
giving the syscall-template.S filename.
Fix this by allowing an optional 'warning: ' regexp at the beginning of the line.
Tested on debian 12.5, with GDB 12.1/13.1/14.1 and 15.0.50.20240211-git
Paul Floyd [Mon, 5 Feb 2024 12:21:28 +0000 (13:21 +0100)]
FreeBSD: updates for FreeBSD 14.0
Added some filtering. Removed a few compiler warnings.
memcheck manuel1 has an extra error somewhere within
the printf calltree - sensitive to libc changes.
I still get
== 853 tests, 2 stderr failures, 0 stdout failures, 0 stderrB failures, 0 stdoutB failures, 0 post failures ==
memcheck/tests/descr_belowsp (stderr)
memcheck/tests/varinfo5 (stderr)
descr_belowsp no longer mentions the guard page. Back in commit
Paul Floyd [Sat, 27 Jan 2024 07:00:34 +0000 (08:00 +0100)]
Helgrind: add suppression for libnss from getaddrinfo
Seems as though Raspberry Pi OS doesn't have a debuginfo package
for libnss_mdns4 so we need to suppress based on the obj name.
There is still one error in the Helgrind getaddrinfo test, but that
is in the somewhat malformed libarmmem library (which does have
debuginfo but Valgrind can't read it because there is no ELF type
or size info). I think that suppressing that would be too broad.
Paul Floyd [Sun, 21 Jan 2024 20:33:06 +0000 (21:33 +0100)]
Bug 480126 - Build failure on Raspberry Pi 5 / OS 6.1.0-rpi7-rpi-v8
The problem is that the Pi 3+ with raspbian has a 64bit aarch64 OS
but a 32bit gnueabihf userland. If you just run "configure" the
result will be an attempt to use 32-bit GCC with the ARM64 Valgrind
platform, which will fail.
This can be fixed by using the appropriate --host= option.
I've updated README.aarch64 with a description of this.
I've also changed configure.ac to take "arm*" for the
ARM platform (previously it was "armv7*"). That's been
a patch on Debian for a while. It will allow building
on older arm hardware and also armv8 (used on the
Raspberry Pi 3 and later models).
Paul Floyd [Thu, 28 Dec 2023 20:50:06 +0000 (21:50 +0100)]
regtest: try to make cachegrind/tests/ann-merge2.vgtest deterministic
Add a touch of the cgout files so that they are more recent than the
source file. git clone seems to sometimes timestamp the source
after the cgout files which generates a warning and a post failure.
At least with FreeBSD on ZFS.
Paul Floyd [Thu, 28 Dec 2023 09:27:18 +0000 (10:27 +0100)]
Bug 479041 - Executables without RW sections do not trigger debuginfo reading
The main change is to not assume that there is always 1 and only 1 RW segment.
Now the rw segment count is obtained from the macho segments.
I've had to make several changes to remove asserts that checked
that there is always 1 or more rw segments. I don't think that this
really affects 'normal' C and C++ compiled binaries. There is one
exp-bbv testcase (x86/million) that is written in assembler and
was failing until I removed all of the asserts.
There's still a bit more work to do.
1. Handle fat binaries - are these still a thing (with "apple silicon")?
2. Use a dynamically sized buffer for the segments rather than just 4k.
Paul Floyd [Fri, 22 Dec 2023 18:59:56 +0000 (19:59 +0100)]
Bug 478837 - valgrind fails to read debug info for rust binaries
mold produces binaries with non-contiguous .rodata and .rodata.xxx
sections. The code that merges their addresses can only handle 1
rodata which means only contiguous sections can be merged.
Since this now seems to be a "normal" case I've changed the warning
message to be a SYMTAB_TRACE message.
Paul Floyd [Sun, 17 Dec 2023 13:18:51 +0000 (14:18 +0100)]
Bug 478624 - Valgrind incompatibility with binutils-2.42 on x86 with new nop patterns (unhandled instruction bytes: 0x2E 0x8D 0xB4 0x26)
It was a bit of a struggle to get the testcase to build
with both clang and gcc (oddly enough gcc was more difficult) so
I just resorted to using .byte arrays.