From 3eb4224bf6d658b0e95412d348e6656fefe92f65 Mon Sep 17 00:00:00 2001 From: Pawel Dziepak Date: Wed, 20 Nov 2013 17:53:39 +0100 Subject: [PATCH] kernel: Make sure mutex::holder is set to a valid value --- src/system/kernel/locks/lock.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/system/kernel/locks/lock.cpp b/src/system/kernel/locks/lock.cpp index 6b3ac5ff70..3240549fbd 100644 --- a/src/system/kernel/locks/lock.cpp +++ b/src/system/kernel/locks/lock.cpp @@ -775,6 +775,9 @@ _mutex_unlock(mutex* lock) lock->waiters = waiter->next; if (lock->waiters != NULL) lock->waiters->last = waiter->last; +#if KDEBUG + thread_id unblockedThread = waiter->thread->id; +#endif // unblock thread thread_unblock(waiter->thread, B_OK); @@ -784,7 +787,7 @@ _mutex_unlock(mutex* lock) // actually reflects the current situation, setting it to -1 would // cause a race condition, since another locker could think the lock // is not held by anyone. - lock->holder = waiter->thread->id; + lock->holder = unblockedThread; #endif } else { // We've acquired the spinlock before the locker that is going to wait.