From d35422b5234761deef85e46ee84f109fb11010e9 Mon Sep 17 00:00:00 2001 From: Alexander Alekhin Date: Thu, 27 Jul 2017 17:31:51 +0300 Subject: [PATCH] core(tls): hide assertions from Thread Sanitizer --- modules/core/include/opencv2/core/cvdef.h | 11 +++++++++++ modules/core/src/system.cpp | 4 ++++ 2 files changed, 15 insertions(+) diff --git a/modules/core/include/opencv2/core/cvdef.h b/modules/core/include/opencv2/core/cvdef.h index 2ac0e17055..70bbf93104 100644 --- a/modules/core/include/opencv2/core/cvdef.h +++ b/modules/core/include/opencv2/core/cvdef.h @@ -327,6 +327,17 @@ Cv64suf; # endif #endif +/****************************************************************************************\ +* Thread sanitizer * +\****************************************************************************************/ +#ifndef CV_THREAD_SANITIZER +# if defined(__has_feature) +# if __has_feature(thread_sanitizer) +# define CV_THREAD_SANITIZER +# endif +# endif +#endif + /****************************************************************************************\ * exchange-add operation for atomic operations on reference counters * \****************************************************************************************/ diff --git a/modules/core/src/system.cpp b/modules/core/src/system.cpp index 629c3fb637..7ea0dd6c5d 100644 --- a/modules/core/src/system.cpp +++ b/modules/core/src/system.cpp @@ -1396,7 +1396,9 @@ public: // Get data by TLS storage index void* getData(size_t slotIdx) const { +#ifndef CV_THREAD_SANITIZER CV_Assert(tlsSlotsSize > slotIdx); +#endif ThreadData* threadData = (ThreadData*)tls.GetData(); if(threadData && threadData->slots.size() > slotIdx) @@ -1426,7 +1428,9 @@ public: // Set data to storage index void setData(size_t slotIdx, void* pData) { +#ifndef CV_THREAD_SANITIZER CV_Assert(tlsSlotsSize > slotIdx); +#endif ThreadData* threadData = (ThreadData*)tls.GetData(); if(!threadData)