From 984bb31709a37c8a510ae3646a4c6543e5ae2015 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 3 May 2014 18:40:27 -0700 Subject: [PATCH] Fix another race condition with multithreading. It's possible that after it's marked completed, the CPU will grab it to enqueue. This actually happened to mean with decent reproducibility. --- GPU/GPUCommon.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/GPU/GPUCommon.cpp b/GPU/GPUCommon.cpp index c575e4f2ef..be0ceac43c 100644 --- a/GPU/GPUCommon.cpp +++ b/GPU/GPUCommon.cpp @@ -663,8 +663,12 @@ void GPUCommon::ProcessDLQueueInternal() { return; } else { easy_guard guard(listLock); - // At the end, we can remove it from the queue and continue. - dlQueue.erase(std::remove(dlQueue.begin(), dlQueue.end(), listIndex), dlQueue.end()); + + // Some other list could've taken the spot while we dilly-dallied around. + if (l.state != PSP_GE_DL_STATE_QUEUED) { + // At the end, we can remove it from the queue and continue. + dlQueue.erase(std::remove(dlQueue.begin(), dlQueue.end(), listIndex), dlQueue.end()); + } UpdateTickEstimate(std::max(busyTicks, startingTicks + cyclesExecuted)); } }