@@ -30,19 +30,36 @@ static void _PyMem_DebugCheckAddress(char api_id, const void *p);
30
30
static void _PyMem_SetupDebugHooksDomain (PyMemAllocatorDomain domain );
31
31
32
32
#if defined(__has_feature ) /* Clang */
33
- # if __has_feature (address_sanitizer ) /* is ASAN enabled? */
34
- # define ATTRIBUTE_NO_ADDRESS_SAFETY_ANALYSIS \
33
+ # if __has_feature (address_sanitizer ) /* is ASAN enabled? */
34
+ # define _Py_NO_ADDRESS_SAFETY_ANALYSIS \
35
35
__attribute__((no_address_safety_analysis))
36
- #else
37
- #define ATTRIBUTE_NO_ADDRESS_SAFETY_ANALYSIS
38
- #endif
39
- #else
40
- #if defined(__SANITIZE_ADDRESS__ ) /* GCC 4.8.x, is ASAN enabled? */
41
- #define ATTRIBUTE_NO_ADDRESS_SAFETY_ANALYSIS \
36
+ # endif
37
+ # if __has_feature (thread_sanitizer ) /* is TSAN enabled? */
38
+ # define _Py_NO_SANITIZE_THREAD __attribute__((no_sanitize_thread))
39
+ # endif
40
+ # if __has_feature (memory_sanitizer ) /* is MSAN enabled? */
41
+ # define _Py_NO_SANITIZE_MEMORY __attribute__((no_sanitize_memory))
42
+ # endif
43
+ #elif defined(__GNUC__ )
44
+ # if defined(__SANITIZE_ADDRESS__ ) /* GCC 4.8+, is ASAN enabled? */
45
+ # define _Py_NO_ADDRESS_SAFETY_ANALYSIS \
42
46
__attribute__((no_address_safety_analysis))
43
- #else
44
- #define ATTRIBUTE_NO_ADDRESS_SAFETY_ANALYSIS
45
- #endif
47
+ # endif
48
+ // TSAN is supported since GCC 4.8, but __SANITIZE_THREAD__ macro
49
+ // is provided only since GCC 7.
50
+ # if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8 )
51
+ # define _Py_NO_SANITIZE_THREAD __attribute__((no_sanitize_thread))
52
+ # endif
53
+ #endif
54
+
55
+ #ifndef _Py_NO_ADDRESS_SAFETY_ANALYSIS
56
+ # define _Py_NO_ADDRESS_SAFETY_ANALYSIS
57
+ #endif
58
+ #ifndef _Py_NO_SANITIZE_THREAD
59
+ # define _Py_NO_SANITIZE_THREAD
60
+ #endif
61
+ #ifndef _Py_NO_SANITIZE_MEMORY
62
+ # define _Py_NO_SANITIZE_MEMORY
46
63
#endif
47
64
48
65
#ifdef WITH_PYMALLOC
@@ -1301,7 +1318,9 @@ obmalloc controls. Since this test is needed at every entry point, it's
1301
1318
extremely desirable that it be this fast.
1302
1319
*/
1303
1320
1304
- static bool ATTRIBUTE_NO_ADDRESS_SAFETY_ANALYSIS
1321
+ static bool _Py_NO_ADDRESS_SAFETY_ANALYSIS
1322
+ _Py_NO_SANITIZE_THREAD
1323
+ _Py_NO_SANITIZE_MEMORY
1305
1324
address_in_range (void * p , poolp pool )
1306
1325
{
1307
1326
// Since address_in_range may be reading from memory which was not allocated
0 commit comments