svn commit: r296947 - head/share/man/man9

John Baldwin jhb at freebsd.org
Wed Mar 16 22:12:23 UTC 2016


On Wednesday, March 16, 2016 06:39:48 PM Bryan Drewery wrote:
> Author: bdrewery
> Date: Wed Mar 16 18:39:48 2016
> New Revision: 296947
> URL: https://svnweb.freebsd.org/changeset/base/296947
> 
> Log:
>   Remove incorrect BUGS entry about asserting lock not held.
>   
>   For non-WITNESS< assertion support for SA_UNLOCKED was added in r125421 and
>   made to panic in r126316.
>   
>   MFC after:	1 week

Eh, how can this possibly work?

That is, suppose I have this code:

	sx_slock(&foo);
	sx_assert(&foo, SA_UNLOCKED);

How does that safely work without WITNESS?  It needs to not panic in the case
that some other thread does sx_slock(&foo).  In fact, the comment (modulo the
spelling nit) says this explicitly:

        case SA_UNLOCKED:
#ifdef WITNESS
                witness_assert(&sx->lock_object, what, file, line);
#else
                /*
                 * If we hold an exclusve lock fail.  We can't
                 * reliably check to see if we hold a shared lock or
                 * not.
                 */
                if (sx_xholder(sx) == curthread)
                        panic("Lock %s exclusively locked @ %s:%d\n",
                            sx->lock_object.lo_name, file, line);
#endif
                break;

You could perhaps reword the bug to say that SA_UNLOCKED will panic if the lock
is exclusively locked in the non-WITNESS case, but will fail to panic if the
thread holds a shared lock.

The wording in rwlock(9) is better than sx(9) though it should mention that
RA_UNLOCKED can detect a write lock.  That wording could then be used in sx(9).

-- 
John Baldwin


More information about the svn-src-head mailing list