mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 18:57:34 +00:00
Kernel: Fix LOCK_DEBUG feature to work again
- UBSAN detected cases where we were calling thread->holding_lock(..) but current_thread was nullptr. - Fix Lock::force_unlock_if_locked to not pass the correct ref delta to holding_lock(..).
This commit is contained in:
parent
35c0a6c54d
commit
7481789eac
1 changed files with 7 additions and 3 deletions
|
@ -53,7 +53,9 @@ void Lock::lock(Mode mode)
|
||||||
VERIFY(m_times_locked == 0);
|
VERIFY(m_times_locked == 0);
|
||||||
m_times_locked++;
|
m_times_locked++;
|
||||||
#if LOCK_DEBUG
|
#if LOCK_DEBUG
|
||||||
|
if (current_thread) {
|
||||||
current_thread->holding_lock(*this, 1, file, line);
|
current_thread->holding_lock(*this, 1, file, line);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
m_queue.should_block(true);
|
m_queue.should_block(true);
|
||||||
m_lock.store(false, AK::memory_order_release);
|
m_lock.store(false, AK::memory_order_release);
|
||||||
|
@ -165,7 +167,9 @@ void Lock::unlock()
|
||||||
}
|
}
|
||||||
|
|
||||||
#if LOCK_DEBUG
|
#if LOCK_DEBUG
|
||||||
|
if (current_thread) {
|
||||||
current_thread->holding_lock(*this, -1);
|
current_thread->holding_lock(*this, -1);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
m_lock.store(false, AK::memory_order_release);
|
m_lock.store(false, AK::memory_order_release);
|
||||||
|
@ -201,7 +205,7 @@ auto Lock::force_unlock_if_locked(u32& lock_count_to_restore) -> Mode
|
||||||
|
|
||||||
dbgln_if(LOCK_RESTORE_DEBUG, "Lock::force_unlock_if_locked @ {}: unlocking exclusive with lock count: {}", this, m_times_locked);
|
dbgln_if(LOCK_RESTORE_DEBUG, "Lock::force_unlock_if_locked @ {}: unlocking exclusive with lock count: {}", this, m_times_locked);
|
||||||
#if LOCK_DEBUG
|
#if LOCK_DEBUG
|
||||||
m_holder->holding_lock(*this, -(int)lock_count_to_restore);
|
m_holder->holding_lock(*this, -(int)m_times_locked);
|
||||||
#endif
|
#endif
|
||||||
m_holder = nullptr;
|
m_holder = nullptr;
|
||||||
VERIFY(m_times_locked > 0);
|
VERIFY(m_times_locked > 0);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue