87 Commits

Author SHA1 Message Date
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
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
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
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
bb8c57ec64 drd: Fix 'conflicting load' error on std::mutex::lock() 2020-01-15 20:00:06 -08: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
e3bc6c7dc7 drd: Add support for calling pthread_create() from inside a shared library - bug #356374
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@16342
2017-05-09 04:45:30 +00:00
Bart Van Assche
06c6edda5e drd: Rename a function
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@16341
2017-05-09 04:44:25 +00:00
Ivo Raisr
38edd50c0e Update copyright end year to 2017 in preparation for 3.13 release.
n-i-bz



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@16333
2017-05-04 15:09:39 +00:00
Bart Van Assche
08dcf38562 drd: Improve thread startup code for non-Linux platforms
Ivo Raisr had reported that thread startup was slow on Solaris.
This patch reduces the thread startup time on Solaris.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15687
2015-09-29 05:39:00 +00:00
Julian Seward
adc2dafee9 Update copyright dates, to include 2015. No functional change.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15577
2015-08-21 11:32:26 +00:00
Julian Seward
ac60633d65 Bug 345248 - add support for Solaris OS in valgrind
Authors of this port:
    Petr Pavlu         setup@dagobah.cz
    Ivo Raisr          ivosh@ivosh.net
    Theo Schlossnagle  theo@omniti.com
            


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15426
2015-07-21 14:44:28 +00:00
Bart Van Assche
6d68e47b19 drd: Ignore ordering introduced by a mutex used in the thread creation wrapper
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14015
2014-06-09 09:19:26 +00:00
Bart Van Assche
0c4bf8499e drd: Add post-rwlock_init and pre-rwlock_destroy client requests (#332265)
From: Ivo Raisr <ivosh@ivosh.net>


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13882
2014-03-19 18:48:01 +00:00
Bart Van Assche
45ab272d19 drd: Fix pthread_rwlock_timed{rd,wr}lock intercepts (#332263)
From: Ivo Raisr <ivosh@ivosh.net>


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13877
2014-03-18 17:53:56 +00:00
Bart Van Assche
74e8b94ed7 drd: Make the code added in r13792 portable
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13794
2014-02-09 09:10:14 +00:00
Bart Van Assche
ea8a9313c2 drd: Avoid that the drd/tests/pth_mutex_reinit test fails with glibc >= 2.18
Apparently with glibc >= 2.18 the value returned by pthread_mutexattr_gettype()
is not the same as the value passed to pthread_mutexattr_settype(). Add a
workaround for this glibc bug.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13792
2014-02-08 10:55:08 +00:00
Bart Van Assche
0dabd6dfd3 drd: Update copyright notice
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13613
2013-10-04 05:55:30 +00:00
Bart Van Assche
7b1a5978c9 drd: Handle pthread_cond_destroy() failure properly
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13198
2012-12-24 10:22:14 +00:00
Petar Jovanovic
40644676b1 Introduce DISABLE_PTHREAD_SPINLOCK_INTERCEPT flag
The flag DISABLE_PTHREAD_SPINLOCK_INTERCEPT is set only for MIPS32, and it is
used in DRD and Helgrind as a workaround for the issue #311690.
In short, pthread_spin_lock implementation has local branches to the start of
the function which interferes with the redirection system in Valgrind that
assumes it has to redirect each call/branch to a particular address.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13190
2012-12-20 18:56:57 +00:00
Florian Krohm
d0aa69c331 Fix more Char/HChar mixups. Closing in...
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13119
2012-11-10 22:29:54 +00:00
Bart Van Assche
7f409138b2 drd: Re-enable the pthread_cancel() intercept now that the CALL_FN_*() ABI
violation has been fixed (r12811).


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12907
2012-08-28 17:57:09 +00:00
Julian Seward
4a3633e266 Update copyright dates to include 2012.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12843
2012-08-05 15:46:46 +00:00
Bart Van Assche
6c92e97588 drd: Avoid that invoking pthread_cancel() from a program analyzed with DRD triggers a crash on Fedora 17
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12800
2012-07-28 14:35:48 +00:00
Bart Van Assche
38b17ca6f4 drd: Avoid that the changes from r12351 trigger a race condition when copying DrdPosixThreadArgs
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12352
2012-01-24 08:30:32 +00:00
Bart Van Assche
a1d8b80b36 drd, semaphore implementation: Only wake the associated futex if at least one thread is waiting
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12351
2012-01-23 17:01:58 +00:00
Bart Van Assche
e76f96cd60 drd: Fix a race condition in the pthread_create() intercept.
Avoid that the futex wake call in DRD_(sema_up)() can get invoked after the semaphore has
already been destroyed. This is most likely the real fix for the bug described in the
commit message of r12332.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12346
2012-01-19 19:52:15 +00:00
Bart Van Assche
12ec9d298a Remove emacs modeline and/or local variables from DRD source files
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12279
2011-12-04 15:54:19 +00:00
Julian Seward
084b7cb10b Fix #284384 (clang 3.1 -Wunused-value warnings in valgrind.h,
memcheck.h) by changing a bunch of VALGRIND_DO_CLIENT_REQUEST_EXPR
into VALGRIND_DO_CLIENT_REQUEST_STMT for cases where the return value
of the former would be unused.  (Bart Van Assche, bart.vanassche@gmail.com)



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12226
2011-10-24 13:21:57 +00:00
Bart Van Assche
83f6f0137f Make drd/drd_pthread_intercepts.c compile again on Linux systems without usable <linux/futex.h> header
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12035
2011-09-17 06:24:49 +00:00
Bart Van Assche
5547d1545e drd: Avoid reporting false positive race reports inside pthread_join().
Note: I haven't analyzed yet since which commit these false positives
started to appear but it's most likely a commit applied after the 3.6
release.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12003
2011-08-24 15:02:21 +00:00
Bart Van Assche
85a61a6c6f drd: Remove a too strict assert() statement
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@11937
2011-07-29 06:30:23 +00:00
Bart Van Assche
08eecbf85d drd: Make drd_pthread_intercepts.c compile again on systems where
FUTEX_PRIVATE_FLAG has not been defined in <linux/futex.h>, e.g. older System z
systems.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@11929
2011-07-28 15:04:08 +00:00
Bart Van Assche
6cf2bc2c34 drd: Delay deletion of memory access information of joined threads in order not
to miss any races caused by these threads.

To do: refine handling of pthread_once() again.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@11926
2011-07-28 09:54:37 +00:00
Bart Van Assche
39b5365cd9 drd/Linux: eliminate busy waiting when starting a thread
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@11920
2011-07-26 19:30:28 +00:00
Julian Seward
eea9337891 The pthread.h on Android has no definition for pthread_rwlock_t, which
makes the associated intercepts in Helgrind and DRD un-compilable.
Add a configure test for it, and use them to guard the aforementioned
intercepts.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@11875
2011-07-11 22:11:58 +00:00
Bart Van Assche
9a36fe677e Get rid of the remaining "set but not used" warnings reported by gcc 4.6 by
swapping the roles of the VALGRIND_DO_CLIENT_REQUEST() and
VALGRIND_DO_CLIENT_REQUEST_EXPR() macros. Also, many __attribute__((unused))
declarations on variables have been eliminated. Closes #269778.

Note: so far this patch has been tested on x86/Linux, amd64/Linux and
ppc64/Linux but not yet on any other supported CPU/OS combination.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@11755
2011-05-15 07:04:03 +00:00
Julian Seward
9c6d0dc9c9 Fix up most but not all warnings generated by gcc-4.6 about
dead assignments ("[-Wunused-but-set-variable]").



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@11673
2011-03-28 16:26:42 +00:00
Bart Van Assche
e53eb1ec0c Updated modeline and copyright statement in DRD source files.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@11642
2011-03-13 12:02:44 +00:00
Bart Van Assche
ad2f458136 DRD: Allocate thread arguments again on the stack.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@11630
2011-03-12 11:01:06 +00:00
Bart Van Assche
8c2ede1182 DRD: Report an error if an invalid argument is passed to pthread_detach(). Do not assume that pthread_detach() returns an error code if its argument is invalid. Should fix #267968.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@11614
2011-03-09 17:53:28 +00:00
Bart Van Assche
942bd034c8 DRD: Fixed a race condition triggered by invoking pthread_detach() with an argument not equal to pthread_self(). Potential fix for #267968.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@11612
2011-03-08 18:34:44 +00:00
Bart Van Assche
3eeee78bed DRD: Removed an obsolete comment.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@11611
2011-03-08 18:32:36 +00:00
Bart Van Assche
218571c462 DRD: Source code cleanup.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@11610
2011-03-08 17:53:45 +00:00
Bart Van Assche
bcd0bc2155 DRD, Darwin: avoid triggering misaligned stack errors. Fixes #267552.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@11591
2011-03-05 14:51:24 +00:00
Bart Van Assche
626fe3372c Reverted r11536 because it didn't have the desired effect - changing the behavior of DRD on Darwin.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@11539
2011-02-13 07:55:36 +00:00
Bart Van Assche
b640febb3e DRD: don't inline pthread intercepts because in combination with the current fragile implementation of the CALL_FN_* macros inlining intercepts can easily trigger stack alignment errors on Darwin.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@11536
2011-02-10 21:03:47 +00:00