aboutsummaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorayles <ayles@yandex-team.com>2022-09-19 12:27:43 +0300
committerayles <ayles@yandex-team.com>2022-09-19 12:27:43 +0300
commitff49fbec3c655b16509b12a0f3a82efacd521771 (patch)
treee14ab4fda50eaf34e8f2c2be86ab2cb055eb96e2 /util
parent94de3c44fbfb54ffa1ea7a8baa73d174ee6f40b1 (diff)
downloadydb-ff49fbec3c655b16509b12a0f3a82efacd521771.tar.gz
Fix tsan warnings in yt intrusive ptr
For example, https://github.com/google/sanitizers/issues/1352 - tsan is not working well with std::atomic_thread_fence Minimal reproducible example (and one that bothers most in every fiber-aware service): ``` auto threadPool = NYT::New<NYT::NConcurrency::TThreadPool>(2, "thread"); TVector<NYT::TFuture<void>> futures; for (size_t i = 0; i < 100000; ++i) { futures.emplace_back(BIND([]() { }).AsyncVia(threadPool->GetInvoker()).Run()); } for (auto& future : futures) { future.Get().ThrowOnError(); } ```
Diffstat (limited to 'util')
-rw-r--r--util/system/sanitizers.h21
1 files changed, 21 insertions, 0 deletions
diff --git a/util/system/sanitizers.h b/util/system/sanitizers.h
index 965e5c751e..3ff42ca15e 100644
--- a/util/system/sanitizers.h
+++ b/util/system/sanitizers.h
@@ -14,6 +14,11 @@ extern "C" { // sanitizers API
void __msan_check_mem_is_initialized(const volatile void* x, size_t size);
#endif
+#if defined(_tsan_enabled_)
+ void __tsan_acquire(void* a);
+ void __tsan_release(void* a);
+#endif
+
}; // sanitizers API
namespace NSan {
@@ -138,4 +143,20 @@ namespace NSan {
Y_UNUSED(description);
}
#endif
+
+ inline static void Acquire(void* a) {
+#if defined(_tsan_enabled_)
+ __tsan_acquire(a);
+#else
+ Y_UNUSED(a);
+#endif
+ }
+
+ inline static void Release(void* a) {
+#if defined(_tsan_enabled_)
+ __tsan_release(a);
+#else
+ Y_UNUSED(a);
+#endif
+ }
}