aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/cxxsupp/openmp/patches/fix_asan.patch
blob: 1245ade87192ba968878cdc2ca921b096599d9b2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
diff --git a/kmp_alloc.cpp b/kmp_alloc.cpp
index 21518c9..c966fa6 100644
--- a/kmp_alloc.cpp
+++ b/kmp_alloc.cpp
@@ -17,6 +17,18 @@
 #include "kmp_io.h"
 #include "kmp_wrapper_malloc.h"

+#ifdef __clang__
+#if __has_feature(address_sanitizer)
+extern "C" { // sanitizers API
+void __lsan_ignore_object(const void* p);
+}
+#else
+#define __lsan_ignore_object(p)
+#endif
+#else
+#define __lsan_ignore_object(p)
+#endif
+
 // Disable bget when it is not used
 #if KMP_USE_BGET
 
@@ -1862,6 +1862,9 @@ static void *___kmp_allocate_align(size_t size,
 #else
   descr.ptr_allocated = malloc_src_loc(descr.size_allocated KMP_SRC_LOC_PARM);
 #endif
+
+  __lsan_ignore_object(descr.ptr_allocated); // espetrov@yandex-team.ru: asan considers descr.ptr_allocated leaked because of address alignment arithmetics
+
   KE_TRACE(10, ("   malloc( %d ) returned %p\n", (int)descr.size_allocated,
                 descr.ptr_allocated));
   if (descr.ptr_allocated == NULL) {