From 4e2650af91c381a8090a770d13a21914dfde6d21 Mon Sep 17 00:00:00 2001 From: eladash Date: Thu, 2 May 2019 17:49:23 +0300 Subject: [PATCH] Fix sys_rwlock_wlock timedout event If the rwlock is currently acquired by a writer signaling readers is wrong and will lead to EPERM for wunlock! Only signal blocked readers if the rwlock is currently acquired by readers --- rpcs3/Emu/Cell/lv2/sys_rwlock.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/rpcs3/Emu/Cell/lv2/sys_rwlock.cpp b/rpcs3/Emu/Cell/lv2/sys_rwlock.cpp index bcec78bd9a..4413b6f877 100644 --- a/rpcs3/Emu/Cell/lv2/sys_rwlock.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_rwlock.cpp @@ -343,10 +343,12 @@ error_code sys_rwlock_wlock(ppu_thread& ppu, u32 rw_lock_id, u64 timeout) continue; } - // If the last waiter quit the writer sleep queue, readers must acquire the lock - if (!rwlock->rq.empty() && rwlock->wq.empty()) + // If the last waiter quit the writer sleep queue, wake blocked readers + if (!rwlock->rq.empty() && rwlock->wq.empty() && rwlock->owner < 0) { - rwlock->owner = (s64{-2} * rwlock->rq.size()) | 1; + verify(HERE), rwlock->owner & 1; + + rwlock->owner -= s64{2} * rwlock->rq.size(); while (auto cpu = rwlock->schedule(rwlock->rq, SYS_SYNC_PRIORITY)) {