From 70b84c8aa22584e626c2e7a74ba5b2b55d428f3e Mon Sep 17 00:00:00 2001 From: Augustin Cavalier Date: Tue, 10 Sep 2024 23:02:18 -0400 Subject: [PATCH] kernel/locks: Assert that rwlocks have no readers on destruction. Previously only whether there were active waiters was checked. --- src/system/kernel/locks/lock.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/system/kernel/locks/lock.cpp b/src/system/kernel/locks/lock.cpp index 5a910d2b98..bb2fe98df0 100644 --- a/src/system/kernel/locks/lock.cpp +++ b/src/system/kernel/locks/lock.cpp @@ -421,9 +421,9 @@ rw_lock_destroy(rw_lock* lock) InterruptsSpinLocker locker(lock->lock); #if KDEBUG - if (lock->waiters != NULL && thread_get_current_thread_id() - != lock->holder) { - panic("rw_lock_destroy(): there are blocking threads, but the caller " + if ((atomic_get(&lock->count) != 0 || lock->waiters != NULL) + && thread_get_current_thread_id() != lock->holder) { + panic("rw_lock_destroy(): lock is in use and the caller " "doesn't hold the write lock (%p)", lock); locker.Unlock();