A few false-positive TSAN warnings in various parts of engine code

Hi, we run our Linux servers with thread sanitizer (-EnableTSan) and found there are some warnings. For example, TSAN complains about race conditions in TQueue::Deque and TQueue::Enqueue. In our case the queue is MPSC. I found there is CL35622008 which adds a condition for SPSC and moves TSAN_AFTER and TSAN_BEFORE from MPSC logic. Is that a false positive warning and would that CL help us to prevent this issue?

`Read of size 8 at 0x7b04000a0550 by thread T15:
#0 TQueue<IHttpThreadedRequest*, (EQueueMode)0>::Dequeue(IHttpThreadedRequest*&) Engine\Source/Runtime/Core/Public\Containers/Queue.h:72:25 (+0x15635c53) (BuildId: cba7d19b0c54f9a2)
#1 FHttpThread::Process(TArray<IHttpThreadedRequest*, TSizedDefaultAllocator<32>>&, TArray<IHttpThreadedRequest*, TSizedDefaultAllocator<32>>&) Engine\Source/.\Runtime/Online/HTTP/Private/HttpThread.cpp:224:30 (+0x15635c53)
#2 FHttpThread::Run() Engine\Source/.\Runtime/Online/HTTP/Private/HttpThread.cpp:130:5 (+0x15634660) (BuildId: cba7d19b0c54f9a2)
#3 FRunnableThreadPThread::Run() Engine\Source/.\Runtime/Core/Private/HAL/PThreadRunnableThread.cpp:25:24 (+0x14d661e4) (BuildId: cba7d19b0c54f9a2)
#4 FRunnableThreadPThread::_ThreadProc(void*) Engine\Source/Runtime/Core/Private\HAL/PThreadRunnableThread.h:187:15 (+0x14cfeea3) (BuildId: cba7d19b0c54f9a2)

Previous atomic write of size 8 at 0x7b04000a0550 by main thread:
#0 FClangPlatformAtomics::InterlockedExchangePtr(void* volatile*, void*) Engine\Source/Runtime/Core/Public\Clang/ClangPlatformAtomics.h:101:10 (+0x1561a901) (BuildId: cba7d19b0c54f9a2)
#1 TQueue<IHttpThreadedRequest*, (EQueueMode)0>::Enqueue(IHttpThreadedRequest* const&) Engine\Source/Runtime/Core/Public\Containers/Queue.h:124:4 (+0x1561a901)
#2 FHttpThread::AddRequest(IHttpThreadedRequest*) Engine\Source/.\Runtime/Online/HTTP/Private/HttpThread.cpp:86:22 (+0x1561a901)
#3 FHttpManager::AddThreadedRequest(TSharedRef<IHttpThreadedRequest, (ESPMode)1> const&) Engine\Source/.\Runtime/Online/HTTP/Private/HttpManager.cpp:420:10 (+0x1561a901)
#4 FCurlHttpRequest::ProcessRequest() Engine\Source/.\Runtime/Online/HTTP/Private/Curl/CurlHttp.cpp:1042:39 (+0x156178e6) (BuildId: cba7d19b0c54f9a2)`

Steps to Reproduce
Build a server with:

dotnet.exe “\Engine\Binaries\DotNET\UnrealBuildTool\UnrealBuildTool.dll” ServerBinary Linux Development -Manifest=\Engine\Intermediate\Build\Manifest.xml -NoHotReload -xgeexport -NoUBTMakefiles -Project=“OurProject.uproject” -WarningsAsErrors -NoPCH -EnableTSan -log=“C:\Engine\Programs\AutomationTool\Saved\Logs\UBT-OurProjectServer-Linux-Development.txt”

I’ve been told that yes, there are some false positives in TQueue, though I’m not sure exactly what it would take to resolve them. The CL you mention likely won’t remove those TSan false positives since it is essentially a no-op for MPSC. That said, I would strongly encourage new code to use TMpscQueue or TSpscQueue instead of TQueue. Technically, TQueue has been deprecated for quite a while and I’ve been slowly working on removing its use in our codebase so that it can be removed entirely.