17221 Commits

Author SHA1 Message Date
Paul Floyd
8224cf37a9 Update none/tests/cmdline1 and 2 for non-linux 2022-12-31 10:13:19 +01:00
Philippe Waroquiers
f6fcc74a68 Allows to only output "new" loss records when doing a leak search.
In the memcheck monitor 'leak_search', add a "new" keyword corresponding
to the delta leak search mode LCD_New.

Add a new client request VALGRIND_DO_NEW_LEAK_CHECK.

When doing a delta leak search, new loss records are marked with "new"
(whatever the delta leak search mode).

Note that trailing white spaces were removed in mc_main.c.
A much small diff can be looked at by using the -w diff option.
2022-12-30 20:56:47 +01:00
Philippe Waroquiers
c8bb6a62ca Add clo option -scheduling-quantum=<number> to control scheduler time slice.
This option can be useful when tracking race conditions which are sensitive
to thread scheduling.
2022-12-30 16:28:23 +01:00
Paul Floyd
ccbb75cf1d FreeeBSD: Add Helgrind suppression for void __thread_specific_ptr<_Tp>::set_pointer(pointer __p) 2022-12-30 13:46:09 +01:00
Paul Floyd
5cfb0173ed Add DRD shared_timed_mutex to Helgrind
This uses pthread_rwlock_timedrdlock / pthread_rwlock_timedwrlock
(see commit 6ffb70e650ee7cf4ada829557dd30ababb09e078)
2022-12-29 22:21:03 +01:00
Paul Floyd
d7c93d1f71 Add a variation of the Helgrind tls_threads test
This version uses GLIBC_TUNABLES in the environment so it checks
that glibc.pthread.stack_cache_size can be detected and modified.
2022-12-29 22:08:14 +01:00
Paul Floyd
6ffb70e650 Bug 400793 - pthread_rwlock_timedwrlock false positive
Add Helgrind intercepts for pthread_rwlock_timedwrlock
(and pthread_rwlock_timedrdlock)

Reuse the DRD trylock test
2022-12-29 22:02:47 +01:00
Paul Floyd
ab1eb2cb74 Update modified hg04 reference for DRD. 2022-12-29 20:59:25 +01:00
Philippe Waroquiers
a5b88a02d5 Add a test for helgrind --history-backtrace-size
Extend hg04_race to have more entries in the conflicting stacktrace,
and make another test hg04_race_h9 to test with one more entry than
the default of 8.
2022-12-29 16:19:24 +01:00
Philippe Waroquiers
3c916e4cbf Fix typo in NEWS. 2022-12-29 13:18:27 +01:00
Philippe Waroquiers
29252c77bb Add clo option the nr of entries in helgrind --history-level=full stack traces
The number of such entries was hardcoded to 8.
A new command line option -history-backtrace-size=number allows
to set the (max) number of entries to record.

Note that according
  perl perf/vg_perf --tools=helgrind --vg=. --vg=../trunk_untouched perf
this change (unexpectedly) improves some tests:
    - Running  tests in perf ----------------------------------------------
    -- bigcode1 --
    bigcode1 .         :0.08s  he: 2.0s (25.5x, -----)
    bigcode1 trunk_untouched:0.08s  he: 2.1s (25.9x, -1.5%)
    -- bigcode2 --
    bigcode2 .         :0.08s  he: 4.2s (52.2x, -----)
    bigcode2 trunk_untouched:0.08s  he: 4.2s (52.0x,  0.5%)
    -- bz2 --
    bz2      .         :0.40s  he: 6.5s (16.3x, -----)
    bz2      trunk_untouched:0.40s  he: 7.4s (18.5x,-14.0%)
    -- fbench --
    fbench   .         :0.15s  he: 2.0s (13.2x, -----)
    fbench   trunk_untouched:0.15s  he: 2.3s (15.5x,-17.7%)
    -- ffbench --
    ffbench  .         :0.16s  he: 3.7s (23.2x, -----)
    ffbench  trunk_untouched:0.16s  he: 3.7s (23.4x, -0.8%)
    -- heap --
    heap     .         :0.05s  he: 5.1s (102.8x, -----)
    heap     trunk_untouched:0.05s  he: 5.2s (104.6x, -1.8%)
    -- heap_pdb4 --
    heap_pdb4 .         :0.07s  he: 5.8s (82.9x, -----)
    heap_pdb4 trunk_untouched:0.07s  he: 5.8s (83.3x, -0.5%)
    -- many-loss-records --
    many-loss-records .         :0.01s  he: 1.0s (96.0x, -----)
    many-loss-records trunk_untouched:0.01s  he: 0.9s (95.0x,  1.0%)
    -- many-xpts --
    many-xpts .         :0.04s  he: 1.6s (38.8x, -----)
    many-xpts trunk_untouched:0.04s  he: 1.5s (38.5x,  0.6%)
    -- memrw --
    memrw    .         :0.06s  he: 2.5s (41.2x, -----)
    memrw    trunk_untouched:0.06s  he: 2.5s (41.2x,  0.0%)
    -- sarp --
    sarp     .         :0.02s  he: 4.0s (198.0x, -----)
    sarp     trunk_untouched:0.02s  he: 3.9s (196.5x,  0.8%)
    -- tinycc --
    tinycc   .         :0.10s  he: 7.1s (70.7x, -----)
    tinycc   trunk_untouched:0.10s  he: 7.6s (75.8x, -7.2%)
    -- Finished tests in perf ----------------------------------------------

    == 12 programs, 24 timings =================
