992 Commits

Author SHA1 Message Date
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
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
Paul Floyd
807ea10a5c Fix typo in added EXTRA_DIST expected 2022-05-27 15:45:25 +02:00
Paul Floyd
b8eddd0226 Forgot to push Makefile.am with EXTRA_DIST for new expecteds 2022-05-27 14:49:25 +02:00
Paul Floyd
60d2018d7c Add new expecteds for drd/tests/annotate_trace_memory[_xml]
With clang13 x86 there is a code gen difference wrt GCC:

gcc:
  i64 = 9;
 8048a6f:       c7 05 68 9f 04 08 09    movl   $0x9,0x8049f68
 8048a76:       00 00 00
 8048a79:       c7 05 6c 9f 04 08 00    movl   $0x0,0x8049f6c
 8048a80:       00 00 00
  i64 += 0x12345678ULL;
 8048a83:       a1 68 9f 04 08          mov    0x8049f68,%eax
 8048a88:       8b 15 6c 9f 04 08       mov    0x8049f6c,%edx
 8048a8e:       05 78 56 34 12          add    $0x12345678,%eax
 8048a93:       83 d2 00                adc    $0x0,%edx
 8048a96:       a3 68 9f 04 08          mov    %eax,0x8049f68
 8048a9b:       89 15 6c 9f 04 08       mov    %edx,0x8049f6c

 clang:
   i64 = 9;
  401ae2:       c7 05 64 3f 40 00 00    movl   $0x0,0x403f64
  401ae9:       00 00 00
  401aec:       c7 05 60 3f 40 00 09    movl   $0x9,0x403f60
  401af3:       00 00 00
  i64 += 0x12345678ULL;
  401af6:       8b 15 60 3f 40 00       mov    0x403f60,%edx
  401afc:       81 c2 78 56 34 12       add    $0x12345678,%edx
  401b02:       83 15 64 3f 40 00 00    adcl   $0x0,0x403f64
  401b09:       89 15 60 3f 40 00       mov    %edx,0x403f60
  401b0f:       8d 85 1c ff ff ff       lea    -0xe4(%ebp),%eax

This inversion of the order of the low and high 32bits
of the 64bit word causes a difference in traced loads
and stores reported by DRD.
2022-05-27 14:18:18 +02:00
Paul Floyd
1f1abc9ec3 Add check for DRD OMP tests for FreeBSD 2022-05-10 20:08:43 +02:00
Paul Floyd
184e3ba052 Bug 453055 shared_timed_mutex drd test fails with "Lock shared failed" message
Patch submited by Jesus Checa jcheca@redhat.com
2022-04-27 21:13:45 +02:00
Paul Floyd
68ac5ca0ea Fix building on macOS
Adds a feature check for clockid_t

Also fix a typo in a macro affecting pthread_mutex_clocklock on Linux.
2022-04-11 22:32:45 +02:00
Paul Floyd
01048e33df FreeBSD sigreturn arg names again
Also make drd/tests/shared_timed_mutex more robust
Already not great using time delays, but the test seems
to fail intermittently due to spurious wakeups. So instead
of railing straight away, make it "three strikes and you're out".
2021-12-09 22:54:23 +01:00
Paul Floyd
c2607e093c Bug 446139 DRD/Helgrind with std::shared_timed_mutex::try_lock_until and try_lock_shared_until false positives
also
Bug 446138 DRD/Helgrind with std::timed_mutex::try_lock_until false positives
2021-12-02 00:03:27 +01:00
Mark Wielaard
5db4f35edf drd-manual.xml: Fix link to libstdc++ manual GLIBCXX_FORCE_NEW reference. 2021-11-21 15:25:14 +01:00
Bart Van Assche
bf0579a44a drd: Add a test program that interrupts pthread_mutex_lock()
This test fails, probably due to differences between native signal handling
and signal handling in the Valgrind core.
2021-11-20 14:28:05 -08:00
Paul Floyd
9abfed23c0 Bug 445504 Using C++ condition_variable results in bogus "mutex is locked simultaneously by two threads" warning(edit)
Add intercepts for pthread_cond_clockwait to DRD and Helgrind
Also testcase from bugzilla done by Bart, with configure check
2021-11-19 08:34:53 +01:00
Mark Wielaard
95468b34f1 Remove executable bits from source files (drd_main.c, pub_tool_machine.h) 2021-10-15 18:02:25 +02:00
Paul Floyd
22857ddd1d filter_stderr also needs to handle FreeBSD libthr 2021-10-12 19:31:04 +02:00
Mark Wielaard
df838bccab drd/tests: Extract start_thread which can come from libpthread or libc
The drd/tests/tc21_pthonce and drd/tests/annotate_barrier tests
would fail if start_thread came from libc (as it does in glibc 2.34)
instead of from libpthread. Extract start_thread in filter_stderr.in
and update the backtraces in annotate_barrier.stderr.exp and in
tc21_pthonce.stderr.exp

