From 7f4e546f1910756ca6e30bd23521ce3083541696 Mon Sep 17 00:00:00 2001 From: Silent Date: Sun, 2 Feb 2020 16:50:58 +0100 Subject: [PATCH] Protect m_storage.find(key) to fix a race --- rpcs3/Emu/RSX/Common/ProgramStateCache.h | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/rpcs3/Emu/RSX/Common/ProgramStateCache.h b/rpcs3/Emu/RSX/Common/ProgramStateCache.h index ef5e6d4d03..add27bf07f 100644 --- a/rpcs3/Emu/RSX/Common/ProgramStateCache.h +++ b/rpcs3/Emu/RSX/Common/ProgramStateCache.h @@ -455,11 +455,14 @@ public: backend_traits::validate_pipeline_properties(vertex_program, fragment_program, pipelineProperties); pipeline_key key = { vertex_program.id, fragment_program.id, pipelineProperties }; - const auto I = m_storage.find(key); - if (I != m_storage.end()) { - m_cache_miss_flag = false; - return I->second; + reader_lock lock(m_pipeline_mutex); + const auto I = m_storage.find(key); + if (I != m_storage.end()) + { + m_cache_miss_flag = false; + return I->second; + } } if (allow_async)