Skip to content

Commit 1c45ac5

Browse files
Bananymousspholz
authored andcommitted
LibC: Don't allow pthread_spin_lock() to steal a lock
1 parent 3ecadc4 commit 1c45ac5

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

Userland/Libraries/LibC/pthread.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -636,6 +636,8 @@ int pthread_spin_lock(pthread_spinlock_t* lock)
636636

637637
if (current == desired)
638638
return EDEADLK;
639+
if (current != spinlock_unlock_sentinel)
640+
continue;
639641

640642
if (AK::atomic_compare_exchange_strong(&lock->m_lock, current, desired, AK::MemoryOrder::memory_order_acquire))
641643
break;

0 commit comments

Comments
 (0)