misc/95103: panic after mtx_destroy() on locked spinlock
>Synopsis: panic after mtx_destroy() on locked spinlock
>Arrival-Date: Thu Mar 30 11:10:14 GMT 2006
>Originator: Tomas Olsson
Stacken Computer Club
FreeBSD lab04.lab.it.su.se 5.5-BETA4 FreeBSD 5.5-BETA4 #0: Mon Mar 13 23:12:57 UTC 2006 [hidden email]:/usr/obj/usr/src/sys/GENERIC i386
MUTEX(9) man page, under mtx_destroy() says:
It is permissible to have a single hold count on a mutex when it is destroyed.
This does not seem to be the case when the mutex is a MTX_SPIN lock. I get a panic very soon after I call mtx_destroy() during kld unload unless the lock is released. Page fault in user mode seems to be a common panic "cause" for this.
With a MTX_DEF it appears to work according to docs.
struct mtx lock;
mtx_init(&lock, "foo", NULL, MTX_SPIN);
(tried during kld unload)