Hi, The following sequence of commands fails on line 4 with an assertion that the lock is not currently held: 1: rw_wlock(&rw); 2: if ( rw_try_wlock(&rw) ) 3: rw_wunlock(&rw); 4: rw_wunlock(&rw); This is because after line 3 is executed the rw lock is no longer held. I tracked this bug down to _rw_try_wlock which correctly increments rw_recurse, but does not set the RW_LOCK_RECURSED bit. Without this bit the third line unlocks the lock and leaves it in a unlocked state (when it should still be locked). Adding a line to set this bit makes _rw_try_wlock match the code in _rw_wlock_hard. I have attached a one line patch which fixes this problem on my 7.2 system, and looking over the CURRENT source it should also apply cleanly (but I have not tested it on CURRENT). I have also attached another (slightly longer) patch which fixes the problem as well as adding an a extra assert. It is up to the FreeBSD developer to decide which patch they prefer. thanks Andrew
This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:39:54 UTC