Skip to content

Commit d35422b

Browse files
committed
core(tls): hide assertions from Thread Sanitizer
1 parent 68ef903 commit d35422b

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

modules/core/include/opencv2/core/cvdef.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,17 @@ Cv64suf;
327327
# endif
328328
#endif
329329

330+
/****************************************************************************************\
331+
* Thread sanitizer *
332+
\****************************************************************************************/
333+
#ifndef CV_THREAD_SANITIZER
334+
# if defined(__has_feature)
335+
# if __has_feature(thread_sanitizer)
336+
# define CV_THREAD_SANITIZER
337+
# endif
338+
# endif
339+
#endif
340+
330341
/****************************************************************************************\
331342
* exchange-add operation for atomic operations on reference counters *
332343
\****************************************************************************************/

modules/core/src/system.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1396,7 +1396,9 @@ class TlsStorage
13961396
// Get data by TLS storage index
13971397
void* getData(size_t slotIdx) const
13981398
{
1399+
#ifndef CV_THREAD_SANITIZER
13991400
CV_Assert(tlsSlotsSize > slotIdx);
1401+
#endif
14001402

14011403
ThreadData* threadData = (ThreadData*)tls.GetData();
14021404
if(threadData && threadData->slots.size() > slotIdx)
@@ -1426,7 +1428,9 @@ class TlsStorage
14261428
// Set data to storage index
14271429
void setData(size_t slotIdx, void* pData)
14281430
{
1431+
#ifndef CV_THREAD_SANITIZER
14291432
CV_Assert(tlsSlotsSize > slotIdx);
1433+
#endif
14301434

14311435
ThreadData* threadData = (ThreadData*)tls.GetData();
14321436
if(!threadData)

0 commit comments

Comments
 (0)