From 453dc4b300e0d595adb736fb555e62a42accfa2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Sat, 4 Jul 2020 22:02:30 +0300 Subject: [PATCH] Fixup the parent commit for MSAN and Valgrind commit 484931325e7bcecddc6daf1a55c008ddd67497e4 was a necessary fix for the buffer pool resizing tests in 10.5 in AddressSanitizer. However, that change would break the tests innodb.innodb_buffer_pool_resize and innodb.innodb_buffer_pool_resize_with_chunks when run in MemorySanitizer, or presumably in Valgrind as well. (Those tests run "forever" in Valgrind.) buf_pool_resize(): Cancel the effect of MEM_NOACCESS() in Valgrind and ASAN. In MSAN, MEM_NOACCESS() is a no-op, and hence we must do nothing special here. MEM_MAKE_ADDRESSABLE() would declare the memory contents undefined. In this particular case, we must actually declare the contents defined for Valgrind. --- storage/innobase/buf/buf0buf.cc | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/storage/innobase/buf/buf0buf.cc b/storage/innobase/buf/buf0buf.cc index c9cff9b3295..f2594725391 100644 --- a/storage/innobase/buf/buf0buf.cc +++ b/storage/innobase/buf/buf0buf.cc @@ -1622,7 +1622,7 @@ buf_chunk_init( return(NULL); } - MEM_MAKE_ADDRESSABLE(chunk->mem, chunk->mem_size()); + MEM_MAKE_ADDRESSABLE(chunk->mem, chunk->mem_size()); #ifdef HAVE_LIBNUMA if (srv_numa_interleave) { @@ -2910,8 +2910,21 @@ withdraw_retry: while (chunk < echunk) { buf_block_t* block = chunk->blocks; - MEM_MAKE_ADDRESSABLE(chunk->mem, - chunk->mem_size()); + /* buf_LRU_block_free_non_file_page() + invokes MEM_NOACCESS() on any blocks + that are in free_list. We must + cancel the effect of that. In MemorySanitizer, + MEM_NOACCESS() is no-op, so we must not do + anything special for it here. */ +#ifdef HAVE_valgrind +# if !__has_feature(memory_sanitizer) + MEM_MAKE_DEFINED(chunk->mem, + chunk->mem_size()); +# endif +#else + MEM_MAKE_ADDRESSABLE(chunk->mem, + chunk->mem_size()); +#endif for (ulint j = chunk->size; j--; block++) {