From 1bbe9309daa96b5fbac7a2df5a2edcb17ab7a05c Mon Sep 17 00:00:00 2001 From: Subv Date: Mon, 8 Jan 2018 14:12:03 -0500 Subject: Kernel: Properly keep track of mutex lock data in the guest memory. This fixes userland locking/unlocking. --- src/core/hle/kernel/svc.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/core/hle/kernel/svc.cpp') diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp index 73793955a..a3ac3d782 100644 --- a/src/core/hle/kernel/svc.cpp +++ b/src/core/hle/kernel/svc.cpp @@ -204,7 +204,6 @@ static ResultCode LockMutex(Handle holding_thread_handle, VAddr mutex_addr, SharedPtr holding_thread = g_handle_table.Get(holding_thread_handle); SharedPtr requesting_thread = g_handle_table.Get(requesting_thread_handle); - ASSERT(holding_thread); ASSERT(requesting_thread); SharedPtr mutex = g_object_address_table.Get(mutex_addr); @@ -214,6 +213,8 @@ static ResultCode LockMutex(Handle holding_thread_handle, VAddr mutex_addr, mutex->name = Common::StringFromFormat("mutex-%llx", mutex_addr); } + ASSERT(holding_thread == mutex->GetHoldingThread()); + return WaitSynchronization1(mutex, requesting_thread.get()); } @@ -491,6 +492,8 @@ static ResultCode WaitProcessWideKeyAtomic(VAddr mutex_addr, VAddr semaphore_add mutex->name = Common::StringFromFormat("mutex-%llx", mutex_addr); } + ASSERT(mutex->GetOwnerHandle() == thread_handle); + SharedPtr semaphore = g_object_address_table.Get(semaphore_addr); if (!semaphore) { // Create a new semaphore for the specified address if one does not already exist -- cgit v1.2.3