2022-12-29 11:14:05 +01:00
Paul Floyd
9acdd79b69 Disable some memcheck tests on FreeBSD
Fail due to differences in DWARF varinfo generated by clang
compared to GCC. No fix in perspective.
2022-12-26 11:06:32 +01:00
Paul Floyd
4dcfc05c20 Fixes related to Bug 392331
1. Added C++17 check to configure.ac
2. Needed Linux version of suppression
3. Added a filter for pthread_cond_signal
2022-12-26 09:04:17 +01:00
Paul Floyd
67bb7eeec9 Fix suppression file inconsistency from previous commit for Bug 392331 2022-12-25 22:31:55 +01:00
Paul Floyd
7d0389956e Bug 392331 - Spurious lock not held error from inside pthread_cond_timedwait
Added a "Dubious" error category to cover this kind of error.
2022-12-25 21:43:36 +01:00
Paul Floyd
227fa1d53b Cleanup for clangd, mostly FreeBSD
Consistently use braces. Make some bitwise expressions use unsigned.
Use some named variables for magic numbers.
2022-12-25 18:36:20 +01:00
Paul Floyd
d8cc70f6d5 FreeBSD only: fix 445743
Restart 3 of the umtx_op mutex operations if they are interrupted.
2022-12-25 10:18:51 +01:00
Paul Floyd
29cfa77b23 FreeBSD: enable PERF_FAST_LOADV for x86 and cleanup for clangd
clangd doesn't like asm, prefers __asm__
some hicpp-braces-around-statements fixes
2022-12-25 09:25:01 +01:00
Bart Van Assche
1845f51728 Revert "syscall"
Revert an incomplete commit that got published accidentally.
2022-12-24 16:49:56 -08:00
Bart Van Assche
72b556ab15 drd: Improve barrier support
Make test drd/tests/pth_barrier_thr_cr pass on Fedora 38.
2022-12-24 15:32:15 -08:00
Bart Van Assche
2bd7f70421 syscall 2022-12-24 08:18:01 -08:00
Paul Floyd
2de91d914c Bug 444488 - Use glibc.pthread.stack_cache_size tunable
Try to use GLIBC_TUNABLES to disable the pthread stack
cache.
2022-12-23 16:51:15 +01:00
Philippe Waroquiers
7e03a15d8d Pass a dummy process_option_state for dynamic options
The process_option_state is functionally needed during initial parsing
of CLO options.  When later changing them, only changing the CLO
itself is good enough.
But the processing of option needs to have a state.
2022-12-23 16:15:23 +01:00
Paul Floyd
316282cd3b Bug 463027 - broken check for MPX instruction support in assembler 2022-12-23 14:49:39 +01:00
Paul Floyd
8b0105ba63 Improve FreeBSD preadv/pwritev error messages
Also correct a copy paste error in generic readv.
2022-12-22 23:38:54 +01:00
Paul Floyd
5b52408406 Bug 462830 - WARNING: unhandled amd64-freebsd syscall: 474
Add syscall wrappers for sctp_generic_recvmsg and sctp_generic_sendmsg
on FreeBSD.
2022-12-22 23:08:45 +01:00
Paul Floyd
35bb01dd45 FreeBSD: make amd64 aspace max mem 128Gbytes 2022-12-22 09:30:45 +01:00
Paul Floyd
1c61a442b1 FreeBSD: add a check that the mqueuefs kernel module is loaded for the none/tests/mq regtest 2022-12-22 09:09:52 +01:00
Mark Wielaard
0811a612dd Implicit int in none/tests/faultstatus.c
There is a definition in faultstatus.c that is not accepted by
C99 compilers (implicit ints were removed in that language revision).