Tested against glibc 2.34, 2.33 and 2.17 on x86_64.
2021-10-12 18:51:23 +02:00
Paul Floyd
2269aeb76c Dnother iteration for getting the right expected line numbers. 2021-10-11 08:16:32 +02:00
Paul Floyd
8c0f72667e Fix the ramaining easily fixable warnings with clang
There's one remaining
memalign2.c:29:9: warning: unused variable 'piece' [-Wunused-variable]
because of a block of #if FreeBSD for memalign that looks unnecessary

Otherwise all that is left is a few like

warning: unknown warning option '-Wno-alloc-size-larger-than'; did you mean '-Wno-frame-larger-than='? [-Wunknown-warning-option]

because there is no standard for compiler arguments.
2021-10-10 21:56:49 +02:00
Paul Floyd
d187106a76 Updating a few expecteds based on valgrind-testresults
I tried to work out what the expecteds should be based on the changes to
the testcase source so there may be a bit more to do.
2021-10-10 12:03:38 +02:00
Paul Floyd
85bbe2853e FreeBSD support, patch 5
drd and helgrind tests
2021-10-07 21:33:45 +02:00
Mark Wielaard
f22758d6da Fix make distcheck by removing references to uncommitted files
Some files for the freebsd port have not yet committed, but were
already referenced in the Makefiles. Remove those references for
now to make distcheck happy.

	* coregrind/Makefile.am (valgrind_SOURCES): Remove
	launcher-freebsd.c
	* drd/tests/Makefile.am (check_PROGRAMS): Remove
	thread_name_freebsd.
	* none/tests/Makefile.am (SUBDIRS): Remove freebsd.
	(DIST_SUBDIRS): Likewise.
	* none/tests/freebsd/filter_stderr: Removed.
2021-10-07 13:43:19 +02:00
Paul Floyd
e2583c02a5 FreeBSD support, patch 2
Files in the root directory
Several Makefile.am files that have dependencies on FreeBSD autoconf
variables. Included a few new filter files to act as placeholders
to create new freebsd subdirectories.

Updated NEWS with the FreeBSD bugzilla items plus a couple of other
items fixed indirectly.
2021-10-07 08:18:47 +02:00
Paul Floyd
7074904a37 FreeBSD support, patch 4
DRD code
Mainly just intercepts, but also a hairy fix for early acces to
pthread_self()
2021-10-06 21:50:49 +02:00
Yi Fan Yu
4c8c4a9c3a drd/tests/swapcontext: Add SIGALRM handler to avoid stacktrace
During testing for oe-core build on QEMU,
SIGALRM can trigger during nanosleep.
This results a different stderr output than expected.

```
==277== Process terminating with default action of signal 14 (SIGALRM)
==277==    at 0x36C74C3943: clock_nanosleep@@GLIBC_2.17 (clock_nanosleep.c:43)
==277==    by 0x36C74C8726: nanosleep (nanosleep.c:25)
```

