diff options
author | Subv <subv2112@gmail.com> | 2017-01-04 18:48:13 +0100 |
---|---|---|
committer | Subv <subv2112@gmail.com> | 2017-01-05 15:40:18 +0100 |
commit | dda4ec93bea089e3286e9a965378d9411f480acd (patch) | |
tree | 29b3fcb87e02fc92e514e28877b588f09264c026 /src/core/hle/kernel/kernel.cpp | |
parent | Kernel: Remove a thread from all of its waiting objects' waiting_threads list when it is awoken. (diff) | |
download | yuzu-dda4ec93bea089e3286e9a965378d9411f480acd.tar yuzu-dda4ec93bea089e3286e9a965378d9411f480acd.tar.gz yuzu-dda4ec93bea089e3286e9a965378d9411f480acd.tar.bz2 yuzu-dda4ec93bea089e3286e9a965378d9411f480acd.tar.lz yuzu-dda4ec93bea089e3286e9a965378d9411f480acd.tar.xz yuzu-dda4ec93bea089e3286e9a965378d9411f480acd.tar.zst yuzu-dda4ec93bea089e3286e9a965378d9411f480acd.zip |
Diffstat (limited to 'src/core/hle/kernel/kernel.cpp')
-rw-r--r-- | src/core/hle/kernel/kernel.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/core/hle/kernel/kernel.cpp b/src/core/hle/kernel/kernel.cpp index 47d4df69c..f599916f0 100644 --- a/src/core/hle/kernel/kernel.cpp +++ b/src/core/hle/kernel/kernel.cpp @@ -27,6 +27,9 @@ void WaitObject::AddWaitingThread(SharedPtr<Thread> thread) { void WaitObject::RemoveWaitingThread(Thread* thread) { auto itr = std::find(waiting_threads.begin(), waiting_threads.end(), thread); + // If a thread passed multiple handles to the same object, + // the kernel might attempt to remove the thread from the object's + // waiting threads list multiple times. if (itr != waiting_threads.end()) waiting_threads.erase(itr); } @@ -36,6 +39,11 @@ SharedPtr<Thread> WaitObject::GetHighestPriorityReadyThread() { s32 candidate_priority = THREADPRIO_LOWEST + 1; for (const auto& thread : waiting_threads) { + // The list of waiting threads must not contain threads that are not waiting to be awakened. + ASSERT_MSG(thread->status == THREADSTATUS_WAIT_SYNCH_ANY || + thread->status == THREADSTATUS_WAIT_SYNCH_ALL, + "Inconsistent thread statuses in waiting_threads"); + if (thread->current_priority >= candidate_priority) continue; |