diff options
author | Nick Coghlan <ncoghlan@gmail.com> | 2013-09-28 14:28:55 (GMT) |
---|---|---|
committer | Nick Coghlan <ncoghlan@gmail.com> | 2013-09-28 14:28:55 (GMT) |
commit | 6ba64f454da7710f0dcbb28fd574ac3fda7eb00c (patch) | |
tree | ebbe7911f4344b84cbbaa411e30bef4013066d0a /Objects | |
parent | 4cc2afa0ec54910d60cdc4ca57d886f66c88dc18 (diff) | |
download | cpython-6ba64f454da7710f0dcbb28fd574ac3fda7eb00c.zip cpython-6ba64f454da7710f0dcbb28fd574ac3fda7eb00c.tar.gz cpython-6ba64f454da7710f0dcbb28fd574ac3fda7eb00c.tar.bz2 |
Close #18596: Support address sanity checking in clang/GCC
This patch appropriately marks known false alarms in the
small object allocator when address sanity checking is
enabled (patch contributed by Dhiru Kholia).
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/obmalloc.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/Objects/obmalloc.c b/Objects/obmalloc.c index 4437bf9..f7b3e49 100644 --- a/Objects/obmalloc.c +++ b/Objects/obmalloc.c @@ -12,6 +12,24 @@ static void _PyObject_DebugDumpAddress(const void *p); static void _PyMem_DebugCheckAddress(char api_id, const void *p); #endif +#if defined(__has_feature) /* Clang */ + #if __has_feature(address_sanitizer) /* is ASAN enabled? */ + #define ATTRIBUTE_NO_ADDRESS_SAFETY_ANALYSIS \ + __attribute__((no_address_safety_analysis)) \ + __attribute__ ((noinline)) + #else + #define ATTRIBUTE_NO_ADDRESS_SAFETY_ANALYSIS + #endif +#else + #if defined(__SANITIZE_ADDRESS__) /* GCC 4.8.x, is ASAN enabled? */ + #define ATTRIBUTE_NO_ADDRESS_SAFETY_ANALYSIS \ + __attribute__((no_address_safety_analysis)) \ + __attribute__ ((noinline)) + #else + #define ATTRIBUTE_NO_ADDRESS_SAFETY_ANALYSIS + #endif +#endif + #ifdef WITH_PYMALLOC #ifdef MS_WINDOWS @@ -1300,6 +1318,7 @@ redirect: /* free */ +ATTRIBUTE_NO_ADDRESS_SAFETY_ANALYSIS static void _PyObject_Free(void *ctx, void *p) { @@ -1528,6 +1547,7 @@ redirect: * return a non-NULL result. */ +ATTRIBUTE_NO_ADDRESS_SAFETY_ANALYSIS static void * _PyObject_Realloc(void *ctx, void *p, size_t nbytes) { |