MEM_CHECK_DEFINED: replace HAVE_valgrind
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
This commit is contained in:
parent
e731a28394
commit
bcb9ca4105
@ -27,6 +27,7 @@
|
|||||||
#if __has_feature(memory_sanitizer)
|
#if __has_feature(memory_sanitizer)
|
||||||
# include <sanitizer/msan_interface.h>
|
# include <sanitizer/msan_interface.h>
|
||||||
# define HAVE_valgrind
|
# define HAVE_valgrind
|
||||||
|
# define HAVE_MEM_CHECK
|
||||||
# define MEM_UNDEFINED(a,len) __msan_allocated_memory(a,len)
|
# define MEM_UNDEFINED(a,len) __msan_allocated_memory(a,len)
|
||||||
# define MEM_MAKE_ADDRESSABLE(a,len) MEM_UNDEFINED(a,len)
|
# define MEM_MAKE_ADDRESSABLE(a,len) MEM_UNDEFINED(a,len)
|
||||||
# define MEM_MAKE_DEFINED(a,len) __msan_unpoison(a,len)
|
# define MEM_MAKE_DEFINED(a,len) __msan_unpoison(a,len)
|
||||||
@ -38,6 +39,7 @@
|
|||||||
# define REDZONE_SIZE 8
|
# define REDZONE_SIZE 8
|
||||||
#elif defined(HAVE_VALGRIND_MEMCHECK_H) && defined(HAVE_valgrind)
|
#elif defined(HAVE_VALGRIND_MEMCHECK_H) && defined(HAVE_valgrind)
|
||||||
# include <valgrind/memcheck.h>
|
# include <valgrind/memcheck.h>
|
||||||
|
# define HAVE_MEM_CHECK
|
||||||
# define MEM_UNDEFINED(a,len) VALGRIND_MAKE_MEM_UNDEFINED(a,len)
|
# define MEM_UNDEFINED(a,len) VALGRIND_MAKE_MEM_UNDEFINED(a,len)
|
||||||
# define MEM_MAKE_ADDRESSABLE(a,len) 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)
|
# define MEM_MAKE_DEFINED(a,len) VALGRIND_MAKE_MEM_DEFINED(a,len)
|
||||||
|
@ -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()
|
void Field_varstring::mark_unused_memory_as_defined()
|
||||||
{
|
{
|
||||||
uint used_length= get_length();
|
uint used_length= get_length();
|
||||||
|
@ -998,7 +998,7 @@ public:
|
|||||||
*/
|
*/
|
||||||
virtual int store_from_statistical_minmax_field(Field *field, String *str);
|
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
|
Mark unused memory in the field as defined. Mainly used to ensure
|
||||||
that if we write full field to disk (for example in
|
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;
|
int store(const char *to,size_t length,CHARSET_INFO *charset) override;
|
||||||
using Field_str::store;
|
using Field_str::store;
|
||||||
#ifdef HAVE_valgrind
|
#ifdef HAVE_MEM_CHECK
|
||||||
void mark_unused_memory_as_defined() override;
|
void mark_unused_memory_as_defined() override;
|
||||||
#endif
|
#endif
|
||||||
double val_real() override;
|
double val_real() override;
|
||||||
|
@ -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 { \
|
# define MONITOR_CHECK_DEFINED(value) do { \
|
||||||
mon_type_t m = value; \
|
mon_type_t m = value; \
|
||||||
MEM_CHECK_DEFINED(&m, sizeof m); \
|
MEM_CHECK_DEFINED(&m, sizeof m); \
|
||||||
} while (0)
|
} while (0)
|
||||||
#else /* HAVE_valgrind */
|
#else /* HAVE_MEM_CHECK */
|
||||||
# define MONITOR_CHECK_DEFINED(value) (void) 0
|
# define MONITOR_CHECK_DEFINED(value) (void) 0
|
||||||
#endif /* HAVE_valgrind */
|
#endif /* HAVE_MEM_CHECK */
|
||||||
|
|
||||||
#define MONITOR_INC_VALUE(monitor, value) \
|
#define MONITOR_INC_VALUE(monitor, value) \
|
||||||
MONITOR_CHECK_DEFINED(value); \
|
MONITOR_CHECK_DEFINED(value); \
|
||||||
|
@ -1311,7 +1311,7 @@ page_cur_insert_rec_low(
|
|||||||
/* 1. Get the size of the physical record in the page */
|
/* 1. Get the size of the physical record in the page */
|
||||||
const ulint rec_size= rec_offs_size(offsets);
|
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);
|
const void *rec_start= rec - rec_offs_extra_size(offsets);
|
||||||
ulint extra_size= 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. */
|
/* The variable-length header must be valid. */
|
||||||
MEM_CHECK_DEFINED(rec_start, extra_size);
|
MEM_CHECK_DEFINED(rec_start, extra_size);
|
||||||
}
|
}
|
||||||
#endif /* HAVE_valgrind */
|
#endif /* HAVE_MEM_CHECK */
|
||||||
|
|
||||||
/* 2. Try to find suitable space from page memory management */
|
/* 2. Try to find suitable space from page memory management */
|
||||||
bool reuse= false;
|
bool reuse= false;
|
||||||
@ -1717,7 +1717,7 @@ page_cur_insert_rec_zip(
|
|||||||
/* 1. Get the size of the physical record in the page */
|
/* 1. Get the size of the physical record in the page */
|
||||||
const ulint rec_size= rec_offs_size(offsets);
|
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);
|
const void *rec_start= rec - rec_offs_extra_size(offsets);
|
||||||
ulint extra_size= rec_offs_extra_size(offsets) - REC_N_NEW_EXTRA_BYTES;
|
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. */
|
/* The variable-length header must be valid. */
|
||||||
MEM_CHECK_DEFINED(rec_start, extra_size);
|
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) &&
|
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(cursor->block->frame, 1) &&
|
||||||
rec_size <= page_get_max_insert_size_after_reorganize(cursor->block->frame,
|
rec_size <= page_get_max_insert_size_after_reorganize(cursor->block->frame,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user