Mark Wielaard [Sun, 18 May 2025 13:31:36 +0000 (15:31 +0200)]
Check whether file descriptor is inherited before printing where_opened
Inherited file descriptors don't have an ExeContext where they were
opened (by the program). So don't try to print the NULL where_opened
when reporting double close errors for such file descriptors.
Add a testcase none/tests/fdleak_doubleclose0 that crashes valgrind
before this fix.
Martin Cermak [Fri, 16 May 2025 20:12:39 +0000 (22:12 +0200)]
PR503969: make ltpchecks: flatten the log structure
Flatten the directory structure of make ltpchecks logs per PR503969#c9.
Individual syscall tests are numbered, so that no testcase naming
conflicts should show up. Demo upload:
Martin Cermak [Fri, 16 May 2025 09:46:06 +0000 (11:46 +0200)]
PR503969: Make test results of make ltpchecks compatible with bunsen
Synthesize automake-like testcase log format for bunsen compatibility.
Each testcase now produces a triplet of <testcase>.{log,trs}, and a
test-suite.log file. This way test results can be uploaded to bunsen
using the t-upload-git-push command.
The <testcase>.log file contains the actual testcase log. The .trs
file contains automake-encoded test result. The test-suite.log
file contains testcase timing information.
The log directory tree respect the one of the LTP testcases to avoid
naming collisions.
Here is how the test result was uploaded to Bunsen:
> TESTING FINISHED, logs in /home/mcermak/WORK/valgrind/valgrind/auxprogs/auxchecks/ltp-full-20250130/ltp
> make[1]: Leaving directory '/home/mcermak/WORK/valgrind/valgrind/auxprogs'
>
> real 8m27.467s
> user 44m46.416s
> sys 6m46.405s
> 41$ cd /home/mcermak/WORK/valgrind/valgrind/auxprogs/auxchecks/ltp-full-20250130/ltp
> 41$ t-upload-git-push ssh://builder.sourceware.org/git/bunsendb.git mcermak/PR503969-$(date +%s) \
> $(find . -type f -name '*.log' -o -name '*.trs' -o -name 'test-suite.log')
> 3036eba2de1cc44a1942f9681720ea234da9029e refs/tags/mcermak/PR503969-1747389329
> 41$
Florian Krohm [Thu, 15 May 2025 21:42:19 +0000 (21:42 +0000)]
Compile code that gets linked with libc by adding -fhosted.
The use of -fno-builtin interfers with -Wformat: no format warnings will
be given when both options are present. Because -fno-builtin means: when
you encounter a function that has the same name as a built-in function,
forget everything you know about that function.
That includes functions attributes. And without __attribute__((format...))
there will be no -Wformat warnings.
The fix is to append -fhosted when compiling something that gets linked
with libc. As command line options are processed left to right adding
-fhosted at the end overrides any earlier -fno-builtin option.
Fix compiler warnings.
Add some ugly ifdeffery to drd/drd_intercepts.c. I could not figure out how
to rewrite the offensive printf to avoid testcase breakage.
Martin Cermak [Thu, 15 May 2025 10:03:55 +0000 (12:03 +0200)]
Wrap linux specific cachestat syscall
cachestat takes an fd, cstat_range and flags arguments and
writes out page cache statistics via the cstat struct.
Declare a sys_cachestat wrapper in priv_syswrap-linux.h and hook it
for {amd64,arm,arm64,mips64,nanomips,ppc32,ppc64,riscv64,s390x,x86}-linux
using LINXY with PRE/POST handlers in syswrap-linux.c.
Define __NR_cachestat for amd64, arm, arm64, mips32, mips64, nanomips,
ppc32, ppc64, riscv64, s390x, and x86.
Mark Wielaard [Tue, 13 May 2025 22:13:06 +0000 (00:13 +0200)]
Don't count closed inherited file descriptors
Programs which close some inherited file descriptors and are run under
valgrind with -q and --track-fds=yes would still show the FILE
DESCRIPTORS banner even if there were no non-inherited file
descriptors still open.
Fix this by not counting already closed inherited file descriptors.
Add a simple testcase to show /usr/bin/cat /dev/null doesn't produce
any output running under valgrind -q --track-fds=yes.
Martin Cermak [Tue, 13 May 2025 12:21:08 +0000 (14:21 +0200)]
auxprogs/ltp-tester.sh: Fix typo in summary log grep
This does point out a couple more failures. In case the test results
differ when running under valgrind, but there are no other error
indicators. e.g. openat202 now reports:
Which points out we have a bug in our openat wrapper when given
/proc/self/exe with RESOLVE_NO_MAGICLINKS (which should fail with
ELOOP, but succeeds when running under valgrind, probably because we
have a "magic" /proc/self/exe wrapper).
Paul Floyd [Mon, 12 May 2025 19:38:46 +0000 (21:38 +0200)]
illumos regtest: mask a leak in memcheck/tests/realloc_size_zero_xml
There's what looks like a libc printf buffer possible leak
in this test on illumos. With xml output leak reporting is
hard coded to on. So to avoid this extra error add
--show-possibly-lost=no
Maybe this should be suppressed. I haven't managed to reproduce it
without xml and outside of perl regtest.
Mark Wielaard [Fri, 9 May 2025 11:46:44 +0000 (13:46 +0200)]
Add workaround for missing riscv_hwprobe syscall (258)
On riscv newer glibc (2.41) will probe instruction support using the
riscv_hwprobe syscall. Since Valgrind currently doesn't have a wrapper
for riscv_hwprobe that causes a Warning. Since the RISC-V Hardware
Probing Interface is non-trivial and we don't really implement
extended riscv instructions anyway work around that by "implementing"
riscv_hwprobe as sys_ni_syscall so it generates an ENOSYS and glibc
will silently fall back to not using any extended instructions.
Mark Wielaard [Thu, 8 May 2025 22:21:25 +0000 (00:21 +0200)]
mount syscall param filesystemtype may be NULL
On Linux the mount syscall, depending on flags provided, the source,
type and data my be ignored. We already don't check data and allow
source to be NULL. Normally when type is ignored an application will
provide an empty string "". But sometimes NULL is passed (like for
source). So we now also allow type to be NULL to prevent false
positives.
Adjust the linux/scalar.c tests so the type param is still
unaddressable.
But the disasm-test parser assumed there could only be one
address including a symbol name on a given line. It stopped
comparison beyond that point.
The line
Said patch removes the resteering machinery which allowed chasing through
unconditional jumps/calls during IR generation.
There were two fixme's related to this which are now removed.
Also eliminate functions 'call_function_and_chase' and
'always_goto_and_chase' which no longer are meaningful. Use
'call_function' and 'always_goto' instead.
Florian Krohm [Sun, 4 May 2025 21:29:34 +0000 (21:29 +0000)]
s390x: Add disassembly for special insns
Surely we want to see this when tracing the frintend.
Also: new function s390_irgen_inject_ir to wrap the handling of
the special insn for IR injection.
Mark Wielaard [Sun, 4 May 2025 18:16:26 +0000 (20:16 +0200)]
ltp-excludes: Add fork14, futex_cmp_requeue and pidfd_send_signal
There are a few more linux test project syscall tests that seem to
cause some trouble for some buildbots. The fork14 test uses a lot of
memory, as do the futex_cmp_requeue tests (at least on ppc64le). And
the pidfd_send_signal tests, when run inside a container, seem to kill
the test wrapper (and the container it runs in).
Paul Floyd [Tue, 22 Apr 2025 05:22:42 +0000 (07:22 +0200)]
Regtest: clean up warning and compilation of bug290061.c
On some platforms there was a 'defined but not used' warning.
When I fixed that I got a link error from clang. Using a
_LDFLAGS option causes automake to split building the test into
separate compile and link commands and clang was optimizing away
the unused static 'meh' symbol.
Paul Floyd [Mon, 21 Apr 2025 18:44:31 +0000 (20:44 +0200)]
Illumos regtest: add an expected for none/tests/fdleak_socketpair_xml.stderr
illumos socketpair doesn't get the next two fds (3 and 4), instead it
gets 4 and 5. That looks like it's because this is done in two steps in libc.
so_socket gets called twice returnning fds 3 and 4 the so_socketpair takes
those and does some rebinding(?) resulting in fds 4 and 5.
Mark Wielaard [Fri, 18 Apr 2025 10:22:29 +0000 (12:22 +0200)]
Add auxprogs/ltp-excludes.txt
There are a couple of ltp testcases that take a very long time to run
(under valgrind). Add a file auxprogs/ltp-excludes.txt that is used to
exclude them from a make ltpchecks run, containing 10 tests:
Martin Cermak [Thu, 17 Apr 2025 14:14:19 +0000 (16:14 +0200)]
Use LTP for testing valgrind
Add a new top level make target ltpchecks which will fetch the latest
linux test project (ltp) release as defined by the LTP_VERSION and
LTP_SHA256 variables in auxprogs/Makefile.am (update those when a new
version of ltp is released). If the ltp tar.xz has already been
downloaded, or it has already been unpacked and build, the (cached)
file and build will be reused.
The actual testing is done through the auxprogs/ltp-tester.sh script.
It takes all executable tests from the ltp testcases under
kernel/syscalls and runs them 3 times. Once directly, not under
valgrind, once with -q --tool=none and once with -q
--tool=memcheck. It then checks that valgrind didn't produce any
messages with the none tool, that there were no fatal errors produced
(as defined in auxprogs/ltp-error-patterns.txt) and that the ltp
results are the same with and without valgrind.
Currently there are 1472 test binaries and running them all (serially)
takes more than three hours and detects various missing or incomplete
syscall handlers in valgrind, plus various crashers.
Paul Floyd [Thu, 17 Apr 2025 19:26:24 +0000 (21:26 +0200)]
Illumos: increase coverage of --modify-fds syscalls
It looks like Solaris/Illumos is missing some F_DUP* coverage
and we aren't handling syscalls that reaturn 2 fds (pipe, socketpair).
Otherwise this should cover most Illumos cases at least.
Normally a newly recreated file descriptor gets the lowest number
available. This might cause old file descriptor numbers to be reused
and hides bad file descriptor accesses (because the old number is
new again).
When enabled, when the program opens a new file descriptor,
the highest available file descriptor is returned instead of the
lowest one.
Add the none/tests/track_new.stderr.exp test to test this new option.
Adjust none/tests/filter_fdleak to filter the track_new.vgtest,
removing some internal glibc functions from the backtraces and remove
symbol versioning. The output of the use_after_close test also had to
be adjusted. Also adjust the none/tests/cmdline1 and
none/tests/cmdline2 output as the new --modify-fds=no|high is
displayed.
Paul Floyd [Tue, 15 Apr 2025 18:39:22 +0000 (20:39 +0200)]
nightly: fix check for Illumos libc
On Illumos `uname -o` outputs "illumos". We weren't testing for
that so it fell through to the Linux block which runs libc.so to
get the version string. On Illumos that outputs
s390x: Regtest integration of none/tests/s390x/disasm-test
The checker requires objdump --version >= 2.44
Add command line flag --check-prereq to disasm-test and use it in
disasm-test.vgtest.
New file none/tests/s390x/disasm-test/disasm-test.post.exp as the
checker is run in the "post" hook.
This patch makes VEX disassembly match objdump disassembly for
objdump versions >= 2.44. Prior objdump versions did not handle the
nuances of the "rotate and ..." set of opcodes and there was also a
bug disassembling BC insns.
Paul Floyd [Sat, 12 Apr 2025 21:57:58 +0000 (23:57 +0200)]
Illumos regtest: use LC_ALL=C for execx test
There's an uninitialized read in /usr/bin/printf when using the
default en_US.UTF-8 locale. This isn't a printf test, and using
the C locale makes the error go away.
4095 is not a valid bfp rounding mode and the old implementation of
s390_irgen_SRNMB let it slide by with a warning. However, POP calls for a
specification exception in this case. This is what this patch changes.i
It also eliminates the s390_irgen_srnmb_wrapper function along the way.
While adjusting none/tests/s390x/srnmb.* I noticed that the line
number shown in the specification exception is incorrect. This
is not a regression. It has been incorrect before as well.
I have opened https://bugs.kde.org/show_bug.cgi?id=502729 fro the line
number issue.
Paul Floyd [Sat, 12 Apr 2025 16:27:06 +0000 (18:27 +0200)]
Illumos regtest: add 'illumos' to os_test and turn off a few tests
The threadname tests fail on Illumos. Solaris has a syscall,
sys_lwp_name, which we intercept and record. Illumos doesn't
have that, with the pthread name functions looking ofr the name in /proc
That's not implemented in Valgrind so I'm turning those 2 tests off.
The other 3 are all based on none faultstatus. This test checks 4 things,
one of which is reading from a 32k mmap that is PRIVATE and READ but is
only backed by a 16k file. All other OSes generate a SIGBUS. Illumos
just reads 0 from the address.
Paul Floyd [Wed, 9 Apr 2025 06:49:52 +0000 (08:49 +0200)]
Helgrind: Fixes for ETIMEDOUT
pthread_rwlock_timedrdlock and pthread_rwlock_clockrdlock were
generating API errors if they timed out. This fixes that and
only generates API errors for non-zero and non-ETIMEDOUT
return codes.
Paul Floyd [Thu, 3 Apr 2025 17:56:51 +0000 (19:56 +0200)]
Illumos helgrind: fix for pthread_rwlock_timedrdlock and pthread_rwlock_timedrwlock
On Illumos these two functions are implemented by calling
pthread_rwlock_clockrdlock and pthread_rwlock_clockwrlock respectively.
Since we intercept both it was appearing as though the lock was being
taken recursively when it wasn't. Fixed it by using a static flag for each
and not callinng the client requests if already in a call to the timed
functions.
I think that musl also does this but, ho-hum, Helgrind has never worked on musl.
Andreas Arnez [Thu, 3 Apr 2025 15:40:03 +0000 (17:40 +0200)]
s390x: Support the PPA instruction
The perform processor assist (PPA) instruction provides the CPU with
special execution hints. It belongs to the processor-assist facility,
which shares facility bit 49 with the execution-hint and load-and-trap
facilities and with the miscellaneous-instruction-extensions facility 1.
Implementing PPA enables setting facility bit 49 to one. Similar to other
execution hint instructions, implement PPA as a no-op for now.
Andreas Arnez [Thu, 3 Apr 2025 17:07:32 +0000 (19:07 +0200)]
s390x: Reflect renaming of DFP insns in opcode checker
After renaming various DFP instructions to their new name, reflect this in
s390-check-opcodes.pl by ignoring their old names, so the checker doesn't
complain about mismatches.
Also, add the missing documentation in s390-opcodes.csv about the fact
that the "with rounding mode" instruction versions cgdtra, cgxtra, and
cxgtra are implemented.
s390x: Add missing s390_insn_assert for non-vector opcodes
Based on the specification in disasm-test/opcode.c
With a few corrections:
- kma: tighten up the assert
- cdftr, cxftr: no emulation failure when floating-point-extension
facility is not installed
- cgdtra, cgxtra: check for floating-point-extension facility
- ltdtr, ltxtr, lxdtr: check for DFP facility
Andreas Arnez [Wed, 2 Apr 2025 17:52:26 +0000 (19:52 +0200)]
Bug 502324 - Add test case for TMx memcheck false positives
Add a regression test for Bug 502324. Before the bug was fixed, this test
failed with various "conditional jump or move depends on uninitialised
value(s)" messages.