]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
BugĀ 400793 - pthread_rwlock_timedwrlock false positive
authorPaul Floyd <pjfloyd@wanadoo.fr>
Thu, 29 Dec 2022 21:00:53 +0000 (22:00 +0100)
committerPaul Floyd <pjfloyd@wanadoo.fr>
Thu, 29 Dec 2022 21:02:47 +0000 (22:02 +0100)
Add Helgrind intercepts for pthread_rwlock_timedwrlock
(and pthread_rwlock_timedrdlock)

Reuse the DRD trylock test

NEWS
helgrind/hg_intercepts.c
helgrind/tests/Makefile.am
helgrind/tests/trylock.stderr.exp [new file with mode: 0644]
helgrind/tests/trylock.vgtest [new file with mode: 0644]

diff --git a/NEWS b/NEWS
index 071f654b50bc78b9a8394d3ce2e13d048d655568..16ae313dfc8b92ae37775587557999c0eb439257 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -32,6 +32,7 @@ are not entered into bugzilla tend to get forgotten about or ignored.
 170510  Don't warn about ioctl of size 0 without direction hint
 351857  confusing error message about valid command line option
 392331  Spurious lock not held error from inside pthread_cond_timedwait
+400793  pthread_rwlock_timedwrlock false positive
 444110  priv/guest_ppc_toIR.c:36198:31: warning: duplicated 'if' condition.
 444488  Use glibc.pthread.stack_cache_size tunable
 444568  drd/tests/pth_barrier_thr_cr fails on Fedora 38
index 0d29cb3bfa2c588298fdc86b24ffe89702f20ae8..5a83996e365adf9fce0ebb60ab46913edbc798d0 100644 (file)
@@ -2222,9 +2222,6 @@ static int pthread_spin_trylock_WRK(pthread_spinlock_t *lock)
               pthread_rwlock_unlock
               pthread_rwlock_tryrdlock
               pthread_rwlock_trywrlock
-
-   Unhandled: pthread_rwlock_timedrdlock
-              pthread_rwlock_timedwrlock
 */
 
 //-----------------------------------------------------------
@@ -2676,7 +2673,7 @@ static int pthread_rwlock_tryrdlock_WRK(pthread_rwlock_t* rwlock)
 
 
 //-----------------------------------------------------------
-// glibc:   Unhandled
+// glibc:   pthread_rwlock_timedrdlock
 // darwin:  Unhandled
 // Solaris: pthread_rwlock_timedrdlock
 // Solaris: pthread_rwlock_reltimedrdlock_np
@@ -2712,6 +2709,11 @@ static int pthread_rwlock_timedrdlock_WRK(pthread_rwlock_t *rwlock,
    return ret;
 }
 #if defined(VGO_linux)
+PTH_FUNC(int, pthreadZurwlockZutimedrdlock, // pthread_rwlock_timedrdlock
+              pthread_rwlock_t *rwlock,
+              const struct timespec *timeout) {
+   return pthread_rwlock_timedrdlock_WRK(rwlock, timeout);
+}
 #elif defined(VGO_darwin)
 #elif defined(VGO_freebsd)
 PTH_FUNC(int, pthreadZurwlockZutimedrdlock, // pthread_rwlock_timedrdlock
@@ -2779,8 +2781,7 @@ PTH_FUNC(int, pthreadZurwlockZuclockrdlock, // pthread_rwlock_clockrdlock
 
 
 //-----------------------------------------------------------
-// glibc:   Unhandled
-// darwin:  Unhandled
+// glibc:   pthread_rwlock_timedwrlock
 // Solaris: pthread_rwlock_timedwrlock
 // Solaris: pthread_rwlock_reltimedwrlock_np
 // FreeBSD: pthread_rwlock_timedwrlock
@@ -2815,6 +2816,11 @@ static int pthread_rwlock_timedwrlock_WRK(pthread_rwlock_t *rwlock,
    return ret;
 }
 #if defined(VGO_linux)
+PTH_FUNC(int, pthreadZurwlockZutimedwrlock, // pthread_rwlock_timedwrlock
+              pthread_rwlock_t *rwlock,
+              const struct timespec *timeout) {
+   return pthread_rwlock_timedwrlock_WRK(rwlock, timeout);
+}
 #elif defined(VGO_darwin)
 #elif defined(VGO_freebsd)
 PTH_FUNC(int, pthreadZurwlockZutimedwrlock, // pthread_rwlock_timedwrlock
index 28f4c61912fbe818128b5e9b4a22029676694d30..2157f7cd381c9ebbb9bf59ddfb3c08856d31e260 100755 (executable)
@@ -134,7 +134,8 @@ EXTRA_DIST = \
        tc24_nonzero_sem.vgtest tc24_nonzero_sem.stdout.exp \
                tc24_nonzero_sem.stderr.exp \
        tls_threads.vgtest tls_threads.stdout.exp \
-               tls_threads.stderr.exp
+               tls_threads.stderr.exp \
+       trylock.vgtest trylock.stderr.exp
 
 # Wrapper headers used by some check programs.
 noinst_HEADERS = safe-pthread.h safe-semaphore.h
diff --git a/helgrind/tests/trylock.stderr.exp b/helgrind/tests/trylock.stderr.exp
new file mode 100644 (file)
index 0000000..e3aea4b
--- /dev/null
@@ -0,0 +1,13 @@
+
+Locking rwlock via pthread_rwlock_wrlock().
+Locking rwlock via pthread_rwlock_trywrlock().
+Locking rwlock via pthread_rwlock_timedwrlock().
+Locking rwlock via pthread_rwlock_rdlock().
+Locking rwlock via pthread_rwlock_tryrdlock().
+Locking rwlock via pthread_rwlock_timedrdlock().
+Attempt to lock for writing recursively (not allowed).
+Locking mutex via pthread_mutex_trylock().
+Locking mutex via pthread_mutex_lock().
+Locking mutex via pthread_mutex_timedlock().
+
+ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
diff --git a/helgrind/tests/trylock.vgtest b/helgrind/tests/trylock.vgtest
new file mode 100644 (file)
index 0000000..1d4f16d
--- /dev/null
@@ -0,0 +1 @@
+prog: ../../drd/tests/trylock