I think we should also assert that no waiter remains when a conditional variable is destroyed (which also suggests that the memory may be freed shortly). Otherwise we would either have modify after free or lost wakeups.
Cheers, -- Xin LI <[email protected]> https://www.delphij.net/ FreeBSD - The Power to Serve! Live free or die
Index: sys/kern/kern_condvar.c
===================================================================
--- sys/kern/kern_condvar.c (revision 283099)
+++ sys/kern/kern_condvar.c (working copy)
@@ -77,6 +77,7 @@ cv_destroy(struct cv *cvp)
#ifdef INVARIANTS
struct sleepqueue *sq;
+ KASSERT(cvp->cv_waiters == 0, ("%s: dangling waiters", __func__));
sleepq_lock(cvp);
sq = sleepq_lookup(cvp);
sleepq_release(cvp);
signature.asc
Description: OpenPGP digital signature
