From bf29a4d7464ec587e8a6a566d495ac4636327d0d Mon Sep 17 00:00:00 2001 From: Yannis Guyon Date: Fri, 27 Jan 2023 13:02:46 +0100 Subject: [PATCH] Avoid double-checked locking with TSAN in parallel Omit the first check of the double-checked locking pattern in recordException() in parallel.cpp when CV_THREAD_SANITIZER is defined. This should only slow recordException() down when the thread sanitizer is used, and avoids the TSAN data race warning. --- modules/core/src/parallel.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/modules/core/src/parallel.cpp b/modules/core/src/parallel.cpp index a4a7baf0f6..efecefc4b4 100644 --- a/modules/core/src/parallel.cpp +++ b/modules/core/src/parallel.cpp @@ -263,7 +263,9 @@ namespace { void recordException(const cv::String& msg) #endif { +#ifndef CV_THREAD_SANITIZER if (!hasException) +#endif { cv::AutoLock lock(cv::getInitializationMutex()); if (!hasException)