Skip to content

Commit

Permalink
MDEV-17799 Add ASAN-poisoned redzones for MEM_ROOT
Browse files Browse the repository at this point in the history
post-merge changes

Closes #954
  • Loading branch information
vuvova committed May 20, 2019
1 parent 7b59ec6 commit 5034b31
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions include/my_valgrind.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand All @@ -44,21 +45,21 @@
# 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 */

0 comments on commit 5034b31

Please sign in to comment.