Kaydet (Commit) 6ba64f45 authored tarafından Nick Coghlan's avatar Nick Coghlan

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).
üst 4cc2afa0
...@@ -650,6 +650,7 @@ Jim Kerr ...@@ -650,6 +650,7 @@ Jim Kerr
Magnus Kessler Magnus Kessler
Lawrence Kesteloot Lawrence Kesteloot
Vivek Khera Vivek Khera
Dhiru Kholia
Mads Kiilerich Mads Kiilerich
Jason Killen Jason Killen
Jan Kim Jan Kim
......
...@@ -94,6 +94,13 @@ Documentation ...@@ -94,6 +94,13 @@ Documentation
- Issue #17003: Unified the size argument names in the io module with common - Issue #17003: Unified the size argument names in the io module with common
practice. 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 Tools/Demos
----------- -----------
......
...@@ -12,6 +12,24 @@ static void _PyObject_DebugDumpAddress(const void *p); ...@@ -12,6 +12,24 @@ static void _PyObject_DebugDumpAddress(const void *p);
static void _PyMem_DebugCheckAddress(char api_id, const void *p); static void _PyMem_DebugCheckAddress(char api_id, const void *p);
#endif #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 WITH_PYMALLOC
#ifdef MS_WINDOWS #ifdef MS_WINDOWS
...@@ -1300,6 +1318,7 @@ redirect: ...@@ -1300,6 +1318,7 @@ redirect:
/* free */ /* free */
ATTRIBUTE_NO_ADDRESS_SAFETY_ANALYSIS
static void static void
_PyObject_Free(void *ctx, void *p) _PyObject_Free(void *ctx, void *p)
{ {
...@@ -1528,6 +1547,7 @@ redirect: ...@@ -1528,6 +1547,7 @@ redirect:
* return a non-NULL result. * return a non-NULL result.
*/ */
ATTRIBUTE_NO_ADDRESS_SAFETY_ANALYSIS
static void * static void *
_PyObject_Realloc(void *ctx, void *p, size_t nbytes) _PyObject_Realloc(void *ctx, void *p, size_t nbytes)
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment