Skip to content

Commit

Permalink
add support for ASAN instrumentation
Browse files Browse the repository at this point in the history
  • Loading branch information
vuvova committed Jan 16, 2018
1 parent 6634f46 commit 5e7593a
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions include/my_valgrind.h
Expand Up @@ -25,7 +25,13 @@
# 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)
#else /* HAVE_VALGRIND */
#elif defined(__SANITIZE_ADDRESS__)
# include <sanitizer/asan_interface.h>
# define MEM_UNDEFINED(a,len) ASAN_UNPOISON_MEMORY_REGION(a,len)
# define MEM_NOACCESS(a,len) ASAN_POISON_MEMORY_REGION(a,len)

This comment has been minimized.

Copy link
@kevgs

kevgs Jan 19, 2018

Contributor

This looks like a dead code: I didn't find macro usage with grep.

This comment has been minimized.

Copy link
@dr-m

dr-m Jan 19, 2018

Contributor

In MySQL, MEM_NOACCESS is only used in unittest/gunit/sql_table-t.cc. I was the one who added MEM_NOACCESS to MySQL, in commit 525768d
I added some use of it to mysys/safemalloc.c but apparently that code was removed in commit f56dd32 due to performance reasons.

# define MEM_CHECK_ADDRESSABLE(a,len) ((void) 0)
# define MEM_CHECK_DEFINED(a,len) ((void) 0)
#else
# define MEM_UNDEFINED(a,len) ((void) 0)
# define MEM_NOACCESS(a,len) ((void) 0)
# define MEM_CHECK_ADDRESSABLE(a,len) ((void) 0)
Expand All @@ -35,9 +41,8 @@
#ifndef DBUG_OFF
#define TRASH_FILL(A,B,C) do { memset(A, C, B); MEM_UNDEFINED(A, B); } while (0)

This comment has been minimized.

Copy link
@kevgs

kevgs Jan 19, 2018

Contributor

Memory is unpoisoned here anyways. Or memset() would fail. You probably wanted to poison it here instead.

#else
#define TRASH_FILL(A,B,C) do{ MEM_CHECK_ADDRESSABLE(A,B);MEM_UNDEFINED(A,B);} while (0)
#define TRASH_FILL(A,B,C) do { MEM_CHECK_ADDRESSABLE(A,B);MEM_UNDEFINED(A,B);} while (0)
#endif
#define TRASH_ALLOC(A,B) TRASH_FILL(A,B,0xA5)
#define TRASH_FREE(A,B) TRASH_FILL(A,B,0x8F)
#define TRASH(A,B) TRASH_FREE(A,B)

0 comments on commit 5e7593a

Please sign in to comment.