This stacktrace printing will not occur
if we add a handler that simply exits.

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

Signed-off-by: Yi Fan Yu <yifan.yu@windriver.com>
2021-04-09 15:55:31 -07:00
Bart Van Assche
c9e88f3459 configure, drd: Only build the swapcontext test if swapcontext() is available
Add a configure test for swapcontext() since MUSL does not provide a
swapcontext() implementation. See also
https://bugs.kde.org/show_bug.cgi?id=434775 .
2021-03-22 19:21:15 -07:00
Paul Floyd
c136213d46 Keep on churning.
Without #define _XOPEN_SOURCE macports clang 9.0.1 on OSX 10.7.5 was
giving me

In file included from swapcontext.c:12:
/usr/include/ucontext.h:43:2: error: The deprecated ucontext routines require
      _XOPEN_SOURCE to be defined
 ^
swapcontext.

So I added #define _XOPEN_SOURCE

But that gives, on Solaris 11.3

In file included from /usr/include/limits.h:12:0,
                 from /usr/gcc/4.8/lib/gcc/i386-pc-solaris2.11/4.8.2/include-fixed/limits.h:168,
                 from /usr/gcc/4.8/lib/gcc/i386-pc-solaris2.11/4.8.2/include-fixed/syslimits.h:7,
                 from /usr/gcc/4.8/lib/gcc/i386-pc-solaris2.11/4.8.2/include-fixed/limits.h:34,
                 from swapcontext.c:7:
/usr/include/sys/feature_tests.h:354:2: error: #error "Compiler or options invalid for pre-UNIX 03 X/Open applications  and pre-2001 POSIX applications"
 #error "Compiler or options invalid for pre-UNIX 03 X/Open applications \
  ^

So make the #define _XOPEN_SOURCE conditional on darwin.
2021-03-03 08:53:51 +01:00
Paul Floyd
8fd6de1cfe Fix compilation on OS X 2021-03-02 17:41:47 +01:00
Paul Floyd
e42badd060 Bug 388787 - Support for C++17 new/delete
These over-aligned new and delete operators were added in C++ 17.
2021-03-02 13:32:22 +01:00
Mark Wielaard
9c9b909cbf Make the dwarf3 reader more robust and less chatty when things go wrong
Skip some stuff when seeing an unknown language, be less chatty about
parser issues.

All the issues seem to come from the multi-file, that is the shared
(supplementary or alt) file containing debuginfo shared by all the
gcc/runtime libraries.

There are a couple of issues that this patch works around:

- The multifile contains entries for the 'D' language, which has some
  constructs we don't expect.
- We don't read partial units correctly, which means we often don't know
  the language we are looking at.
- The parser is very chatty about issues it didn't expect (even if they
  are ignored, it will still output something)

It only shows up with --read-var-info=yes which some tests enable, but
which is disabled by default.

Also increate the timeout of drd/tests/pth_cleanup_handler.c because
DWARF reading is so slow.

https://bugs.kde.org/show_bug.cgi?id=433500
2021-02-26 02:34:32 +01:00
Paul Floyd
871f786535 Hopefully the last small changes for the drd swapcontext test 2021-02-24 11:01:13 +01:00
Bart Van Assche
caf05d5ca9 drd/tests/swapcontext: Improve the portability of this test further
- Remove the VALGRIND_STACK_REGISTER() invocation for the initial thread
  stack since it is superfluous. Remove the pthread_attr_getstack() call
  that became superfluous by this change.
- Change SIGINT into SIGALRM for FreeBSD since pthread_kill(..., SIGINT)
  causes the application to return a SIGINT status.
