From 847b16fb769b18d1c317fc9e6dde328f2e1367d2 Mon Sep 17 00:00:00 2001 From: Vincent Rabaud Date: Mon, 8 Feb 2021 16:53:37 +0100 Subject: [PATCH] Disable thread sanitization when CV_USE_GLOBAL_WORKERS_COND_VAR is not set. This fixes #19463 --- modules/core/src/parallel_impl.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/modules/core/src/parallel_impl.cpp b/modules/core/src/parallel_impl.cpp index 8638af9d67..7f30c9d5f3 100644 --- a/modules/core/src/parallel_impl.cpp +++ b/modules/core/src/parallel_impl.cpp @@ -382,6 +382,16 @@ public: }; +// Disable thread sanitization check when CV_USE_GLOBAL_WORKERS_COND_VAR is not +// set because it triggers as the main thread reads isActive while the children +// thread writes it (but it all works out because a mutex is locked in the main +// thread and isActive re-checked). +// This is to solve issue #19463. +#if !defined(CV_USE_GLOBAL_WORKERS_COND_VAR) && defined(__clang__) && defined(__has_feature) +#if __has_feature(thread_sanitizer) +__attribute__((no_sanitize("thread"))) +#endif +#endif void WorkerThread::thread_body() { (void)cv::utils::getThreadID(); // notify OpenCV about new thread