File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1919
2020#include " driver_config.hpp"
2121
22+ #if !defined(THREAD_SANITIZER)
23+ #if defined(__has_feature)
24+ #if __has_feature(thread_sanitizer)
25+ #define THREAD_SANITIZER 1
26+ #endif
27+ #elif defined(__SANITIZE_THREAD__)
28+ #define THREAD_SANITIZER 1
29+ #endif
30+ #endif
31+
32+ // Annotations for atomic_thread_fence, see https://github.com/google/sanitizers/issues/1352
33+ #ifdef THREAD_SANITIZER
34+ extern " C" {
35+ void __tsan_acquire (void * addr);
36+ void __tsan_release (void * addr);
37+ }
38+ #endif
39+
2240#if defined(HAVE_BOOST_ATOMIC)
2341#include " atomic/atomic_boost.hpp"
2442#elif defined(HAVE_STD_ATOMIC)
Original file line number Diff line number Diff line change @@ -43,6 +43,9 @@ class RefCounted : public Allocated {
4343 assert (new_ref_count >= 1 );
4444 if (new_ref_count == 1 ) {
4545 atomic_thread_fence (MEMORY_ORDER_ACQUIRE);
46+ #ifdef THREAD_SANITIZER
47+ __tsan_acquire (const_cast <void *>(static_cast <const void *>(this )));
48+ #endif
4649 delete static_cast <const T*>(this );
4750 }
4851 }
You can’t perform that action at this time.
0 commit comments