]> git.ipfire.org Git - thirdparty/valgrind.git/log
thirdparty/valgrind.git
2 years agoIllumos: regtest filters and gitignore
Paul Floyd [Sat, 28 Jan 2023 17:27:16 +0000 (18:27 +0100)] 
Illumos: regtest filters and gitignore

Filter for the gdb python autoload warnings
Filter for another variation of shell abort messages

2 years agoRegtest: broaden suppression for helgrind bug 392331
Paul Floyd [Fri, 27 Jan 2023 19:00:26 +0000 (20:00 +0100)] 
Regtest: broaden suppression for helgrind bug 392331

Inlining differences on different Linux platforms.

2 years agoBug 382034 - Testcases build fixes for musl
Paul Floyd [Fri, 27 Jan 2023 07:42:06 +0000 (08:42 +0100)] 
Bug 382034 - Testcases build fixes for musl

2 years agoBug 464859 - Build failures with GCC-13 (drd tsan_unittest)
Paul Floyd [Fri, 27 Jan 2023 07:30:41 +0000 (08:30 +0100)] 
Bug 464859 - Build failures with GCC-13 (drd tsan_unittest)

Patch submitted by
Khem Raj <raj.khem@gmail.com>

2 years agoLinux regtest: some extra filtering for helgrind bug392331
Paul Floyd [Fri, 27 Jan 2023 07:22:19 +0000 (08:22 +0100)] 
Linux regtest: some extra filtering for helgrind bug392331

Was failing on rhel 7.6

2 years agoLinux regtest: forgot prereq test for scalar_openat2
Paul Floyd [Fri, 27 Jan 2023 06:40:31 +0000 (07:40 +0100)] 
Linux regtest: forgot prereq test for scalar_openat2

2 years agoFreeBSD: update comment about __sysctlbyname and kern.proc.pathname
Paul Floyd [Wed, 25 Jan 2023 07:31:09 +0000 (08:31 +0100)] 
FreeBSD: update comment about __sysctlbyname and kern.proc.pathname

2 years agoFreeBSD: fix compile of auxv on FreeBSD 12
Paul Floyd [Tue, 24 Jan 2023 21:00:44 +0000 (22:00 +0100)] 
FreeBSD: fix compile of auxv on FreeBSD 12

2 years agoFreeBSD: fix build on older OSes
Paul Floyd [Tue, 24 Jan 2023 20:54:09 +0000 (21:54 +0100)] 
FreeBSD: fix build on older OSes

A bad copy-and-paste broke compilation on FreeBSD 12.

2 years agoFreeBSD: remove different reserved fds number
Paul Floyd [Tue, 24 Jan 2023 20:03:48 +0000 (21:03 +0100)] 
FreeBSD: remove different reserved fds number

No idea where it originated. Causes no problems on
FreeBSD 13.1 amd64.

2 years agoFreeBSD: switch to FreeBSD 12 versions of syscalls for fstat etc
Paul Floyd [Tue, 24 Jan 2023 19:38:26 +0000 (20:38 +0100)] 
FreeBSD: switch to FreeBSD 12 versions of syscalls for fstat etc

This was a change that enabled 64bit inodes (ino64).

Also a couple of typos in READMEs.

2 years agoBug 435441 - valgrind fails to interpose malloc on musl 1.2.2 due to weak symbol...
Paul Floyd [Mon, 23 Jan 2023 08:05:50 +0000 (09:05 +0100)] 
Bug 435441 - valgrind fails to interpose malloc on musl 1.2.2 due to weak symbol name and no libc soname

Patch by Michael Forney <mforney@mforney.org>

2 years agoFreeBSD: More details on interrupting vgdb and correct 1 typo.
Paul Floyd [Mon, 23 Jan 2023 06:27:55 +0000 (07:27 +0100)] 
FreeBSD: More details on interrupting vgdb and correct 1 typo.

2 years agoFreeBSD: start adding more checks for /proc
Paul Floyd [Sun, 22 Jan 2023 20:48:51 +0000 (21:48 +0100)] 
FreeBSD: start adding more checks for /proc

Also add a couple of expecteds.

2 years agoFreeBSD: improve auxv filter
Paul Floyd [Sun, 22 Jan 2023 08:41:49 +0000 (09:41 +0100)] 
FreeBSD: improve auxv filter

Didn't work id the clone directory isn't 'valgrind'

2 years agoFreeBSD: Fix auxv AT_EXECPATH
Paul Floyd [Sat, 21 Jan 2023 19:46:24 +0000 (20:46 +0100)] 
FreeBSD: Fix auxv AT_EXECPATH

This was being copied from the host. Now it's synthesized for
the guest. Also improve the none/freebsd/auxv test to
print a few of the strings in auxv (but not the envp ones).

