Add ASan support for Tizen 4.0 toolchain 73/140973/3 accepted/tizen/4.0/base/20170828.221206 accepted/tizen/base/20170814.055733 submit/tizen_4.0_base/20170828.000000 submit/tizen_4.0_base/20170828.000001 submit/tizen_base/20170810.114146 submit/tizen_base/20180205.004317 tizen_4.0.IoT.p1_release tizen_4.0.IoT.p2_release tizen_4.0.m2_release
authorSlava Barinov <v.barinov@samsung.com>
Thu, 27 Jul 2017 09:41:12 +0000 (12:41 +0300)
committerSlava Barinov <v.barinov@samsung.com>
Thu, 27 Jul 2017 11:01:31 +0000 (14:01 +0300)
Change-Id: I9dafdddf0af4c511cf9be9208f86ef2774986fd6
Signed-off-by: Slava Barinov <v.barinov@samsung.com>
Objects/obmalloc.c

index 194fbfd52e3baf9579a5ad40f8197483298c8fe7..b9b3910e66b750874c260a404e0f97ff48ea3437 100644 (file)
@@ -5,6 +5,8 @@
   #define ATTRIBUTE_NO_ADDRESS_SAFETY_ANALYSIS \
         __attribute__ ((no_sanitize_address)) \
         __attribute__ ((noinline))
+  #define SANITIZED_BUILD
+  #define RUNNING_ON_VALGRIND 1
  #else
   #define ATTRIBUTE_NO_ADDRESS_SAFETY_ANALYSIS
  #endif
@@ -13,6 +15,8 @@
   #define ATTRIBUTE_NO_ADDRESS_SAFETY_ANALYSIS \
         __attribute__ ((no_sanitize_address)) \
         __attribute__ ((noinline))
+  #define SANITIZED_BUILD
+  #define RUNNING_ON_VALGRIND 1
  #else
   #define ATTRIBUTE_NO_ADDRESS_SAFETY_ANALYSIS
  #endif
  #endif
 #endif
 
+#if defined(WITH_VALGRIND) || defined(SANITIZED_BUILD)
 #ifdef WITH_VALGRIND
 #include <valgrind/valgrind.h>
+#endif
 
 /* If we're using GCC, use __builtin_expect() to reduce overhead of
    the valgrind checks */
@@ -794,7 +800,7 @@ PyObject_Malloc(size_t nbytes)
     poolp next;
     uint size;
 
-#ifdef WITH_VALGRIND
+#if defined(WITH_VALGRIND) || defined(SANITIZED_BUILD)
     if (UNLIKELY(running_on_valgrind == -1))
         running_on_valgrind = RUNNING_ON_VALGRIND;
     if (UNLIKELY(running_on_valgrind))
@@ -1004,7 +1010,7 @@ PyObject_Free(void *p)
     if (p == NULL)      /* free(NULL) has no effect */
         return;
 
-#ifdef WITH_VALGRIND
+#if defined(WITH_VALGRIND) || defined(SANITIZED_BUILD)
     if (UNLIKELY(running_on_valgrind > 0))
         goto redirect;
 #endif
@@ -1207,7 +1213,7 @@ PyObject_Free(void *p)
         return;
     }
 
-#ifdef WITH_VALGRIND
+#if defined(WITH_VALGRIND) || defined(SANITIZED_BUILD)
 redirect:
 #endif
     /* We didn't allocate this address. */
@@ -1243,7 +1249,7 @@ PyObject_Realloc(void *p, size_t nbytes)
     if (nbytes > PY_SSIZE_T_MAX)
         return NULL;
 
-#ifdef WITH_VALGRIND
+#if defined(WITH_VALGRIND) || defined(SANITIZED_BUILD)
     /* Treat running_on_valgrind == -1 the same as 0 */
     if (UNLIKELY(running_on_valgrind > 0))
         goto redirect;
@@ -1276,7 +1282,7 @@ PyObject_Realloc(void *p, size_t nbytes)
         }
         return bp;
     }
-#ifdef WITH_VALGRIND
+#if defined(WITH_VALGRIND) || defined(SANITIZED_BUILD)
  redirect:
 #endif
     /* We're not managing this block.  If nbytes <=