File tree Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Original file line number Diff line number Diff line change 19
19
20
20
#include " driver_config.hpp"
21
21
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
+
22
40
#if defined(HAVE_BOOST_ATOMIC)
23
41
#include " atomic/atomic_boost.hpp"
24
42
#elif defined(HAVE_STD_ATOMIC)
Original file line number Diff line number Diff line change @@ -43,6 +43,9 @@ class RefCounted : public Allocated {
43
43
assert (new_ref_count >= 1 );
44
44
if (new_ref_count == 1 ) {
45
45
atomic_thread_fence (MEMORY_ORDER_ACQUIRE);
46
+ #ifdef THREAD_SANITIZER
47
+ __tsan_acquire (const_cast <void *>(static_cast <const void *>(this )));
48
+ #endif
46
49
delete static_cast <const T*>(this );
47
50
}
48
51
}
You can’t perform that action at this time.
0 commit comments