summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2019-05-20 18:23:10 +0200
committerSergei Golubchik <serg@mariadb.org>2019-05-20 18:24:49 +0200
commit5034b31b01b790ce1c28159402d754f7f951edc5 (patch)
tree47cb6da617775cb8bc7065b1504a49785682f3bb
parent7b59ec6f345986db0cbc6f8b1d504a6e7e21cb5f (diff)
downloadmariadb-git-5034b31b01b790ce1c28159402d754f7f951edc5.tar.gz
MDEV-17799 Add ASAN-poisoned redzones for MEM_ROOT
post-merge changes Closes #954
-rw-r--r--include/my_valgrind.h11
1 files changed, 6 insertions, 5 deletions
diff --git a/include/my_valgrind.h b/include/my_valgrind.h
index 14db2af2cb3..ad22f0cad40 100644
--- a/include/my_valgrind.h
+++ b/include/my_valgrind.h
@@ -13,8 +13,8 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */
-#ifndef _my_valgrind_h
-#define _my_valgrind_h
+#ifndef MY_VALGRIND_INCLUDED
+#define MY_VALGRIND_INCLUDED
/* clang -> gcc */
#ifndef __has_feature
@@ -36,6 +36,7 @@
# define MEM_NOACCESS(a,len) VALGRIND_MAKE_MEM_NOACCESS(a,len)
# define MEM_CHECK_ADDRESSABLE(a,len) VALGRIND_CHECK_MEM_IS_ADDRESSABLE(a,len)
# define MEM_CHECK_DEFINED(a,len) VALGRIND_CHECK_MEM_IS_DEFINED(a,len)
+# define REDZONE_SIZE 8
#elif defined(__SANITIZE_ADDRESS__)
# include <sanitizer/asan_interface.h>
/* How to do manual poisoning:
@@ -44,21 +45,21 @@ https://github.com/google/sanitizers/wiki/AddressSanitizerManualPoisoning */
# define MEM_NOACCESS(a,len) ASAN_POISON_MEMORY_REGION(a,len)
# define MEM_CHECK_ADDRESSABLE(a,len) ((void) 0)
# define MEM_CHECK_DEFINED(a,len) ((void) 0)
+# define REDZONE_SIZE 8
#else
# define MEM_UNDEFINED(a,len) ((void) (a), (void) (len))
# define MEM_NOACCESS(a,len) ((void) 0)
# define MEM_CHECK_ADDRESSABLE(a,len) ((void) 0)
# define MEM_CHECK_DEFINED(a,len) ((void) 0)
+# define REDZONE_SIZE 0
#endif /* HAVE_VALGRIND */
#ifndef DBUG_OFF
-static const size_t REDZONE_SIZE= 8;
#define TRASH_FILL(A,B,C) do { const size_t trash_tmp= (B); MEM_UNDEFINED(A, trash_tmp); memset(A, C, trash_tmp); } while (0)
#else
-static const size_t REDZONE_SIZE= 0;
#define TRASH_FILL(A,B,C) do { MEM_UNDEFINED((A), (B)); } while (0)
#endif
#define TRASH_ALLOC(A,B) do { TRASH_FILL(A,B,0xA5); MEM_UNDEFINED(A,B); } while(0)
#define TRASH_FREE(A,B) do { TRASH_FILL(A,B,0x8F); MEM_NOACCESS(A,B); } while(0)
-#endif /* _my_valgrind_h */
+#endif /* MY_VALGRIND_INCLUDED */