Mark Wielaard [Wed, 3 Sep 2025 16:29:43 +0000 (18:29 +0200)]
Remove fdleak.h CLOSE_INHERITED_FDS workaround
This workaround was necessary with very old perl implementations (from
2008) which might execute programs with some non-standard file
descriptors not closed. The macro would close all file descriptors 3
or higher so --track-fds wouldn't report on them.
More recently --track-fds also reports on bad file descriptor
usage. First only double or bad close calls were reported. This would
cause lots of warnings for the close_inherited file descriptor loop
because almost all of those file descriptors were never opened, so
--track-fds would report those. To work around that an fstat call was
added before the close to make sure the file descriptor existed.
This fstat workaround in close_inherited only worked because fstat
didn't have a fd_allowed check. Which is a bug that should be
fixed. On some systems fstat actually calls the fstatat syscall and
that did recently got the fd_allowed check, so on systems that use
fstatat for fstat various fdleak tests started failing.
We could test for and use close_range, which is smart enough to not
warn about never opened file descriptors in the range. But it seems
simpler to just get rid of the CLOSE_INHERITED_FDS macro because the
problematic perl implementation is now so old that nobody uses it
anymore.
Florian Krohm [Sat, 30 Aug 2025 11:28:03 +0000 (11:28 +0000)]
iropt-test: Constant folding for DivModU32to32 and DivModS32to32
Needed for Mips. Mips is still disabled in iropt-test because there
are miscompares between the folded the result and the result computed
by the insn sequence that implements the IROp. Several IRops are affected.
Part of fixing https://bugs.kde.org/show_bug.cgi?id=506211
Paul Floyd [Fri, 29 Aug 2025 06:22:17 +0000 (08:22 +0200)]
regtest: add vgtest and expected for memcheck duplicate_align_size_errors
The cpp file and .gitignore change were done at the same
time as the aligned size checks, but I missed out the expected
vgtest and Makefile.am changes. There were also a couple of unused
variables in the cpp file.
Paul Floyd [Fri, 29 Aug 2025 05:59:28 +0000 (07:59 +0200)]
Linux FreeBSD and Darwin: refactor *at syscall dirfd checks
I haven't done Solaris. The code there is less messy because
Solaris doesn't use a negative value for AT_FDCWD, meaning
no explicit or implicit cast from unsigned word to signed
int is needed before comparing to the int dirfd parameter.
Florian Krohm [Thu, 28 Aug 2025 20:17:29 +0000 (20:17 +0000)]
iropt-test: Constant folding for Iop_DivModU64to32 and Iop_DivModS64to32
Function get_selected_values has been tweaked to return more
"interesting" values for test generation. Namely those that,
when interpreted as a signed integer, are boundary (or near
boundary) values.
Also a bit of reorg because for the DivMod.. IROps we need to be a bit
more careful when generating testcases that do not trap or where the
result does not fit in 32 bit.
Part of fixing https://bugs.kde.org/show_bug.cgi?id=506211
Paul Floyd [Sun, 24 Aug 2025 09:25:51 +0000 (11:25 +0200)]
illumos syscalls: fd handling (part 4)
Almost everything looked OK. Added a couple of POST_newFd_RES
macro uses.
There are a few functions that create fds other than via RES
(like pipe). For these I think that we need to add a
POST_newFd(fd) macro, plus in a few places refactor so that
RES is available to set the status after ML_(get_next_new_fd).
Paul Floyd [Sat, 23 Aug 2025 22:05:51 +0000 (00:05 +0200)]
FreeBSD regtest: updates to scalar for x86
Now that there better checks of fds a couple of syscalls using
rubbish values for fd which were above the max files limit.
That changed the syscall return code causing an assert.
Also some left over updates to the expected from previous changes.
Paul Floyd [Sat, 23 Aug 2025 19:31:13 +0000 (21:31 +0200)]
FreeBSD regtest: get pdfork_pdkill to pass on arm64
arm64 was giving a few conditional jump errors (suppressed)
and a pdfork was succeeding with uninit flags whilst it was
failing on amd64. Made sure that it has bad flags (-1) but
still uninit.
Some more recording of fd opens and closes
Lots of checks for the directory fd of *at() syscalls
Fixed a few bugs in pdfork and pdkill (and updated the testcase).
Updated a few message strings.
Started improving readlinkat - needs more work.
Florian Krohm [Fri, 22 Aug 2025 17:48:23 +0000 (17:48 +0000)]
iropt-test: Run tests with and without constant folding.
That way we can check whether the result of constant folding matches
the value computed by the insn sequence that is generated to implement
a specific IROp. Bugs were found for all architectures. s390 has been
fixed. The other architectures are currently disabled.
- irops.tab modified to enable only those IROps that are actually
implemented for a given architecture. Architectures considered here
are amd64, x86, ppc32, ppc64be/le
- IRICB_iropt_payload amended to store both the folded and unfolded
result
- In valgrind_execute_test call IR injection twice: with and without
constant folding enabled (--vex-iropt-fold-expr=yes/no)
Florian Krohm [Tue, 19 Aug 2025 21:11:25 +0000 (21:11 +0000)]
s390: Fix code generation for Iop_MullS8/16 and Iop_MullU8/16
Multiplication is performed using 4-byte values.
There were two bugs:
(1) Iop_MullS8/16 operands weren't sign-extended
(2) No shifting and OR'ing required to access the result. r11[32:63] has it.
Mark Wielaard [Mon, 18 Aug 2025 13:30:47 +0000 (15:30 +0200)]
Add ppc64le linux hardwire for ld64.so.2 strcmp
When dlopen is used we might end up in an assembly powerpc/strcmp.S
variant that is optimized in a way memcheck cannot proof correct. We
try to intercept strcmp in ld.so, but might fail when strcmp is called
before our interception code is loaded. Having an hardwire for ld.so
strcmp (earlier intercept) would solve this.
Martin Cermak [Wed, 13 Aug 2025 07:03:13 +0000 (09:03 +0200)]
PRE(sys_fchownat) not handling VKI_AT_FDCWD
Multiple `make ltpchecks` failures seem tp be caused by
PRE(sys_fchownat) not handling VKI_AT_FDCWD properly.
This specifically impacts aarch64 test results these days.
Martin Cermak [Mon, 11 Aug 2025 09:17:58 +0000 (11:17 +0200)]
faccessat and faccessat2 should do better checks
Do more fine-grained checks within sys_faccessat and sys_faccessat2
syscall wrappers. Allow passing special value of VKI_AT_FDCWD as a
file descriptor. Check for valid flags.
Martin Cermak [Fri, 8 Aug 2025 21:38:33 +0000 (23:38 +0200)]
Review the vmsplice syscall wrapper
Reuse the vmsplice syscall wrapper in coregrind/m_syswrap/syswrap-linux.c
for mips64 as well. And make sure arm64-linux and riscv64-linux also use
the POST vmsplice wrapper.
Mark Wielaard [Wed, 6 Aug 2025 22:21:42 +0000 (00:21 +0200)]
Distribute auxprogs scripts and data files
Make sure pybuild.sh, ltp-tester.sh, ltp-apply-patches.sh,
s390-check-opcodes.pl, s390-runone scripts, ltp filters, ltp patches
and pylintrc are added to the dist.
This makes sure users can run the scripts and make ltpchecks not just
from a git checkout, but also from a release or snapshots tar.
Also use the ustar format to package files, the path under
valgrind-x.yy.z/auxprogs/ltp-patches might be larger than 99
chars. automake 1.18 already defaults to the ustar format.
Martin Cermak [Tue, 5 Aug 2025 16:06:08 +0000 (18:06 +0200)]
Allow for patching LTP sources
Sometimes there's an upstream LTP patch that helps testing
valgrind, but it's not yet part of the official LTP tarball.
In such cases it's helpful to be able to patch the LTP sources.
Attached patch allows for that. It comes with a real life
example patch: LTP commit b62b831cf.
Florian Krohm [Sat, 2 Aug 2025 12:43:54 +0000 (12:43 +0000)]
mips specific changes for BZ 507033
Rework code to use Iop_ClzNat32 instead of the deprecated Iop_Clz32.
Likewise for Iop_Clz64.
For Iop_Clz32 a CLZ insn will be emitted which behaves naturally when
its input is 0. That is: CLZ(0) == 32.
Similarly, for Iop_Clz64 a DCLZ will be emitted with DCLZ(0) == 64.
That means we can replace Iop_Clz32/64 with Iop_ClzNat32/64 and remove
any IR that handles the input-is-zero case.
See also commit a5c48217e94.
Part of fixing https://bugs.kde.org/show_bug.cgi?id=507033