Bug 403212 - trylock test hangs on FreeBSD
Summary: trylock test hangs on FreeBSD
Status: RESOLVED FIXED
Alias: None
Product: valgrind
Classification: Developer tools
Component: drd (show other bugs)
Version: 3.13.0
Platform: Other FreeBSD
: NOR normal
Target Milestone: ---
Assignee: Paul Floyd
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-01-14 19:22 UTC by Mark Johnston
Modified: 2020-09-19 15:53 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mark Johnston 2019-01-14 19:22:18 UTC
SUMMARY
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.

Seems to me that for the purpose of the test the second wrlock could become a trywrlock; I verified that in this case, drd on FreeBSD detects the attempted recursion and spits out the error message expected by the test.  I can submit a patch if there are no objections to this approach.

STEPS TO REPRODUCE
1. run drd/tests/trylock on FreeBSD

OBSERVED RESULT
trylock hangs and requires a ctrl-C.

EXPECTED RESULT
The test program should complete.
Comment 1 Bart Van Assche 2019-01-15 02:26:55 UTC
This proposal sounds good to me.
Comment 2 Paul Floyd 2020-04-12 16:34:11 UTC
I've dealt with this in my git repo by putting the double call to wrlock in a conditional compilation block.

https://github.com/paulfloyd/freebsd_valgrind/commit/abf44418d52416a625445c782f79717d7b06cadd
Comment 3 Bart Van Assche 2020-04-12 23:52:22 UTC
A candidate fix has been checked in as commit 20dc7278512c ("drd/tests/trylock, FreeBSD: Fix a hang"). I'm not familiar enough with FreeBSD to review the changes in FreeBSD-specific code.