]> granicus.if.org Git - python/commitdiff
Close #18596: Support address sanity checking in clang/GCC
authorNick Coghlan <ncoghlan@gmail.com>
Sat, 28 Sep 2013 14:28:55 +0000 (00:28 +1000)
committerNick Coghlan <ncoghlan@gmail.com>
Sat, 28 Sep 2013 14:28:55 +0000 (00:28 +1000)
This patch appropriately marks known false alarms in the
small object allocator when address sanity checking is
enabled (patch contributed by Dhiru Kholia).

Misc/ACKS
Misc/NEWS
Objects/obmalloc.c

index cb823d1ec1a27143c5047ecee16c47183a1ebdc8..5b7b630b948d8723094b2b84f28a17de74e5285d 100644 (file)
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -650,6 +650,7 @@ Jim Kerr
 Magnus Kessler
 Lawrence Kesteloot
 Vivek Khera
+Dhiru Kholia
 Mads Kiilerich
 Jason Killen
 Jan Kim
index ae8631f06a0233e5ecb0ed00b5fc218fbbc6a98a..449d915eaf87fda03e4a849618a3fcc21c5030c6 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -94,6 +94,13 @@ Documentation
 - Issue #17003: Unified the size argument names in the io module with common
   practice.
 
+Build
+-----
+
+- Issue #18596: Support the use of address sanity checking in recent versions
+  of clang and GCC by appropriately marking known false alarms in the small
+  object allocator. Patch contributed by Dhiru Kholia.
+
 Tools/Demos
 -----------
 
index 4437bf9a659c409028c629bcf4970363a1f633a7..f7b3e491ca468001039cbcd9f57433f920fae683 100644 (file)
@@ -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)
 {