2 years agoTwo more debuginfo.c typos
Paul Floyd [Sat, 21 Jan 2023 17:09:47 +0000 (18:09 +0100)] 
Two more debuginfo.c typos

2 years agoBug 464476 - Firefox fails to start under Valgrind
Paul Floyd [Sat, 21 Jan 2023 16:55:09 +0000 (17:55 +0100)] 
Bug 464476 - Firefox fails to start under Valgrind

On FreeBSD, Firefox uses the kern.proc.pathname.PID sysctl
to get the binary path (where PID can be the actual pid
or -1). The user path is /usr/local/bin/firefox which is
a symlink to /usr/local/lib/firefox/firefox.

This was failing because we were not handling this MIB.
That meant that the sysctl returned the path for the
binary of the running tool (e.g.,
/home/paulf/scratch/valgrind/memcheck/memcheck-amd64-freebsd).
Firefox looks for files in the same directory.
Since it was the wrong directory it failed to find them and
exited.

I also noticed a lot of _umtx_op errors. On analysis they
are spurious. The wake ops take an "obj" argument, a pointer
to a variable. They only use the address as a key for
lookups and don't read the contents.

2 years agoFreeBSD: small change for pthread mutex types
Paul Floyd [Sat, 21 Jan 2023 12:51:50 +0000 (13:51 +0100)] 
FreeBSD: small change for pthread mutex types

It seems what is 'normal' and 'default' is not
portable.

And a bit more debuginfo mmap comment fixing

2 years agoCleanup mmap comments in debuginfo.c
Paul Floyd [Sat, 21 Jan 2023 12:34:47 +0000 (13:34 +0100)] 
Cleanup mmap comments in debuginfo.c

2 years agom_debuginfo: Suppress warning about not handling entry_value ops
Mark Wielaard [Sun, 15 Jan 2023 13:24:19 +0000 (14:24 +0100)] 
m_debuginfo: Suppress warning about not handling entry_value ops

The warning: evaluate_Dwarf3_Expr: unhandled DW_OP_ 0xf3 isn't
very helpful. This means we didn't handle DW_OP_GNU_entry_value.

DW_OP_GNU_entry_value (or DWARF5 DW_OP_entry_value) means interpreting
the given DWARF expression using register values as they were upon
entering the function. Which is non-trivial to implement.

