summaryrefslogtreecommitdiff
path: root/src/core/hle/kernel/svc.cpp
diff options
context:
space:
mode:
authorGravatar Subv2018-08-12 16:35:27 -0500
committerGravatar Subv2018-08-12 16:35:27 -0500
commit5224cc49c4daa8d20999bad15a9b16d8d16b9d10 (patch)
tree1adb522e7319f520a382a34cd635b08a0f04a989 /src/core/hle/kernel/svc.cpp
parentMerge pull request #1029 from bunnei/fix-out-attrib (diff)
downloadyuzu-5224cc49c4daa8d20999bad15a9b16d8d16b9d10.tar.gz
yuzu-5224cc49c4daa8d20999bad15a9b16d8d16b9d10.tar.xz
yuzu-5224cc49c4daa8d20999bad15a9b16d8d16b9d10.zip
Kernel/Mutex: Don't duplicate threads in the mutex waiter list.
Exit from AddMutexWaiter early if the thread is already waiting for a mutex owned by the owner thread. This accounts for the possibility of a thread that is waiting on a condition variable being awakened twice in a row. Also added more validation asserts. This should fix one of the random crashes in Breath Of The Wild.
Diffstat (limited to 'src/core/hle/kernel/svc.cpp')
-rw-r--r--src/core/hle/kernel/svc.cpp3
1 files changed, 1 insertions, 2 deletions
diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp
index 5db2db687..5818cc06d 100644
--- a/src/core/hle/kernel/svc.cpp
+++ b/src/core/hle/kernel/svc.cpp
@@ -706,8 +706,7 @@ static ResultCode SignalProcessWideKey(VAddr condition_variable_addr, s32 target
706 Handle owner_handle = static_cast<Handle>(mutex_val & Mutex::MutexOwnerMask); 706 Handle owner_handle = static_cast<Handle>(mutex_val & Mutex::MutexOwnerMask);
707 auto owner = g_handle_table.Get<Thread>(owner_handle); 707 auto owner = g_handle_table.Get<Thread>(owner_handle);
708 ASSERT(owner); 708 ASSERT(owner);
709 ASSERT(thread->status != ThreadStatus::Running); 709 ASSERT(thread->status == ThreadStatus::WaitMutex);
710 thread->status = ThreadStatus::WaitMutex;
711 thread->wakeup_callback = nullptr; 710 thread->wakeup_callback = nullptr;
712 711
713 owner->AddMutexWaiter(thread); 712 owner->AddMutexWaiter(thread);