hot-fix: Fix race in rwlock

Resetting the owner should be before the lock is unlocked, otherwise a waiter might lock and set a new owner before its reset.
This commit is contained in:
TheTurtle 2024-12-12 03:33:49 +02:00 committed by GitHub
parent 714605c6a7
commit 7f4265834a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -177,13 +177,13 @@ int PS4_SYSV_ABI posix_pthread_rwlock_unlock(PthreadRwlockT* rwlock) {
} }
if (prwlock->owner == curthread) { if (prwlock->owner == curthread) {
prwlock->lock.unlock();
prwlock->owner = nullptr; prwlock->owner = nullptr;
prwlock->lock.unlock();
} else { } else {
prwlock->lock.unlock_shared();
if (prwlock->owner == nullptr) { if (prwlock->owner == nullptr) {
curthread->rdlock_count--; curthread->rdlock_count--;
} }
prwlock->lock.unlock_shared();
} }
return 0; return 0;