- Reduce the stack size of the threads created by this test.
2021-02-23 11:49:14 -08:00
Mark Wielaard
610973c79d swapcontext.vgtest fails with glibc-debuginfo installed
With debuginfo installed the backtace contains the swapcontext.S
source file. Filter that out, like the clone.S source file is in
drd/tests/filter_stderr.
2021-02-21 15:18:58 +01:00
Bart Van Assche
719d23b7a9 drd/tests/swapcontext: Improve portability 2021-02-20 14:51:15 -08:00
Mark Wielaard
7aac53c6d0 Fix valgrind.h include in drd/tests/swapcontext.c
In tree tests should include "valgrind.h" not <valgrind/valgrind.h>
the later might pick up the system installed valgrind.h and doesn't
work when srcdir != builddir.
2021-02-20 20:05:42 +01:00
Bart Van Assche
0062f2b519 drd/tests/swapcontext: Add a swapcontext() test 2021-02-20 08:44:50 -08:00
Bart Van Assche
fd5a12afcb drd: Process stack registration client requests
Reset stack information if the client registers a new stack
2021-02-20 08:44:50 -08:00
Paul Floyd
383e463e1a Initial change for Bug 429952 didn't work well with older GCC. Use the __clang__ macro instead. 2020-12-09 08:55:55 +01:00
Paul Floyd
af0a901b4e Bug 429952 - Errors when building regtest with clang 2020-12-08 14:59:49 +01:00
Paul Floyd
d2d54dbcc7 Bug 428909 - helgrind: need to intercept duplicate libc definitions for Fedora 33 2020-12-04 10:11:55 +01:00
Bart Van Assche
3073d03e4b drd: Unbreak the musl build
See also https://bugs.kde.org/show_bug.cgi?id=428035.

Reported-by: Stacy <stacy.gaikovaia@windriver.com>
Fixes: 15330adf7c24 ("drd: Port to Fedora 33")
2020-10-21 17:33:30 -07:00
Bart Van Assche
01f01fd910 drd: Update copyright notices 2020-10-10 18:11:31 -07:00
Bart Van Assche
15330adf7c drd: Port to Fedora 33
Apparently on Fedora 33 the POSIX thread functions exist in both libc and
libpthread. Hence this patch that intercepts the pthread functions in
libc. See also https://bugs.kde.org/show_bug.cgi?id=426144 .
2020-09-19 08:50:37 -07:00
Mark Wielaard
9f4cd0c47c drd/tests/tsan_unittest.cpp: Fix array CHECK
Use == equality, not = assignment, for CHECK.
2020-06-08 13:36:29 +02:00
Mark Wielaard
555ddc4753 Use DTD DocBook XML V4.5 everywhere.
This makes the rule for xmllint easier since it doesn't need to
override the DTD to validate against. It also helps with other tools
tryinf to process the docbookx xml files.
2020-05-14 15:12:02 +02:00
Mark Wielaard
022f8daf02 drd-manual.xml: C++ isn't a valid id syntax, use CXX instead. 2020-05-14 00:38:27 +02:00
Bart Van Assche
52d02fe239 drd/drd_pthread_intercepts: Add a workaround for what is probably a compiler bug
Without this patch drd produces incorrect output for some test cases. It
seems like without this patch an incorrect value is passed as the sixth
argument of VALGRIND_DO_CLIENT_REQUEST_STMT(VG_USERREQ__POST_SEM_OPEN, ...):

$ ./vg-in-place --tool=drd --traemaphore=yes drd/tests/sem_open -m -p
drd, a thread error detector
Copyright (C) 2006-2017, and GNU GPL'd, by Bart Van Assche.
Using Valgrind-3.16.0.GIT and LibVEX; rerun with -h for copyright info
Command: drd/tests/sem_open -m -p

[1] sem_open      0x4029000 name /drd-sem-open-test-27725 oflag 0xc0 mode 0600 value 0
s_d1 = 1 (should be 1)
[2] sem_wait      0x4029000 value 0 -> 4294967295
Thread 2:
Invalid semaphore: semaphore 0x4029000
   at 0x484ADC7: sem_wait_intercept (drd_pthread_intercepts.c:1436)
   by 0x484ADC7: sem_wait@* (drd_pthread_intercepts.c:1441)
   by 0x4014A9: thread_func (sem_open.c:114)
   by 0x483FEA6: vgDrd_thread_wrapper (drd_pthread_intercepts.c:449)
   by 0x4886EF9: start_thread (in /lib64/libpthread-2.31.so)
   by 0x499F3BE: clone (in /lib64/libc-2.31.so)
