From 4fc12cdd2992c42dd35fe2b9107afcf17d30f288 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 29 May 2016 00:12:36 -0700 Subject: [PATCH] ThreadEvent: Handle getting scheduled off a thread. --- Core/HLE/ThreadQueueList.h | 2 +- Core/HLE/sceKernelThread.cpp | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Core/HLE/ThreadQueueList.h b/Core/HLE/ThreadQueueList.h index beb149657a..9111fff41d 100644 --- a/Core/HLE/ThreadQueueList.h +++ b/Core/HLE/ThreadQueueList.h @@ -99,7 +99,7 @@ struct ThreadQueueList { return 0; } - inline SceUID peek_first(u32 priority) { + inline SceUID peek_first() { Queue *cur = first; while (cur != invalid()) { if (cur->size() > 0) diff --git a/Core/HLE/sceKernelThread.cpp b/Core/HLE/sceKernelThread.cpp index 06fb085d72..978defe8a3 100644 --- a/Core/HLE/sceKernelThread.cpp +++ b/Core/HLE/sceKernelThread.cpp @@ -3057,7 +3057,7 @@ static bool __CanExecuteCallbackNow(Thread *thread) { void __KernelCallAddress(Thread *thread, u32 entryPoint, Action *afterAction, const u32 args[], int numargs, bool reschedAfter, SceUID cbId) { - if (thread->isStopped()) { + if (!thread || thread->isStopped()) { WARN_LOG_REPORT(SCEKERNEL, "Running mipscall on dormant thread"); } @@ -3591,8 +3591,8 @@ KernelObject *__KernelThreadEventHandlerObject() { void __KernelThreadTriggerEvent(const ThreadEventHandlerList &handlers, SceUID threadID, ThreadEventType type) { Thread *thread = __GetCurrentThread(); - if (thread->isStopped()) { - SceUID nextThreadID = threadReadyQueue.peek_first(thread->nt.currentPriority); + if (!thread || thread->isStopped()) { + SceUID nextThreadID = threadReadyQueue.peek_first(); thread = kernelObjects.GetFast(nextThreadID); }