LibC: Fix race condition in pthread_mutex_unlock()
This ensures the store to mutex->lock doesn't get re-ordered before the store to mutex->owner which could otherwise result in a locked owner-less mutex if another thread tries to acquire the lock at the same time.
This commit is contained in:
parent
5ca1d4289b
commit
90f4c9e44c
Notes:
sideshowbarker
2024-07-18 17:00:13 +09:00
Author: https://github.com/gunnarbeutner Commit: https://github.com/SerenityOS/serenity/commit/90f4c9e44c1 Pull-request: https://github.com/SerenityOS/serenity/pull/7685
1 changed files with 1 additions and 1 deletions
|
@ -119,7 +119,7 @@ int __pthread_mutex_unlock(pthread_mutex_t* mutex)
|
|||
return 0;
|
||||
}
|
||||
mutex->owner = 0;
|
||||
mutex->lock = 0;
|
||||
AK::atomic_store(&mutex->lock, 0u, AK::memory_order_release);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue