982 Commits

Author SHA1 Message Date
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
Bart Van Assche
bb8c57ec64 drd: Fix 'conflicting load' error on std::mutex::lock() 2020-01-15 20:00:06 -08:00
Bart Van Assche
2d8192a2a7 drd/tests/Makefile.am: Fix indentation 2020-01-15 19:55:47 -08:00
Petar Jovanovic
24c1f4ada3 mips: Add nanoMIPS support to Valgrind 3/4
Necessary changes to support nanoMIPS on Linux.

Part 3/4 - Coregrind and tools changes

Patch by Aleksandar Rikalo, Dimitrije Nikolic, Tamara Vlahovic,
Nikola Milutinovic and Aleksandra Karadzic.

Related KDE issue: #400872.
2019-12-31 09:44:42 +00:00
Mark Wielaard
461cc5c003 Cleanup GPL header address notices by using http://www.gnu.org/licenses/
Sync VEX/LICENSE.GPL with top-level COPYING file. We used 3 different
addresses for writing to the FSF to receive a copy of the GPL. Replace
all different variants with an URL <http://www.gnu.org/licenses/>.

The following files might still have some slightly different (L)GPL
copyright notice because they were derived from other programs:

- files under coregrind/m_demangle which come from libiberty:
  cplus-dem.c, d-demangle.c, demangle.h, rust-demangle.c,
  safe-ctype.c and safe-ctype.h
- coregrind/m_demangle/dyn-string.[hc] derived from GCC.
- coregrind/m_demangle/ansidecl.h derived from glibc.
- VEX files for FMA detived from glibc:
  host_generic_maddf.h and host_generic_maddf.c
- files under coregrin/m_debuginfo derived from LZO:
  lzoconf.h, lzodefs.h, minilzo-inl.c and minilzo.h
- files under coregrind/m_gdbserver detived from GDB:
  gdb/signals.h, inferiors.c, regcache.c, regcache.h,
  regdef.h, remote-utils.c, server.c, server.h, signals.c,
  target.c, target.h and utils.c

Plus the following test files:

- none/tests/ppc32/testVMX.c derived from testVMX.
- ppc tests derived from QEMU: jm-insns.c, ppc64_helpers.h
  and test_isa_3_0.c
- tests derived from bzip2 (with embedded GPL text in code):
  hackedbz2.c, origin5-bz2.c, varinfo6.c
- tests detived from glibc: str_tester.c, pth_atfork1.c
- test detived from GCC libgomp: tc17_sembar.c
- performance tests derived from bzip2 or tinycc (with embedded GPL
  text in code): bz2.c, test_input_for_tinycc.c and tinycc.c
2019-05-26 20:07:51 +02:00
Bart Van Assche
7ebdd45026 drd/tests/tsan_unittest: Avoid that this test reads from uninitialized memory
Reported-by: Philippe Waroquiers <philippe.waroquiers@skynet.be>
2019-04-17 17:42:22 -07:00
Bart Van Assche
30b3264e60 drd: Fix an integer overflow in the stack margin calculation 2019-03-21 20:09:16 -07:00
Philippe Waroquiers
cfae4f70a6 Modify .exp files following the new error message.
Change:
For counts of detected and suppressed errors, rerun with: -v
to
For lists of detected and suppressed errors, rerun with: -s
2018-12-28 19:33:00 +01:00
Philippe Waroquiers
d680f66465 Implement option --show-error-list=no|yes -s
This option allows to list the detected errors and show the used
suppressions without increasing the verbosity.
Increasing the verbosity also activates a lot of messages that
are often not very useful for the user.
So, this option allows to see the list of errors and used suppressions
independently of the verbosity.

Note if a high verbosity is selected, the behaviour is unchanged.
In other words, when specifying -v, the list of detected errors
and the used suppressions are still shown, even if
--show-error-list=yes and -s are not used.
2018-12-28 19:32:53 +01:00
Philippe Waroquiers
36bf7c0647 Factorize producing the 'For counts of detected and suppressed errors' msg
Each tool producing errors had identical code to produce this msg.
Factorize the production of the message in m_main.c

This prepares the work to have a specific option to show the list
of detected errors and the count of suppressed errors.

This has a (small) visible effect on the output of memcheck:
Instead of producing
  For counts of detected and suppressed errors, rerun with: -v
  Use --track-origins=yes to see where uninitialised values come from
memcheck now produces:
  Use --track-origins=yes to see where uninitialised values come from
  For counts of detected and suppressed errors, rerun with: -v

i.e. the track origin and counts of errors msg are inverted.
2018-12-23 23:45:33 +01:00
Bart Van Assche
5b4029b8cc drd/tests/tsan_thread_wrappers_pthread.h: Fix MyThread::ThreadBody()
See also https://bugs.kde.org/show_bug.cgi?id=402341.
2018-12-19 18:13:31 -08:00