semaphore 0x4029000 was first observed at:
   at 0x484A395: sem_open_intercept (drd_pthread_intercepts.c:1403)
   by 0x484A395: sem_open (drd_pthread_intercepts.c:1409)
   by 0x4012CE: main (sem_open.c:63)

[2] sem_post      0x4029000 value 4294967295 -> 0
[1] sem_wait      0x4029000 value 0 -> 4294967295
Thread 1:
Invalid semaphore: semaphore 0x4029000
   at 0x484ADC7: sem_wait_intercept (drd_pthread_intercepts.c:1436)
   by 0x484ADC7: sem_wait@* (drd_pthread_intercepts.c:1441)
   by 0x40139D: main (sem_open.c:90)
semaphore 0x4029000 was first observed at:
   at 0x484A395: sem_open_intercept (drd_pthread_intercepts.c:1403)
   by 0x484A395: sem_open (drd_pthread_intercepts.c:1409)
   by 0x4012CE: main (sem_open.c:63)

Conflicting load by thread 1 at 0x00404108 size 8
   at 0x40139E: main (sem_open.c:91)
Allocation context: BSS section of /home/bart/software/valgrind.git/drd/tests/sem_open
Other segment start (thread 2)
   (thread finished, call stack no longer available)
Other segment end (thread 2)
   (thread finished, call stack no longer available)

Conflicting store by thread 1 at 0x00404108 size 8
   at 0x4013B2: main (sem_open.c:91)
Allocation context: BSS section of /home/bart/software/valgrind.git/drd/tests/sem_open
Other segment start (thread 2)
   (thread finished, call stack no longer available)
Other segment end (thread 2)
   (thread finished, call stack no longer available)

[1] sem_post      0x4029000 value 4294967295 -> 0
s_d2 = 2 (should be 2)
s_d3 = 5 (should be 5)
[1] sem_close     0x4029000 value 0

For lists of detected and suppressed errors, rerun with: -s
ERROR SUMMARY: 4 errors from 4 contexts (suppressed: 18 from 8)
2020-04-12 16:34:25 -07:00
Bart Van Assche
20dc727851 drd/tests/trylock, FreeBSD: Fix a hang
The test code in drd/tests/trylock.c attempts to write-lock a POSIX rwlock
twice. The code expects the second attempt to return an error, but POSIX
doesn't require that behaviour, and FreeBSD's implementation deadlocks
instead.

See also https://bugs.kde.org/show_bug.cgi?id=403212

Reported-by: Mark Johnston <markj@FreeBSD.org>
2020-04-12 15:20:13 -07:00
Khem Raj
92fcf75d6d drd/tests/pth_detached3: Make pthread_detach() call portable across platforms
pthread_t is opaque type therefore we can not apply simple arithmetic to
variables of pthread_t type this test needs to pass a invalid pthread_t
handle, typcasting to uintptr_t works too and is portable across glibc and
musl

Fixes
| pth_detached3.c:24:25: error: invalid use of undefined type 'struct __pthread'
|    24 |   pthread_detach(thread + 8);
|       |                         ^

[ bvanassche: reformatted patch description and fixed up line numbers ]
2020-01-28 20:38:04 -08:00
Julian Seward
9dcd3ab1f6 Fix some spelling errors found by Lintian. Patch from Alessandro Ghedini <ghedo@debian.org>. 2020-01-23 10:53:36 +01:00
Bart Van Assche
d6efbcb0b5 drd/tests/std_mutex: Add a unit test for std::mutex 2020-01-15 20:01:40 -08:00