Check that the mutex address matches before waking a waiting thread

This commit is contained in:
gdkchan 2018-04-21 14:15:36 -03:00
commit babfcde885

View file

@ -187,8 +187,17 @@ namespace Ryujinx.Core.OsHle.Kernel
return false;
}
lock (CurrThread)
{
//This is the new thread that will not own the mutex.
//If no threads are waiting for the lock, then it should be null.
KThread OwnerThread = CurrThread.NextMutexThread;
while (OwnerThread?.NextMutexThread != null && OwnerThread.MutexAddress != MutexAddress)
{
OwnerThread = OwnerThread.NextMutexThread;
}
CurrThread.NextMutexThread = null;
if (OwnerThread != null)
@ -214,6 +223,7 @@ namespace Ryujinx.Core.OsHle.Kernel
return false;
}
}
}
private bool CondVarWait(
KThread WaitThread,
@ -246,6 +256,8 @@ namespace Ryujinx.Core.OsHle.Kernel
DoInsert &= CurrThread != WaitThread;
}
//Only insert if the node doesn't already exist in the list.
//This prevents circular references.
if (DoInsert)
{
if (WaitThread.NextCondVarThread != null)