https://bugs.kde.org/show_bug.cgi?id=462007
2022-11-18 20:12:06 +01:00
Paul Floyd
5ab1e53f07 Manual: add FreeBSD to section about Linux stack cache
Use macOS rather than Mac OS X
2022-11-13 07:41:25 +01:00
Paul Floyd
ac6d9faf4b Bug 351857 - confusing error message about valid command line option
Added code to handle missing "=something".
2022-11-12 21:02:07 +01:00
Alexandra Petlanova Hajkova
ea91997394 vgdb: allow address reuse to avoid "address already in use" errors
https://bugs.kde.org/show_bug.cgi?id=459476
2022-11-12 13:03:46 +01:00
Paul Floyd
f2550057e1 Bug 170510 - Don't warn about ioctl of size 0 without direction hint
Apply this to generic and update the message on all platforms.
2022-11-10 22:31:07 +01:00
Carl Love
873f376695 Bug 444110 priv/guest_ppc_toIR.c: warning: duplicated 'if' condition
The compiler reported a duplicated condition in VEX/priv/guest_ppc_toIR.c
The handling of the plbz and xxpermx instructions have the same if/elseif
conditions.  The else if condition for the plbz instruction was wrong.  The
elseif statement should be checking for pType2 not pType1.  The plbz
instruction was inadvertently being handled by the else statement for
the lbz instruction.

This patch fixes the checking for the plbz and lbz instructions.
2022-10-31 18:28:36 +00:00
Paul Floyd
6c9aae8f44 FreeBSD: more filtering for gdbserver_tests/nlvgdbsigqueue
Needed for FreeBSD 14 without debug info files.
2022-10-28 22:19:47 +02:00
Paul Floyd
aed1e501c8 FreeBSD: fix a typo in my previous commit for VKI_AT_USRSTACKLIM define. 2022-10-28 17:04:26 +02:00
Paul Floyd
4ff2185f45 FreeBSD: remove dependency on elf header and make VKI_ copies of AT defines
Also prepare NEWS and configure.ac for 3.21.0
2022-10-28 16:52:50 +02:00
Mark Wielaard
5147d671e4 -> 3.20.0 final 2022-10-24 13:59:17 +02:00
Paul Floyd
328ece8463 Fix DRD and Helgrind on Solaris.
It seems as though Solaris RW sections can also have the
execute flag set. Checking for RW and !X was causing the
debuginfo reading to fail. That meant that the helgrind and
drd preload shared libraries weren't processed, and also
the rtld bind function pointers not setup. Without the rtld bind
function an assert fires and Helgrind and DRD abort.
2022-10-23 15:29:40 +02:00
Mark Wielaard
206dbcfed9 {callgrind,callgrind}/tests/ann{1,2}.vgtest touch cgout-test
Both a.c and cgout-test are checked into the repository and
used in testcases. Make sure cgout-test is newer than a.c
before running the post script to prevent warnings liks:

@@ WARNING @@ WARNING @@ WARNING @@ WARNING @@ WARNING @@ WARNING @@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ Source file 'a.c' is more recent than input file
../../cachegrind/tests/cgout-test'.
@ Annotations may not be correct.
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
2022-10-22 17:31:58 +02:00
Paul Floyd
0ea3746e97 Fix build on macOS
A while back when I added support for split RW PT_LOAD sections
one instance in the macho code didn't get updated. Also
update the comment that refers to the old struct member that
got renamed.
2022-10-20 23:15:00 +02:00
Mark Wielaard
b112a9b37a Set version to 3.20.0-RC1 and update NEWS 2022-10-20 01:40:12 +02:00
Mark Wielaard
6a5a689fd9 Add none/tests/freebsd/auxv.stderr.exp-freebsd14 to EXTRA_DIST 2022-10-20 00:34:15 +02:00
Paul Floyd
12d2a3c85d Auxv user stack for FreeBSD, last part
Clean up, didn't need an extra func for user stack limit.
2022-10-19 00:51:05 +02:00
Paul Floyd
802f2d21d9 Auxv user stack for FreeBSD, part 2
Try to set the stack limit.
2022-10-18 22:11:32 +02:00
Paul Floyd
121374b287 Add auxv entry for usrstack on FreeBSD 14, part 1
Previously the user stack was obtained using the kern.usrstack
sysctl. This has been moved to auxv in FreeBSD 14. Without
this change all programs linked with libthr fail with a panic
when they fail to get a valid user stack address.

Note also in FreeBSD 14 ASLR has been enabled. This means that
there is now some extra difference between the address layout of
a standalone executable and the same executable under valgrind.

Pre-FreeBSD 14 and under valgrind:
lib rtld is loaded after the executable (though a much smaller gap
inder valgrind)
user stack starts at 0x7ffffffff000

