From 6ef49349ffbaa8b8b4a32ceea439b3b3b9f2043e Mon Sep 17 00:00:00 2001 From: Wojciech Figat Date: Thu, 29 Dec 2022 11:20:39 +0100 Subject: [PATCH] Fix assertion on thread double-free from registry (not harmful) --- Source/Engine/Threading/ThreadRegistry.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Source/Engine/Threading/ThreadRegistry.cpp b/Source/Engine/Threading/ThreadRegistry.cpp index b6844e13f..3dafb4f87 100644 --- a/Source/Engine/Threading/ThreadRegistry.cpp +++ b/Source/Engine/Threading/ThreadRegistry.cpp @@ -47,7 +47,6 @@ void ThreadRegistry::KillEmAll() void ThreadRegistry::Add(Thread* thread) { ASSERT(thread && thread->GetID() != 0); - Locker.Lock(); ASSERT(!Registry.ContainsKey(thread->GetID()) && !Registry.ContainsValue(thread)); Registry.Add(thread->GetID(), thread); @@ -57,9 +56,11 @@ void ThreadRegistry::Add(Thread* thread) void ThreadRegistry::Remove(Thread* thread) { ASSERT(thread && thread->GetID() != 0); - Locker.Lock(); - ASSERT_LOW_LAYER(Registry.ContainsKey(thread->GetID()) && Registry[thread->GetID()] == thread); +#if ENABLE_ASSERTION_LOW_LAYERS + Thread** currentValue = Registry.TryGet(thread->GetID()); + ASSERT_LOW_LAYER(!currentValue || *currentValue == thread); +#endif Registry.Remove(thread->GetID()); Locker.Unlock(); }