Skip to content

Commit d0c69cc

Browse files
MDEV-22911: Fix the valgrind & MSAN instrumentation of MDEV-8139
MEM_GET_VBITS(): Save information about uninitialized data. MEM_SET_VBITS(): Restore information about uninitialized data.
1 parent 72fc4f3 commit d0c69cc

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

include/my_valgrind.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@
3838
# define MEM_NOACCESS(a,len) VALGRIND_MAKE_MEM_NOACCESS(a,len)
3939
# define MEM_CHECK_ADDRESSABLE(a,len) VALGRIND_CHECK_MEM_IS_ADDRESSABLE(a,len)
4040
# define MEM_CHECK_DEFINED(a,len) VALGRIND_CHECK_MEM_IS_DEFINED(a,len)
41+
# define MEM_GET_VBITS(a,b,len) VALGRIND_GET_VBITS(a,b,len)
42+
# define MEM_SET_VBITS(a,b,len) VALGRIND_SET_VBITS(a,b,len)
4143
# define REDZONE_SIZE 8
4244
#elif defined(__SANITIZE_ADDRESS__)
4345
# include <sanitizer/asan_interface.h>
@@ -48,6 +50,8 @@
4850
# define MEM_NOACCESS(a,len) ASAN_POISON_MEMORY_REGION(a,len)
4951
# define MEM_CHECK_ADDRESSABLE(a,len) ((void) 0)
5052
# define MEM_CHECK_DEFINED(a,len) ((void) 0)
53+
# define MEM_GET_VBITS(a,b,len) ((void) 0)
54+
# define MEM_SET_VBITS(a,b,len) ((void) 0)
5155
# define REDZONE_SIZE 8
5256
#elif __has_feature(memory_sanitizer)
5357
# include <sanitizer/msan_interface.h>
@@ -57,13 +61,17 @@
5761
# define MEM_NOACCESS(a,len) ((void) 0)
5862
# define MEM_CHECK_ADDRESSABLE(a,len) ((void) 0)
5963
# define MEM_CHECK_DEFINED(a,len) __msan_check_mem_is_initialized(a,len)
64+
# define MEM_GET_VBITS(a,b,len) __msan_copy_shadow(b,a,len)
65+
# define MEM_SET_VBITS(a,b,len) __msan_copy_shadow(a,b,len)
6066
# define REDZONE_SIZE 8
6167
#else
6268
# define MEM_UNDEFINED(a,len) ((void) (a), (void) (len))
6369
# define MEM_MAKE_DEFINED(a,len) ((void) 0)
6470
# define MEM_NOACCESS(a,len) ((void) 0)
6571
# define MEM_CHECK_ADDRESSABLE(a,len) ((void) 0)
6672
# define MEM_CHECK_DEFINED(a,len) ((void) 0)
73+
# define MEM_GET_VBITS(a,b,len) ((void) 0)
74+
# define MEM_SET_VBITS(a,b,len) ((void) 0)
6775
# define REDZONE_SIZE 0
6876
#endif /* HAVE_VALGRIND_MEMCHECK_H */
6977

storage/innobase/mtr/mtr0mtr.cc

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -354,9 +354,12 @@ struct mtr_write_log_t {
354354
/** Start a mini-transaction. */
355355
void mtr_t::start()
356356
{
357-
MEM_CHECK_DEFINED(&m_freed_ranges, sizeof m_freed_ranges);
357+
#ifdef HAVE_valgrind_or_MSAN
358+
char m_freed_ranges_vbits[sizeof m_freed_ranges];
359+
#endif
360+
MEM_GET_VBITS(&m_freed_ranges, m_freed_ranges_vbits, sizeof m_freed_ranges);
358361
UNIV_MEM_INVALID(this, sizeof *this);
359-
UNIV_MEM_VALID(&m_freed_ranges, sizeof m_freed_ranges);
362+
MEM_SET_VBITS(&m_freed_ranges, m_freed_ranges_vbits, sizeof m_freed_ranges);
360363

361364
ut_d(m_start= true);
362365
ut_d(m_commit= false);

0 commit comments

Comments
 (0)