From: Bart Van Assche Date: Sun, 12 Apr 2020 21:28:57 +0000 (-0700) Subject: drd/tests/trylock, FreeBSD: Fix a hang X-Git-Tag: VALGRIND_3_16_0~59 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=20dc7278512cbe530dc722ed18232915bfe4ab8b;p=thirdparty%2Fvalgrind.git 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 --- diff --git a/NEWS b/NEWS index 7c497c15fa..5d8792b5c4 100644 --- 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 diff --git a/drd/tests/trylock.c b/drd/tests/trylock.c index 839c11b969..1aca703408 100644 --- a/drd/tests/trylock.c +++ b/drd/tests/trylock.c @@ -11,6 +11,7 @@ #define _GNU_SOURCE 1 #include "../../config.h" +#include #include #include #include @@ -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); diff --git a/drd/tests/trylock.stderr.exp b/drd/tests/trylock.stderr.exp index 2c5d765f11..6821c13127 100644 --- a/drd/tests/trylock.stderr.exp +++ b/drd/tests/trylock.stderr.exp @@ -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:?)