We can fail the evaluation of the DWARF expression without warning
about it by default, since it isn't really needed for any current
valgrind functionality (and it is only done with --read-var-info=yes.

2 years agoFreeBSD: some _umtx_op corrections
Paul Floyd [Sun, 15 Jan 2023 08:05:55 +0000 (09:05 +0100)] 
FreeBSD: some _umtx_op corrections

mutex trylock doesn't user timer arguments
plain mutex lock doesn't need restart

still not sure about mutex trylock

2 years agoFreeBSD: some more clangd refactoring
Paul Floyd [Sun, 15 Jan 2023 06:20:08 +0000 (07:20 +0100)] 
FreeBSD: some more clangd refactoring

2 years agoRemove execute bit from drd tests std_string.cpp
Paul Floyd [Sat, 14 Jan 2023 15:24:00 +0000 (16:24 +0100)] 
Remove execute bit from drd tests std_string.cpp

2 years agoUpdate wrong expecteds for Bug 241072
Paul Floyd [Thu, 12 Jan 2023 07:00:27 +0000 (08:00 +0100)] 
Update wrong expecteds for Bug 241072

2 years agoBug 241072 List tools in --help output
Paul Floyd [Wed, 11 Jan 2023 20:42:41 +0000 (21:42 +0100)] 
Bug 241072 List tools in --help output

2 years agos390: Add z16 support to ecag testcase
Andreas Arnez [Thu, 8 Dec 2022 12:39:25 +0000 (13:39 +0100)] 
s390: Add z16 support to ecag testcase

The testcase 'none/tests/s390x/ecag' requires expected output from any
machine it runs on.  This is missing for z16, so add it.

2 years agos390: Add test for short/extended vector float insns
Andreas Arnez [Wed, 26 Oct 2022 17:45:30 +0000 (19:45 +0200)] 
s390: Add test for short/extended vector float insns

Several issues with vector floating point instructions have gone unnoticed
due to a lack of test coverage in this area.  Add a test case that
improves the coverage, particuarly when dealing with short and extended
floating point formats.

2 years agos390: Stop CC clobbering by VFMIN and VFMAX
Andreas Arnez [Thu, 1 Dec 2022 14:20:21 +0000 (15:20 +0100)] 
s390: Stop CC clobbering by VFMIN and VFMAX

Valgrind's implementation of the VFMIN and VFMAX instructions clobbers the
condition code, which is wrong.  Stop doing that.

2 years agos390: Un-swap implementations of VFCH and VFCHE
Andreas Arnez [Thu, 1 Dec 2022 10:02:12 +0000 (11:02 +0100)] 
s390: Un-swap implementations of VFCH and VFCHE

When running under Valgrind, the VFCH instruction behaves like VFCHE, and
vice versa.  Fix this.

2 years agos390: Fix VFMA, VFMS, VFNMA, and VFNMS for 128-bit FP
Andreas Arnez [Wed, 30 Nov 2022 18:15:53 +0000 (19:15 +0100)] 
s390: Fix VFMA, VFMS, VFNMA, and VFNMS for 128-bit FP

When trying to execute any of the vector float multiply-and-add family
instructions, Valgrind panics with the message "Iex_Qop with F128 data".

So far all F128 operations were implemented with instructions that operate
on FP register pairs.  However, such instructions don't exist for
Iop_MAddF128 and Iop_MSubF128, so they must be implemented with vector
instructions instead.  This was missed when emitting them in
"guest_s390_toIR.c".

Add the missing support.  This also involves adding a few new features to
host_s390_defs:

* a new vector operation S390_VEC_INIT_FROM_FPRS

* the capability to move the left half of a VR to an FPR

* S390_VEC_FLOAT_MADD/_MSUB for 128-bit sizes

2 years agoBug 460356 -- s390: Fix code generation for Iop_Sqrt32Fx4
Andreas Arnez [Thu, 13 Oct 2022 12:29:08 +0000 (14:29 +0200)] 
Bug 460356 -- s390: Fix code generation for Iop_Sqrt32Fx4

There is no instruction selector for Iop_Sqrt32Fx4, leading to Valgrind
panicking with the message:

   s390_isel_vec_expr: cannot reduce tree

Fix this.

2 years agogdbserver tests filter out uninstalled python scripts warnings
Mark Wielaard [Wed, 11 Jan 2023 14:44:27 +0000 (15:44 +0100)] 
gdbserver tests filter out uninstalled python scripts warnings

Filter out loading error messages when python scripts haven't
been installed yet (running against vg-in-place)

2 years agoLinux regtest: openat2 not available on older systems
Paul Floyd [Tue, 10 Jan 2023 20:00:22 +0000 (21:00 +0100)] 
Linux regtest: openat2 not available on older systems

The x86-linux/scalar testcase fas failing to compile.
So split out openat2 into a separate test with a condfigure test.

2 years agoFix gdbserver tests failing when python code cannot be autoloaded.
Philippe Waroquiers [Mon, 9 Jan 2023 05:01:36 +0000 (06:01 +0100)] 
Fix gdbserver tests failing when python code cannot be autoloaded.

If the valgrind python code loading is not authorised by GDB config,
ensure the related error messages and info messages are filtered.

2 years agoCleanup warnings
Paul Floyd [Mon, 9 Jan 2023 22:57:01 +0000 (23:57 +0100)] 
Cleanup warnings

Now no warnings on Fedora 36
For a short while

2 years agoFreeBSD: clang-tidy corrections
Paul Floyd [Sun, 8 Jan 2023 16:52:48 +0000 (17:52 +0100)] 
FreeBSD: clang-tidy corrections

2 years agoCleanup of warnings, mostly -Wno-unused-but-set-variable
Paul Floyd [Sun, 8 Jan 2023 16:51:37 +0000 (17:51 +0100)] 
Cleanup of warnings, mostly -Wno-unused-but-set-variable

2 years agoImplement front end GDB commands for Valgrind gdbserver monitor commands.
Philippe Waroquiers [Tue, 27 Dec 2022 20:51:30 +0000 (21:51 +0100)] 
Implement front end GDB commands for Valgrind gdbserver monitor commands.

This commit implements in python a set of GDB commands corresponding to the
Valgrind gdbserver monitor commands.

Basically, the idea is that one GDB command is defined for each valgrind
gdbserver subcommand and will generate and send a monitor command to valgrind.

The python code is auto-loaded by GDB as soon as GDB observes that the valgrind
preload core shared lib is loaded (e.g. vgpreload_core-amd64-linux.so).
This automatic loading is done thanks to the .debug_gdb_scripts section
added in vg_preloaded.c file.

Sadly, the auto-load only happens once valgrind has started to execute the code
of ld that loads this vg_preload file.

I have tried 2 approaches to have the python code auto-loaded when attaching at
startup to valgrind:
  * have valgrind gdbserver reporting first to GDB that the executable file is
    the tool executable (with a .debug_gdb_scripts section) and then reporting
    the real (guest) executable file.
    The drawback of this approach is that it triggers a warning/question in GDB
    according to the GDB setting 'set exec-file-mismatch'.
  * have valgrind gdbserver pretending to be multiprocess enabled, and report
    a fake process using the tool executable with a .debug_gdb_scripts section.
    The drawback of this is that this always creates a second inferior in GDB,
    which will be confusing.

Possibly, we might complete the below message :
  ==2984378== (action at startup) vgdb me ...
  ==2984378==
  ==2984378== TO DEBUG THIS PROCESS USING GDB: start GDB like this
  ==2984378==   /path/to/gdb /home/philippe/valgrind/littleprogs/some_mem
  ==2984378== and then give GDB the following command
  ==2984378==   target remote | /home/philippe/valgrind/git/improve/Inst/libexec/valgrind/../../bin/vgdb --pid=2984378
  ==2984378== --pid is optional if only one valgrind process is running

with:
  ==2984378== GDB valgrind python specific commands will be auto-loaded when execution begins.
  ==2984378== Alternatively, you might load it before with the GDB command:
  ==2984378==   source /abs/path/to/valgrind/install/libexec/valgrind/valgrind-monitor.py

The following GDB setting traces the monitor commands sent by a GDB valgrind
command to the valgrind gdbserver:
  set debug valgrind-execute-monitor on

How to use the new GDB valgrind commands?
-----------------------------------------

The usage of the GDB front end commands is compatible with the
monitor command as accepted today by Valgrind.

For example, the memcheck monitor command "xb' has the following usage:
 xb <addr> [<len>]

With some piece of code:
   'char some_mem [5];'
xb can be used the following way:
  (gdb) print &some_mem
  (gdb) $2 = (char (*)[5]) 0x1ffefffe8b
  (gdb) monitor xb 0x1ffefffe8b 5
       ff   ff   ff   ff   ff
  0x4A43040:   0x00 0x00 0x00 0x00 0x00
  (gdb)

The same action can be done with the new GDB 'memcheck xb' command:
  (gdb) memcheck xb 0x1ffefffe8b 5
       ff   ff   ff   ff   ff
  0x1FFEFFFE8B:   0x00 0x00 0x00 0x00 0x00
  (gdb)

At this point, you might ask yourself: "what is the interest ?".

Using GDB valgrind commands provides several advantages compared to
the valgrind gdbserver monitor commands.

Evaluation of arguments by GDB:
-------------------------------
For relevant arguments, the GDB command will evaluate its arguments using
the usual GDB evaluation logic, for example, instead of printing/copying
the address and size of 'some_mem', the following will work:
  (gdb) memcheck xb &some_mem sizeof(some_mem)
       ff   ff   ff   ff   ff
  0x1FFEFFFE8B:   0x00 0x00 0x00 0x00 0x00
  (gdb)

or:
  (gdb) p some_mem
  $4 = "\000\000\000\000"
  (gdb) memcheck xb &$4
       ff   ff   ff   ff   ff
  0x1FFEFFFE8B:   0x00 0x00 0x00 0x00 0x00
  (gdb)

This is both easier to use interactively and easier to use in GDB scripts,
as you can directly use variable names in the GDB valgrind commands.

Command completion by GDB:
--------------------------
The usual command completion in GDB will work for the GDB valgrind commands.
For example, typing TAB after the letter 'l' in:
  (gdb) valgrind v.info l
will show the 2 "valgrind v.info" subcommands:
  last_error  location
  (gdb) valgrind v.info l

Note that as usual, GDB will recognise a command as soon as it is unambiguous.

Usual help and apropos support by GDB:
--------------------------------------
The Valgrind gdbserver provides an online help using:
  (gdb) monitor help
However, this gives the help for all monitor commands, and is not searchable.
GDB provides a better help and documentation search.
For example, the following commands can be used to get various help
or search the GDB Valgrind command online documentation:
   help valgrind
   help memcheck
   help helgrind
   help callgrind
   help massif
to get help about the general valgrind commands or the tool specific commands.

Examples of searching the online documentation:
  apropos valgrind.*location
  apropos -v validity
  apropos -v leak

User can define aliases for the valgrind commands:
--------------------------------------------------
The following aliases are predefined:
  v and vg for valgrind
  mc for memcheck
  hg for helgrind
  cg for callgrind
  ms for massif

So, the following will be equivalent:
   (gdb) valgrind v.info location &some_mem
   (gdb) v v.i lo &some_mem
   (gdb) alias Vl = valgrind v.info location
   (gdb) Vl &some_mem

Thanks to Hassan El Karouni for the help in factorising the python
code common to all valgrind python commands using a decorator.

2 years agoAvoid doing mempool specific leak search activities if there are no mempools
Philippe Waroquiers [Sun, 8 Jan 2023 10:50:07 +0000 (11:50 +0100)] 
Avoid doing mempool specific leak search activities if there are no mempools

For most memcheck users, no mempools are used, but the leak search logic
was doing in any case special handling, leading to useless work such as
sorting again an already sorted array and making a copy of an array without
modifying it.

This slightly optimises the perf reg tests of memcheck.
perl perf/vg_perf --tools=memcheck --vg=. --vg=../trunk_untouched perf
-- Running  tests in perf ----------------------------------------------
-- bigcode1 --
bigcode1 .         :0.08s  me: 3.0s (38.1x, -----)
bigcode1 trunk_untouched:0.08s  me: 3.1s (38.6x, -1.3%)
-- bigcode2 --
bigcode2 .         :0.07s  me: 7.4s (105.9x, -----)
bigcode2 trunk_untouched:0.07s  me: 7.5s (107.4x, -1.5%)
-- bz2 --
bz2      .         :0.40s  me: 5.2s (12.9x, -----)
bz2      trunk_untouched:0.40s  me: 5.4s (13.6x, -5.0%)
-- fbench --
fbench   .         :0.15s  me: 2.8s (18.8x, -----)
fbench   trunk_untouched:0.15s  me: 2.9s (19.0x, -1.1%)
-- ffbench --
ffbench  .         :0.16s  me: 2.7s (16.8x, -----)
ffbench  trunk_untouched:0.16s  me: 2.7s (17.1x, -1.9%)
-- heap --
heap     .         :0.06s  me: 4.0s (66.5x, -----)
heap     trunk_untouched:0.06s  me: 4.1s (68.7x, -3.3%)
-- heap_pdb4 --
heap_pdb4 .         :0.07s  me: 6.2s (89.1x, -----)
heap_pdb4 trunk_untouched:0.07s  me: 6.6s (94.9x, -6.4%)
-- many-loss-records --
many-loss-records .         :0.01s  me: 1.2s (122.0x, -----)
many-loss-records trunk_untouched:0.01s  me: 1.2s (125.0x, -2.5%)
-- many-xpts --
many-xpts .         :0.03s  me: 1.2s (41.7x, -----)
many-xpts trunk_untouched:0.03s  me: 1.3s (43.7x, -4.8%)
-- memrw --
memrw    .         :0.06s  me: 1.2s (19.8x, -----)
memrw    trunk_untouched:0.06s  me: 1.2s (20.2x, -1.7%)
-- sarp --
sarp     .         :0.02s  me: 1.8s (91.5x, -----)
sarp     trunk_untouched:0.02s  me: 2.1s (103.5x,-13.1%)
-- tinycc --
tinycc   .         :0.11s  me: 7.1s (64.4x, -----)
tinycc   trunk_untouched:0.11s  me: 7.1s (64.3x,  0.1%)
-- Finished tests in perf ----------------------------------------------

== 12 programs, 24 timings =================

2 years agoBug 433873 - openat2 syscall unimplemented on Linux
Paul Floyd [Fri, 6 Jan 2023 20:27:01 +0000 (21:27 +0100)] 
Bug 433873 - openat2 syscall unimplemented on Linux

This syscall is not exposed via glibc, so there is only an
addition to the scalar test.

2 years agoRemove a debugging line `if (0) ..` that mistakenly got landed in fa3a9cc43c22593c707...
Julian Seward [Wed, 4 Jan 2023 16:43:21 +0000 (17:43 +0100)] 
Remove a debugging line `if (0) ..` that mistakenly got landed in fa3a9cc43c22593c70796a99aff33bb9436ad448.

2 years agoFix 64-bit uncleanness in VG_(get_bbs_translated)/VG_(get_bbs_discarded_or_dumped) ..
Julian Seward [Wed, 4 Jan 2023 16:12:21 +0000 (17:12 +0100)] 
Fix 64-bit uncleanness in VG_(get_bbs_translated)/VG_(get_bbs_discarded_or_dumped) ..

.. and some debug printing associated with them.  I don't think this affects
anything apart from debug printing.  Noticed when running a x86 (32-bit)
Firefox build.

2 years agoamd64 and x86 front ends: add a few more spec rules.
Julian Seward [Wed, 4 Jan 2023 16:04:03 +0000 (17:04 +0100)] 
amd64 and x86 front ends: add a few more spec rules.

amd64:
  S and NS  after LOGICQ (per comments from Eyal Soha on the dev list)
  S         after SHLQ
  NZ        after SHLL

x86:
  NZ        after SHRL
  Z         after SHLL

I would have liked to have added the inverse conditions in all cases (eg, both
S and NS, or both Z and NZ), but finding use cases for some of these is almost
impossible, hence they are sometimes omitted.  All of the added cases have
been tested.

2 years agoMemcheck: handle origin data for 8-/16-bit shadow stores a bit more accurately.
Julian Seward [Wed, 4 Jan 2023 15:32:03 +0000 (16:32 +0100)] 
Memcheck: handle origin data for 8-/16-bit shadow stores a bit more accurately.

With origin tracking enabled, 8- and 16-bit stores could sometimes lose origin
info unnecessarily.  This patch removes this avoidable lossage.  (Since MC
only stores 1 origin value for each 32-bit word of address space, there is
still unavoidable lossage of origins in some cases; this patch does not help
in those cases since it's a fundamental design limitation.)

2 years agoDHAT: increase the size of the cache for `find_Block_containing` from 2 to 3.
Julian Seward [Wed, 4 Jan 2023 14:38:12 +0000 (15:38 +0100)] 
DHAT: increase the size of the cache for `find_Block_containing` from 2 to 3.

In the hope of making DHAT a bit faster.

2 years agoBug 327548 - false positive while destroying mutex
Paul Floyd [Tue, 3 Jan 2023 20:28:42 +0000 (21:28 +0100)] 
Bug 327548 - false positive while destroying mutex

2 years agoSmall improvement to documentation.
Philippe Waroquiers [Mon, 2 Jan 2023 22:04:44 +0000 (23:04 +0100)] 
Small improvement to documentation.

2 years agoUpdate none/tests/cmdline1 and 2 for non-linux
Paul Floyd [Sat, 31 Dec 2022 09:13:19 +0000 (10:13 +0100)] 
Update none/tests/cmdline1 and 2 for non-linux

2 years agoAllows to only output "new" loss records when doing a leak search.
Philippe Waroquiers [Fri, 30 Dec 2022 19:05:40 +0000 (20:05 +0100)] 
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.

2 years agoAdd clo option -scheduling-quantum=<number> to control scheduler time slice.
Philippe Waroquiers [Fri, 30 Dec 2022 15:28:23 +0000 (16:28 +0100)] 
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.

2 years agoFreeeBSD: Add Helgrind suppression for void __thread_specific_ptr<_Tp>::set_pointer...
Paul Floyd [Fri, 30 Dec 2022 12:46:09 +0000 (13:46 +0100)] 
FreeeBSD: Add Helgrind suppression for void __thread_specific_ptr<_Tp>::set_pointer(pointer __p)

2 years agoAdd DRD shared_timed_mutex to Helgrind
Paul Floyd [Thu, 29 Dec 2022 21:21:03 +0000 (22:21 +0100)] 
Add DRD shared_timed_mutex to Helgrind

This uses pthread_rwlock_timedrdlock / pthread_rwlock_timedwrlock
(see commit 6ffb70e650ee7cf4ada829557dd30ababb09e078)

2 years agoAdd a variation of the Helgrind tls_threads test
Paul Floyd [Thu, 29 Dec 2022 21:08:14 +0000 (22:08 +0100)] 
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.

2 years agoBug 400793 - pthread_rwlock_timedwrlock false positive
Paul Floyd [Thu, 29 Dec 2022 21:00:53 +0000 (22:00 +0100)] 
Bug 400793 - pthread_rwlock_timedwrlock false positive

Add Helgrind intercepts for pthread_rwlock_timedwrlock
(and pthread_rwlock_timedrdlock)

Reuse the DRD trylock test

2 years agoUpdate modified hg04 reference for DRD.
Paul Floyd [Thu, 29 Dec 2022 19:59:25 +0000 (20:59 +0100)] 
Update modified hg04 reference for DRD.

2 years agoAdd a test for helgrind --history-backtrace-size
Philippe Waroquiers [Thu, 29 Dec 2022 14:56:36 +0000 (15:56 +0100)] 
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.

2 years agoFix typo in NEWS.
Philippe Waroquiers [Thu, 29 Dec 2022 12:18:27 +0000 (13:18 +0100)] 
Fix typo in NEWS.

2 years agoAdd clo option the nr of entries in helgrind --history-level=full stack traces
Philippe Waroquiers [Thu, 29 Dec 2022 10:11:01 +0000 (11:11 +0100)] 
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 =================

2 years agoDisable some memcheck tests on FreeBSD
Paul Floyd [Mon, 26 Dec 2022 10:06:32 +0000 (11:06 +0100)] 
Disable some memcheck tests on FreeBSD

Fail due to differences in DWARF varinfo generated by clang
compared to GCC. No fix in perspective.

2 years agoFixes related to Bug 392331
Paul Floyd [Mon, 26 Dec 2022 08:04:17 +0000 (09:04 +0100)] 
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

2 years agoFix suppression file inconsistency from previous commit for Bug 392331
Paul Floyd [Sun, 25 Dec 2022 21:31:55 +0000 (22:31 +0100)] 
Fix suppression file inconsistency from previous commit for Bug 392331

2 years agoBug 392331 - Spurious lock not held error from inside pthread_cond_timedwait
Paul Floyd [Sun, 25 Dec 2022 20:43:36 +0000 (21:43 +0100)] 
Bug 392331  - Spurious lock not held error from inside pthread_cond_timedwait

Added a "Dubious" error category to cover this kind of error.

2 years agoCleanup for clangd, mostly FreeBSD
Paul Floyd [Sun, 25 Dec 2022 17:36:20 +0000 (18:36 +0100)] 
Cleanup for clangd, mostly FreeBSD

Consistently use braces. Make some bitwise expressions use unsigned.
Use some named variables for magic numbers.

2 years agoFreeBSD only: fix 445743
Paul Floyd [Sun, 25 Dec 2022 09:18:51 +0000 (10:18 +0100)] 
FreeBSD only: fix 445743

Restart 3 of the umtx_op mutex operations if they are interrupted.

2 years agoFreeBSD: enable PERF_FAST_LOADV for x86 and cleanup for clangd
Paul Floyd [Sun, 25 Dec 2022 08:25:01 +0000 (09:25 +0100)] 
FreeBSD: enable PERF_FAST_LOADV for x86 and cleanup for clangd

clangd doesn't like asm, prefers __asm__
some hicpp-braces-around-statements fixes

2 years agoRevert "syscall"
Bart Van Assche [Sun, 25 Dec 2022 00:49:56 +0000 (16:49 -0800)] 
Revert "syscall"

Revert an incomplete commit that got published accidentally.

2 years agodrd: Improve barrier support
Bart Van Assche [Sat, 24 Dec 2022 22:43:40 +0000 (14:43 -0800)] 
drd: Improve barrier support

Make test drd/tests/pth_barrier_thr_cr pass on Fedora 38.

2 years agosyscall
Bart Van Assche [Mon, 20 Jun 2022 19:46:40 +0000 (12:46 -0700)] 
syscall

2 years agoBug 444488 - Use glibc.pthread.stack_cache_size tunable
Paul Floyd [Fri, 23 Dec 2022 15:49:20 +0000 (16:49 +0100)] 
Bug 444488 - Use glibc.pthread.stack_cache_size tunable

Try to use GLIBC_TUNABLES to disable the pthread stack
cache.

2 years agoPass a dummy process_option_state for dynamic options
Philippe Waroquiers [Fri, 23 Dec 2022 15:12:53 +0000 (16:12 +0100)] 
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.

2 years agoBug 463027 - broken check for MPX instruction support in assembler
Paul Floyd [Fri, 23 Dec 2022 13:49:39 +0000 (14:49 +0100)] 
Bug 463027 - broken check for MPX instruction support in assembler

2 years agoImprove FreeBSD preadv/pwritev error messages
Paul Floyd [Thu, 22 Dec 2022 22:38:54 +0000 (23:38 +0100)] 
Improve FreeBSD preadv/pwritev error messages

Also correct a copy paste error in generic readv.

2 years agoBug 462830 - WARNING: unhandled amd64-freebsd syscall: 474
Paul Floyd [Thu, 22 Dec 2022 22:08:45 +0000 (23:08 +0100)] 
Bug 462830 - WARNING: unhandled amd64-freebsd syscall: 474

Add syscall wrappers for sctp_generic_recvmsg and sctp_generic_sendmsg
on FreeBSD.

2 years agoFreeBSD: make amd64 aspace max mem 128Gbytes
Paul Floyd [Thu, 22 Dec 2022 08:30:45 +0000 (09:30 +0100)] 
FreeBSD: make amd64 aspace max mem 128Gbytes

2 years agoFreeBSD: add a check that the mqueuefs kernel module is loaded for the none/tests...
Paul Floyd [Thu, 22 Dec 2022 08:09:52 +0000 (09:09 +0100)] 
FreeBSD: add a check that the mqueuefs kernel module is loaded for the none/tests/mq regtest

2 years agoImplicit int in none/tests/faultstatus.c
Mark Wielaard [Fri, 18 Nov 2022 19:12:06 +0000 (20:12 +0100)] 
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

2 years agoManual: add FreeBSD to section about Linux stack cache
Paul Floyd [Sun, 13 Nov 2022 06:39:43 +0000 (07:39 +0100)] 
Manual: add FreeBSD to section about Linux stack cache

Use macOS rather than Mac OS X

2 years agoBug 351857 - confusing error message about valid command line option
Paul Floyd [Sat, 12 Nov 2022 18:24:51 +0000 (19:24 +0100)] 
Bug 351857 - confusing error message about valid command line option

Added code to handle missing "=something".

2 years agovgdb: allow address reuse to avoid "address already in use" errors
Alexandra Petlanova Hajkova [Wed, 7 Sep 2022 09:46:55 +0000 (05:46 -0400)] 
vgdb: allow address reuse to avoid "address already in use" errors

https://bugs.kde.org/show_bug.cgi?id=459476

2 years agoBug 170510 - Don't warn about ioctl of size 0 without direction hint
Paul Floyd [Thu, 10 Nov 2022 21:31:07 +0000 (22:31 +0100)] 
Bug 170510 - Don't warn about ioctl of size 0 without direction hint

Apply this to generic and update the message on all platforms.

2 years agoBug 444110 priv/guest_ppc_toIR.c: warning: duplicated 'if' condition
Carl Love [Mon, 31 Oct 2022 17:29:31 +0000 (13:29 -0400)] 
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.

2 years agoFreeBSD: more filtering for gdbserver_tests/nlvgdbsigqueue
Paul Floyd [Fri, 28 Oct 2022 20:19:47 +0000 (22:19 +0200)] 
FreeBSD: more filtering for gdbserver_tests/nlvgdbsigqueue

Needed for FreeBSD 14 without debug info files.

2 years agoFreeBSD: fix a typo in my previous commit for VKI_AT_USRSTACKLIM define.
Paul Floyd [Fri, 28 Oct 2022 15:04:26 +0000 (17:04 +0200)] 
FreeBSD: fix a typo in my previous commit for VKI_AT_USRSTACKLIM define.

2 years agoFreeBSD: remove dependency on elf header and make VKI_ copies of AT defines
Paul Floyd [Fri, 28 Oct 2022 14:52:50 +0000 (16:52 +0200)] 
FreeBSD: remove dependency on elf header and make VKI_ copies of AT defines

Also prepare NEWS and configure.ac for 3.21.0

2 years ago-> 3.20.0 final VALGRIND_3_20_0
Mark Wielaard [Mon, 24 Oct 2022 11:59:17 +0000 (13:59 +0200)] 
-> 3.20.0 final

2 years agoFix DRD and Helgrind on Solaris.
Paul Floyd [Sun, 23 Oct 2022 13:16:51 +0000 (15:16 +0200)] 
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.

2 years ago{callgrind,callgrind}/tests/ann{1,2}.vgtest touch cgout-test
Mark Wielaard [Sat, 22 Oct 2022 15:29:00 +0000 (17:29 +0200)] 
{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.
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

2 years agoFix build on macOS
Paul Floyd [Thu, 20 Oct 2022 21:11:42 +0000 (23:11 +0200)] 
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.

2 years agoSet version to 3.20.0-RC1 and update NEWS
Mark Wielaard [Wed, 19 Oct 2022 23:40:12 +0000 (01:40 +0200)] 
Set version to 3.20.0-RC1 and update NEWS

2 years agoAdd none/tests/freebsd/auxv.stderr.exp-freebsd14 to EXTRA_DIST
Mark Wielaard [Wed, 19 Oct 2022 22:34:15 +0000 (00:34 +0200)] 
Add none/tests/freebsd/auxv.stderr.exp-freebsd14 to EXTRA_DIST

2 years ago Auxv user stack for FreeBSD, last part
Paul Floyd [Tue, 18 Oct 2022 22:51:05 +0000 (00:51 +0200)] 
 Auxv user stack for FreeBSD, last part

Clean up, didn't need an extra func for user stack limit.

2 years agoAuxv user stack for FreeBSD, part 2
Paul Floyd [Tue, 18 Oct 2022 20:11:32 +0000 (22:11 +0200)] 
Auxv user stack for FreeBSD, part 2

Try to set the stack limit.

2 years agoAdd auxv entry for usrstack on FreeBSD 14, part 1
Paul Floyd [Tue, 18 Oct 2022 21:38:36 +0000 (23:38 +0200)] 
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.

2 years agoImprove FreeBSD handling of W^X setting.
Paul Floyd [Sun, 16 Oct 2022 16:58:52 +0000 (18:58 +0200)] 
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:
https://github.com/semihalf-Duleba-Kornel/valgrind/commit/0a3a794143f7c451a5a00e598854ae8d813f8f17

2 years agoRemove register cache to fix 458915 gdbserver causes wrong syscall return
Philippe Waroquiers [Sat, 15 Oct 2022 20:59:08 +0000 (22:59 +0200)] 
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.

2 years agoBug 131186 - writev reports error in (vector[...])
Paul Floyd [Wed, 12 Oct 2022 06:34:51 +0000 (08:34 +0200)] 
Bug 131186 - writev reports error in (vector[...])

Use the index rather than ...
Also done for readv.

2 years agoFix 459477 missing \n in XERROR and ERROR calls
Philippe Waroquiers [Sun, 25 Sep 2022 11:09:38 +0000 (13:09 +0200)] 
Fix 459477 missing \n in XERROR and ERROR calls

Based on a patch by Alexandra Hajkova.

2 years agoUpdate valinfo5 FreeBSD expected
Paul Floyd [Sun, 18 Sep 2022 19:20:12 +0000 (21:20 +0200)] 
Update valinfo5 FreeBSD expected

Slightly less diffs wrt the main one now with llvm 13 and FreeBSD 13.1

2 years agoAdd abexit to non-Linux expecteds for gdb atexit events
Paul Floyd [Sun, 18 Sep 2022 14:57:04 +0000 (16:57 +0200)] 
Add abexit to non-Linux expecteds for gdb atexit events