]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
drd/tests/trylock, FreeBSD: Fix a hang
authorBart Van Assche <bvanassche@acm.org>
Sun, 12 Apr 2020 21:28:57 +0000 (14:28 -0700)
committerBart Van Assche <bvanassche@acm.org>
Sun, 12 Apr 2020 22:20:13 +0000 (15:20 -0700)
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>
NEWS
drd/tests/trylock.c
drd/tests/trylock.stderr.exp

diff --git a/NEWS b/NEWS
index 7c497c15fae38e426730cccf17922a3c863b601b..5d8792b5c42ada23a832821b9c90e20a1810450c 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -83,6 +83,7 @@ where XXXXXX is the bug number as listed below.
 385386  Assertion failed "szB >= CACHE_ENTRY_SIZE" at m_debuginfo/image.c:517
 400593  In Coregrind, use statx for some internal syscalls if [f]stat[64] fail
 400872  Add nanoMIPS support to Valgrind
+403212  drd/tests/trylock hangs on FreeBSD
 404406  s390x: z14 miscellaneous instructions not implemented
 405201  Incorrect size of struct vki_siginfo on 64-bit Linux architectures
 406561  mcinfcallWSRU gdbserver_test fails on ppc64
index 839c11b969618edd017b95df80983755131e7176..1aca703408244845cd75ecfbf2295d96d1ab1307 100644 (file)
@@ -11,6 +11,7 @@
 #define _GNU_SOURCE 1
 
 #include "../../config.h"
+#include <errno.h>
 #include <stdio.h>
 #include <assert.h>
 #include <pthread.h>
@@ -56,7 +57,7 @@ int main(int argc, char** argv)
 #endif
   fprintf(stderr, "Attempt to lock for writing recursively (not allowed).\n");
   r = pthread_rwlock_wrlock(&rwlock); assert(r == 0);
-  r = pthread_rwlock_wrlock(&rwlock); assert(r != 0);
+  r = pthread_rwlock_trywrlock(&rwlock); assert(r == EBUSY);
   r = pthread_rwlock_unlock(&rwlock); assert(r == 0);
   r = pthread_rwlock_destroy(&rwlock); assert(r == 0);
 
index 2c5d765f1182d9135026f1a13f696bd4d8f32c8e..6821c131273dac3175953958f3874b547639b44d 100644 (file)
@@ -7,7 +7,7 @@ Locking rwlock via pthread_rwlock_tryrdlock().
 Locking rwlock via pthread_rwlock_timedrdlock().
 Attempt to lock for writing recursively (not allowed).
 Recursive writer locking not allowed: rwlock 0x.........
-   at 0x........: pthread_rwlock_wrlock (drd_pthread_intercepts.c:?)
+   at 0x........: pthread_rwlock_trywrlock (drd_pthread_intercepts.c:?)
    by 0x........: main (trylock.c:?)
 rwlock 0x........ was first observed at:
    at 0x........: pthread_rwlock_init (drd_pthread_intercepts.c:?)