diff options
author | Maxim Ostapenko <m.ostapenko@samsung.com> | 2016-12-07 10:29:36 +0300 |
---|---|---|
committer | Maxim Ostapenko <m.ostapenko@samsung.com> | 2016-12-07 10:29:36 +0300 |
commit | 0e58c426324dfdec09042b45ec32e7064d6aa995 (patch) | |
tree | 22f81145b05aea2d0e0d976b059e1adf62709e37 | |
parent | 05e5371e4c51cacc1b9057e038c120605be2118b (diff) | |
download | python-sandbox/mro/dynamic_allocas.tar.gz python-sandbox/mro/dynamic_allocas.tar.bz2 python-sandbox/mro/dynamic_allocas.zip |
Backport https://hg.python.org/cpython/rev/f6792f734fcc/sandbox/mro/dynamic_allocas
Change-Id: I50013a31b76a661803c3a27550ddde01fede8561
Signed-off-by: Maxim Ostapenko <m.ostapenko@samsung.com>
-rw-r--r-- | Objects/obmalloc.c | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/Objects/obmalloc.c b/Objects/obmalloc.c index 1434206..8416377 100644 --- a/Objects/obmalloc.c +++ b/Objects/obmalloc.c @@ -24,6 +24,24 @@ static int running_on_valgrind = -1; #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 + /* An object allocator for Python. Here is an introduction to the layers of the Python memory architecture, @@ -971,6 +989,7 @@ redirect: /* free */ #undef PyObject_Free +ATTRIBUTE_NO_ADDRESS_SAFETY_ANALYSIS void PyObject_Free(void *p) { @@ -1201,6 +1220,7 @@ redirect: */ #undef PyObject_Realloc +ATTRIBUTE_NO_ADDRESS_SAFETY_ANALYSIS void * PyObject_Realloc(void *p, size_t nbytes) { @@ -1263,7 +1283,8 @@ PyObject_Realloc(void *p, size_t nbytes) * SMALL_REQUEST_THRESHOLD, it's tempting to try to take over this * block. However, if we do, we need to copy the valid data from * the C-managed block to one of our blocks, and there's no portable - * way to know how much of the memory space starting at p is valid. + * way to know how much of the + ATTRIBUTE_NO_ADDRESS_SAFETY_ANALYSISmemory space starting at p is valid. * As bug 1185883 pointed out the hard way, it's possible that the * C-managed block is "at the end" of allocated VM space, so that * a memory fault can occur if we try to copy nbytes bytes starting |