Skip to content

Commit bcb9ca4

Browse files
committed
MEM_CHECK_DEFINED: replace HAVE_valgrind
HAVE_valgrind_or_MSAN to HAVE_valgrind was incorrect in af78438. 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: af78438
1 parent e731a28 commit bcb9ca4

File tree

5 files changed

+12
-10
lines changed

5 files changed

+12
-10
lines changed

include/my_valgrind.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#if __has_feature(memory_sanitizer)
2828
# include <sanitizer/msan_interface.h>
2929
# define HAVE_valgrind
30+
# define HAVE_MEM_CHECK
3031
# define MEM_UNDEFINED(a,len) __msan_allocated_memory(a,len)
3132
# define MEM_MAKE_ADDRESSABLE(a,len) MEM_UNDEFINED(a,len)
3233
# define MEM_MAKE_DEFINED(a,len) __msan_unpoison(a,len)
@@ -38,6 +39,7 @@
3839
# define REDZONE_SIZE 8
3940
#elif defined(HAVE_VALGRIND_MEMCHECK_H) && defined(HAVE_valgrind)
4041
# include <valgrind/memcheck.h>
42+
# define HAVE_MEM_CHECK
4143
# define MEM_UNDEFINED(a,len) VALGRIND_MAKE_MEM_UNDEFINED(a,len)
4244
# define MEM_MAKE_ADDRESSABLE(a,len) MEM_UNDEFINED(a,len)
4345
# define MEM_MAKE_DEFINED(a,len) VALGRIND_MAKE_MEM_DEFINED(a,len)

sql/field.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7854,7 +7854,7 @@ bool Field_varstring::send(Protocol *protocol)
78547854
}
78557855

78567856

7857-
#ifdef HAVE_valgrind
7857+
#ifdef HAVE_MEM_CHECK
78587858
void Field_varstring::mark_unused_memory_as_defined()
78597859
{
78607860
uint used_length= get_length();

sql/field.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -998,7 +998,7 @@ class Field: public Value_source
998998
*/
999999
virtual int store_from_statistical_minmax_field(Field *field, String *str);
10001000

1001-
#ifdef HAVE_valgrind
1001+
#ifdef HAVE_MEM_CHECK
10021002
/**
10031003
Mark unused memory in the field as defined. Mainly used to ensure
10041004
that if we write full field to disk (for example in
@@ -4161,7 +4161,7 @@ class Field_varstring :public Field_longstr {
41614161
}
41624162
int store(const char *to,size_t length,CHARSET_INFO *charset) override;
41634163
using Field_str::store;
4164-
#ifdef HAVE_valgrind
4164+
#ifdef HAVE_MEM_CHECK
41654165
void mark_unused_memory_as_defined() override;
41664166
#endif
41674167
double val_real() override;

storage/innobase/include/srv0mon.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -637,14 +637,14 @@ Use MONITOR_DEC if appropriate mutex protection exists.
637637
} \
638638
}
639639

640-
#ifdef HAVE_valgrind
640+
#ifdef HAVE_MEM_CHECK
641641
# define MONITOR_CHECK_DEFINED(value) do { \
642642
mon_type_t m = value; \
643643
MEM_CHECK_DEFINED(&m, sizeof m); \
644644
} while (0)
645-
#else /* HAVE_valgrind */
645+
#else /* HAVE_MEM_CHECK */
646646
# define MONITOR_CHECK_DEFINED(value) (void) 0
647-
#endif /* HAVE_valgrind */
647+
#endif /* HAVE_MEM_CHECK */
648648

649649
#define MONITOR_INC_VALUE(monitor, value) \
650650
MONITOR_CHECK_DEFINED(value); \

storage/innobase/page/page0cur.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1311,7 +1311,7 @@ page_cur_insert_rec_low(
13111311
/* 1. Get the size of the physical record in the page */
13121312
const ulint rec_size= rec_offs_size(offsets);
13131313

1314-
#ifdef HAVE_valgrind
1314+
#ifdef HAVE_MEM_CHECK
13151315
{
13161316
const void *rec_start= rec - rec_offs_extra_size(offsets);
13171317
ulint extra_size= rec_offs_extra_size(offsets) -
@@ -1323,7 +1323,7 @@ page_cur_insert_rec_low(
13231323
/* The variable-length header must be valid. */
13241324
MEM_CHECK_DEFINED(rec_start, extra_size);
13251325
}
1326-
#endif /* HAVE_valgrind */
1326+
#endif /* HAVE_MEM_CHECK */
13271327

13281328
/* 2. Try to find suitable space from page memory management */
13291329
bool reuse= false;
@@ -1717,7 +1717,7 @@ page_cur_insert_rec_zip(
17171717
/* 1. Get the size of the physical record in the page */
17181718
const ulint rec_size= rec_offs_size(offsets);
17191719

1720-
#ifdef HAVE_valgrind
1720+
#ifdef HAVE_MEM_CHECK
17211721
{
17221722
const void *rec_start= rec - rec_offs_extra_size(offsets);
17231723
ulint extra_size= rec_offs_extra_size(offsets) - REC_N_NEW_EXTRA_BYTES;
@@ -1726,7 +1726,7 @@ page_cur_insert_rec_zip(
17261726
/* The variable-length header must be valid. */
17271727
MEM_CHECK_DEFINED(rec_start, extra_size);
17281728
}
1729-
#endif /* HAVE_valgrind */
1729+
#endif /* HAVE_MEM_CHECK */
17301730
const bool reorg_before_insert= page_has_garbage(cursor->block->frame) &&
17311731
rec_size > page_get_max_insert_size(cursor->block->frame, 1) &&
17321732
rec_size <= page_get_max_insert_size_after_reorganize(cursor->block->frame,

0 commit comments

Comments
 (0)