Commit ff0acd76 authored by marko's avatar marko

branches/zip: Instrument the buffer pool allocator and deallocator

for more accurate Valgrind debugging.

univ.i: Introduce UNIV_DEBUG_VALGRIND, UNIV_MEM_VALID, and UNIV_MEM_INVALID.

buf_LRU_block_free_non_file_page(): Invalidate the buffer frame
with UNIV_MEM_INVALID().

buf_LRU_get_free_block(): Declare the buffer frame valid
with UNIV_MEM_VALID().

Other memory is allocated and deallocated via malloc() and free(),
which are already overridden by Valgrind.  Without the added
instrumentation, accesses to free pages in the buffer pool cannot
be caught.

The diagnostics could probably be improved further by declaring all
non-latched buffer frames invalid.
parent 3b03315f
......@@ -448,6 +448,7 @@ buf_LRU_get_free_block(
}
block->state = BUF_BLOCK_READY_FOR_USE;
UNIV_MEM_VALID(block->frame, UNIV_PAGE_SIZE);
mutex_exit(&(buf_pool->mutex));
......@@ -881,6 +882,9 @@ buf_LRU_block_free_non_file_page(
UT_LIST_ADD_FIRST(awe_LRU_free_mapped,
buf_pool->awe_LRU_free_mapped, block);
UNIV_MEM_INVALID(block->frame, UNIV_PAGE_SIZE);
} else {
UNIV_MEM_INVALID(block->frame, UNIV_PAGE_SIZE);
}
}
......
......@@ -83,6 +83,7 @@ memory is read outside the allocated blocks. */
/* Make a non-inline debug version */
#if 0
#define UNIV_DEBUG_VALGRIND
#define UNIV_DEBUG_PRINT
#define UNIV_DEBUG
#define UNIV_MEM_DEBUG
......@@ -292,5 +293,13 @@ typedef void* os_thread_ret_t;
#include "ut0dbg.h"
#include "ut0ut.h"
#include "db0err.h"
#ifdef UNIV_DEBUG_VALGRIND
# include <valgrind/memcheck.h>
# define UNIV_MEM_VALID(addr, size) VALGRIND_MAKE_MEM_DEFINED(addr, size)
# define UNIV_MEM_INVALID(addr, size) VALGRIND_MAKE_MEM_UNDEFINED(addr, size)
#else
# define UNIV_MEM_VALID(addr, size) do {} while(0)
# define UNIV_MEM_INVALID(addr, size) do {} while(0)
#endif
#endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment