From 933a98f8fac2835a59f0777dc4672f33c713becb Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Thu, 22 Aug 2019 09:22:30 +0200 Subject: [PATCH] Kernel: Make Lock::lock() assert early that we're not in the scheduler The scheduler is not allowed to take locks, so if that's happening, we want to make that clear instead of crashing with the more general "Interrupts disabled while trying to take Lock" error. --- Kernel/Lock.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Kernel/Lock.cpp b/Kernel/Lock.cpp index bd7e35d7194..c19f479f640 100644 --- a/Kernel/Lock.cpp +++ b/Kernel/Lock.cpp @@ -2,12 +2,12 @@ void Lock::lock() { + ASSERT(!Scheduler::is_active()); if (!are_interrupts_enabled()) { kprintf("Interrupts disabled when trying to take Lock{%s}\n", m_name); dump_backtrace(); hang(); } - ASSERT(!Scheduler::is_active()); for (;;) { if (CAS(&m_lock, 1, 0) == 0) { if (!m_holder || m_holder == current) {