diff options
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) { | |||
| 27 | 27 | ||
| 28 | void WaitObject::RemoveWaitingThread(Thread* thread) { | 28 | void WaitObject::RemoveWaitingThread(Thread* thread) { |
| 29 | auto itr = std::find(waiting_threads.begin(), waiting_threads.end(), thread); | 29 | auto itr = std::find(waiting_threads.begin(), waiting_threads.end(), thread); |
| 30 | // If a thread passed multiple handles to the same object, | ||
| 31 | // the kernel might attempt to remove the thread from the object's | ||
| 32 | // waiting threads list multiple times. | ||
| 30 | if (itr != waiting_threads.end()) | 33 | if (itr != waiting_threads.end()) |
| 31 | waiting_threads.erase(itr); | 34 | waiting_threads.erase(itr); |
| 32 | } | 35 | } |
| @@ -36,6 +39,11 @@ SharedPtr<Thread> WaitObject::GetHighestPriorityReadyThread() { | |||
| 36 | s32 candidate_priority = THREADPRIO_LOWEST + 1; | 39 | s32 candidate_priority = THREADPRIO_LOWEST + 1; |
| 37 | 40 | ||
| 38 | for (const auto& thread : waiting_threads) { | 41 | for (const auto& thread : waiting_threads) { |
| 42 | // The list of waiting threads must not contain threads that are not waiting to be awakened. | ||
| 43 | ASSERT_MSG(thread->status == THREADSTATUS_WAIT_SYNCH_ANY || | ||
| 44 | thread->status == THREADSTATUS_WAIT_SYNCH_ALL, | ||
| 45 | "Inconsistent thread statuses in waiting_threads"); | ||
| 46 | |||
| 39 | if (thread->current_priority >= candidate_priority) | 47 | if (thread->current_priority >= candidate_priority) |
| 40 | continue; | 48 | continue; |
| 41 | 49 | ||