From 5034b31b01b790ce1c28159402d754f7f951edc5 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Mon, 20 May 2019 18:23:10 +0200 Subject: MDEV-17799 Add ASAN-poisoned redzones for MEM_ROOT post-merge changes Closes #954 --- include/my_valgrind.h | 11 ++++++----- 1 file 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 /* 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 */ -- cgit v1.2.1