FreeBSD 14
lib rtld is loaded at a much higher address, around 0xeeeecc15000
user stack is at a much lower address, around 0x82073d000

This means that valgrind behaves somewhat as thogh the
kern.elf(64|32).aslr.stack sysctl were set to 0.

Some more work will be needed for the stack size.
There are no plans at the moment to match the FreeBSD 14 memory
layout.
2022-10-18 23:38:36 +02:00
Paul Floyd
b31ff3321e Improve FreeBSD handling of W^X setting.
FreeBSD has a sysctl that prevents mmapping regions
that are both Write and Exec. This setting prevents
Valgrind from workig correctly.

This change uses ELF tags to turn off W^X control,
and also removes a sysctl check for the same flag.

Patch contributor:
0a3a794143
2022-10-16 18:58:52 +02:00
Philippe Waroquiers
348775f34b Remove register cache to fix 458915 gdbserver causes wrong syscall return
The valgrind gdbserver inheritated a register cache from the original
GDBserver implementation.
The objective of this register cache was to improve the performance
of GDB-> gdbserver -> inferior by avoiding the gdbserver having to
do ptrace system calls each time GDB wants to read or write a register
when the inferior is stopped.

This register cache is however not useful for the valgrind gdbserver:
As the valgrind gdbserver being co-located with the inferior, it
can directly and efficiently read and write registers from/to the VEX
state.

This commit ensures the valgrind GDBserver directly reads from
VEX state instead of fetching the registers from the VEX state and
copying them to the gdbserver regcache.

Similarly, when GDB wants to modify a register, the valgrind GDB server now
directly writes into the VEX state instead of writing the registers
in the regcache and having the regcache flushed to the VEX state
when execution is resumed.

The files regcache.h and regcache.c are still useful as they provide
a translation between a register number, a register name on one side
and the offset in an array of bytes in the format expected by GDB.
The regcache now is only used to create this array of bytes, which is
itself only used temporarily when GDB reads or writes the complete
set of registers instead of reading/writing one register at a time.

Removing the usage of this regcache avoids the bug 458915.
The regcache was causing the bug in the following circumstances:
We have a thread executing code, while we have a bunch of threads
that are blocked in a syscall.
When a thread is blocked in a syscall, the VEX rax register is set to the
syscall nr.
A thread executing code will check from time to time if GDB tries to
attach.
When GDB attaches to the valgrind gdbserver , the thread executing code
will copy the registers from all the threads to the thread gdbserver regcache.
However, the threads blocked in a system call can be unblocked e.g.
because the epoll_wait timeout expires. In such a case, the thread will
still execute the few instructions that follow the syscall instructions
till the thread is blocked trying to acquire the scheduler lock.
These instructions are extracting the syscall return code from the host
register and copies it to the valgrind VEX state.
However, this assembly code is not aware that there is a gdbserver cache.
When the unblocked thread is on the acquire lock statement,
the GDB server regcache is now inconsistent (i.e. different from) the
real VEX state.
When finally GDB tells GDB server to continue execution, the GDB server
wrongly detected that its regcache was modified compared to the VEX state:
the regcache still contains e.g. for the rax register the syscall number
while the unblocked thread has put the syscall return code in the VEX
rax register. GDBserver then flushed the regcache rax (containing the
syscall number) to the VEX rax.
And that led to the detected bug that the syscall return code seen by
the guest application was the syscall number.

Removing the regcache ensures that GDB directly reads the values
from VEX and directly writes to VEX state.

Note that we could still have GDB reading from VEX a register value
that will be changed a few instructions later.
GDB will then show some (slightly) old/obsolete values
for some registers to the user.
This should have no consequence as long as GDB does not try to modify
the registers to execute an inferior call.

The bug did not happen systematically as most of the time, when threads are
blocked in syscalls, vgdb attaches using ptrace to the valgrind process.
When vgdb attaches with ptrace, it stops all the threads using linux syscall.
When vgdb stops the threads, the threads blocked in a syscall will not
execute the instructions between the syscall instruction and the lock
acquire, and so the problem of desynchronisation between the VEX state
and the register cache could not happen.

This commit touches architecture specific files of the gdbserver,
it has been tested on amd64/debian, on pcc64/centos and on arm64/ubuntu.
Possibly, some untested arch might not compile but the fix should be trivial.
2022-10-16 00:44:40 +02:00
Paul Floyd
2dde5c405b Bug 131186 - writev reports error in (vector[...])
Use the index rather than ...
Also done for readv.
2022-10-12 08:34:51 +02:00
Philippe Waroquiers
3c57204534 Fix 459477 missing \n in XERROR and ERROR calls
Based on a patch by Alexandra Hajkova.
2022-09-25 13:13:31 +02:00