summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2022-03-14 09:28:55 +0200
committerMarko Mäkelä <marko.makela@mariadb.com>2022-03-14 09:28:55 +0200
commit59359fb44a6ddbed5d8d5487ec62da43db763299 (patch)
treea99f6d12e0350c89d2f629d8ee67ea0e14817c71 /include
parentd78173828e9f69ab3f6a406cb38f323261171076 (diff)
downloadmariadb-git-59359fb44a6ddbed5d8d5487ec62da43db763299.tar.gz
MDEV-24841 Build error with MSAN use-of-uninitialized-value in comp_err
The MemorySanitizer implementation in clang includes some built-in instrumentation (interceptors) for GNU libc. In GNU libc 2.33, the interface to the stat() family of functions was changed. Until the MemorySanitizer interceptors are adjusted, any MSAN code builds will act as if that the stat() family of functions failed to initialize the struct stat. A fix was applied in https://reviews.llvm.org/rG4e1a6c07052b466a2a1cd0c3ff150e4e89a6d87a but it fails to cover the 64-bit variants of the calls. For now, let us work around the MemorySanitizer bug by defining and using the macro MSAN_STAT_WORKAROUND().
Diffstat (limited to 'include')
-rw-r--r--include/my_valgrind.h10
1 files changed, 9 insertions, 1 deletions
diff --git a/include/my_valgrind.h b/include/my_valgrind.h
index 260521d4d4b..a24ad597d36 100644
--- a/include/my_valgrind.h
+++ b/include/my_valgrind.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 2010, 2020, MariaDB Corporation.
+/* Copyright (C) 2010, 2022, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -37,6 +37,11 @@
# define MEM_GET_VBITS(a,b,len) __msan_copy_shadow(b,a,len)
# define MEM_SET_VBITS(a,b,len) __msan_copy_shadow(a,b,len)
# define REDZONE_SIZE 8
+# ifdef __linux__
+# define MSAN_STAT_WORKAROUND(st) MEM_MAKE_DEFINED(st, sizeof(*st))
+# else
+# define MSAN_STAT_WORKAROUND(st) ((void) 0)
+# endif
#elif defined(HAVE_VALGRIND_MEMCHECK_H) && defined(HAVE_valgrind)
# include <valgrind/memcheck.h>
# define HAVE_MEM_CHECK
@@ -49,6 +54,7 @@
# define MEM_GET_VBITS(a,b,len) VALGRIND_GET_VBITS(a,b,len)
# define MEM_SET_VBITS(a,b,len) VALGRIND_SET_VBITS(a,b,len)
# define REDZONE_SIZE 8
+# define MSAN_STAT_WORKAROUND(st) ((void) 0)
#elif defined(__SANITIZE_ADDRESS__) && (!defined(_MSC_VER) || defined (__clang__))
# include <sanitizer/asan_interface.h>
/* How to do manual poisoning:
@@ -62,6 +68,7 @@ https://github.com/google/sanitizers/wiki/AddressSanitizerManualPoisoning */
# define MEM_CHECK_DEFINED(a,len) ((void) 0)
# define MEM_GET_VBITS(a,b,len) ((void) 0)
# define MEM_SET_VBITS(a,b,len) ((void) 0)
+# define MSAN_STAT_WORKAROUND(st) ((void) 0)
# define REDZONE_SIZE 8
#else
# define MEM_UNDEFINED(a,len) ((void) 0)
@@ -73,6 +80,7 @@ https://github.com/google/sanitizers/wiki/AddressSanitizerManualPoisoning */
# define MEM_GET_VBITS(a,b,len) ((void) 0)
# define MEM_SET_VBITS(a,b,len) ((void) 0)
# define REDZONE_SIZE 0
+# define MSAN_STAT_WORKAROUND(st) ((void) 0)
#endif /* __has_feature(memory_sanitizer) */
#ifdef HAVE_valgrind