summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Black <daniel@mariadb.org>2021-03-23 18:16:20 +1100
committerDaniel Black <daniel@mariadb.org>2021-03-26 07:58:49 +1100
commitbcb9ca41053aa3db8d4d04d9d11dcd176b1a23e9 (patch)
treef99837b5dfaf1dd0b40ebda05739ba73e4381bfc
parente731a283942c3ec2386d79b639317131645caa1e (diff)
downloadmariadb-git-bb-10.5-danielblack-clang-valgrind-without-memcheck_h.tar.gz
MEM_CHECK_DEFINED: replace HAVE_valgrindbb-10.5-danielblack-clang-valgrind-without-memcheck_h
HAVE_valgrind_or_MSAN to HAVE_valgrind was incorrect in af784385b4a2b286000fa2c658e34283fe7bba60. In my_valgrind.h when clang exists (hence no __has_feature(memory_sanitizer), and -DWITH_VALGRIND=1, but without memcheck.h, we end up with a MEM_CHECK_DEFINED being empty. If we are also doing a CMAKE_BUILD_TYPE=Debug this results a number of [-Werror,-Wunused-variable] errors because MEM_CHECK_DEFINED is empty. With MEM_CHECK_DEFINED empty, there becomes no uses of this of the fixed field and innodb variables in this patch. So we stop using HAVE_valgrind as catchall and use the name HAVE_CHECK_MEM to indicate that a CHECK_MEM_DEFINED function exists. Reviewer: Monty Corrects: af784385b4a2b286000fa2c658e34283fe7bba60
-rw-r--r--include/my_valgrind.h2
-rw-r--r--sql/field.cc2
-rw-r--r--sql/field.h4
-rw-r--r--storage/innobase/include/srv0mon.h6
-rw-r--r--storage/innobase/page/page0cur.cc8
5 files changed, 12 insertions, 10 deletions
diff --git a/include/my_valgrind.h b/include/my_valgrind.h
index daea5266a28..260521d4d4b 100644
--- a/include/my_valgrind.h
+++ b/include/my_valgrind.h
@@ -27,6 +27,7 @@
#if __has_feature(memory_sanitizer)
# include <sanitizer/msan_interface.h>
# define HAVE_valgrind
+# define HAVE_MEM_CHECK
# define MEM_UNDEFINED(a,len) __msan_allocated_memory(a,len)
# define MEM_MAKE_ADDRESSABLE(a,len) MEM_UNDEFINED(a,len)
# define MEM_MAKE_DEFINED(a,len) __msan_unpoison(a,len)
@@ -38,6 +39,7 @@
# define REDZONE_SIZE 8
#elif defined(HAVE_VALGRIND_MEMCHECK_H) && defined(HAVE_valgrind)
# include <valgrind/memcheck.h>
+# define HAVE_MEM_CHECK
# define MEM_UNDEFINED(a,len) VALGRIND_MAKE_MEM_UNDEFINED(a,len)
# define MEM_MAKE_ADDRESSABLE(a,len) MEM_UNDEFINED(a,len)
# define MEM_MAKE_DEFINED(a,len) VALGRIND_MAKE_MEM_DEFINED(a,len)
diff --git a/sql/field.cc b/sql/field.cc
index 52074417046..5ea43df1a7e 100644
--- a/sql/field.cc
+++ b/sql/field.cc
@@ -7854,7 +7854,7 @@ bool Field_varstring::send(Protocol *protocol)
}
-#ifdef HAVE_valgrind
+#ifdef HAVE_MEM_CHECK
void Field_varstring::mark_unused_memory_as_defined()
{
uint used_length= get_length();
diff --git a/sql/field.h b/sql/field.h
index 4a4f7cee2a5..8eacf75844a 100644
--- a/sql/field.h
+++ b/sql/field.h
@@ -998,7 +998,7 @@ public:
*/
virtual int store_from_statistical_minmax_field(Field *field, String *str);
-#ifdef HAVE_valgrind
+#ifdef HAVE_MEM_CHECK
/**
Mark unused memory in the field as defined. Mainly used to ensure
that if we write full field to disk (for example in
@@ -4161,7 +4161,7 @@ public:
}
int store(const char *to,size_t length,CHARSET_INFO *charset) override;
using Field_str::store;
-#ifdef HAVE_valgrind
+#ifdef HAVE_MEM_CHECK
void mark_unused_memory_as_defined() override;
#endif
double val_real() override;
diff --git a/storage/innobase/include/srv0mon.h b/storage/innobase/include/srv0mon.h
index 20365ffc7a7..77a90b0c84a 100644
--- a/storage/innobase/include/srv0mon.h
+++ b/storage/innobase/include/srv0mon.h
@@ -637,14 +637,14 @@ Use MONITOR_DEC if appropriate mutex protection exists.
} \
}
-#ifdef HAVE_valgrind
+#ifdef HAVE_MEM_CHECK
# define MONITOR_CHECK_DEFINED(value) do { \
mon_type_t m = value; \
MEM_CHECK_DEFINED(&m, sizeof m); \
} while (0)
-#else /* HAVE_valgrind */
+#else /* HAVE_MEM_CHECK */
# define MONITOR_CHECK_DEFINED(value) (void) 0
-#endif /* HAVE_valgrind */
+#endif /* HAVE_MEM_CHECK */
#define MONITOR_INC_VALUE(monitor, value) \
MONITOR_CHECK_DEFINED(value); \
diff --git a/storage/innobase/page/page0cur.cc b/storage/innobase/page/page0cur.cc
index cb4293f998a..5e751010f44 100644
--- a/storage/innobase/page/page0cur.cc
+++ b/storage/innobase/page/page0cur.cc
@@ -1311,7 +1311,7 @@ page_cur_insert_rec_low(
/* 1. Get the size of the physical record in the page */
const ulint rec_size= rec_offs_size(offsets);
-#ifdef HAVE_valgrind
+#ifdef HAVE_MEM_CHECK
{
const void *rec_start= rec - rec_offs_extra_size(offsets);
ulint extra_size= rec_offs_extra_size(offsets) -
@@ -1323,7 +1323,7 @@ page_cur_insert_rec_low(
/* The variable-length header must be valid. */
MEM_CHECK_DEFINED(rec_start, extra_size);
}
-#endif /* HAVE_valgrind */
+#endif /* HAVE_MEM_CHECK */
/* 2. Try to find suitable space from page memory management */
bool reuse= false;
@@ -1717,7 +1717,7 @@ page_cur_insert_rec_zip(
/* 1. Get the size of the physical record in the page */
const ulint rec_size= rec_offs_size(offsets);
-#ifdef HAVE_valgrind
+#ifdef HAVE_MEM_CHECK
{
const void *rec_start= rec - rec_offs_extra_size(offsets);
ulint extra_size= rec_offs_extra_size(offsets) - REC_N_NEW_EXTRA_BYTES;
@@ -1726,7 +1726,7 @@ page_cur_insert_rec_zip(
/* The variable-length header must be valid. */
MEM_CHECK_DEFINED(rec_start, extra_size);
}
-#endif /* HAVE_valgrind */
+#endif /* HAVE_MEM_CHECK */
const bool reorg_before_insert= page_has_garbage(cursor->block->frame) &&
rec_size > page_get_max_insert_size(cursor->block->frame, 1) &&
rec_size <= page_get_max_insert_size_after_reorganize(cursor->block->frame,