From 73bb34156f5655ed75112a9d7aa82d4cc96bc674 Mon Sep 17 00:00:00 2001 From: marko Date: Wed, 24 Jan 2007 11:41:19 +0000 Subject: [PATCH] branches/zip: Add UNIV_HASH_DEBUG for detecting multiple invocations of HASH_DELETE(). HASH_ASSERT_VALID(), HASH_INVALIDATE(): New macros, used in HASH_DELETE() and HASH_SEARCH(). buf_page_init_low(): Add HASH_INVALIDATE(bpage, hash); buf_page_init(): Call buf_page_init_low() before HASH_INSERT(), so that bpage->hash will not be invalidated. --- buf/buf0buf.c | 6 +++--- include/hash0hash.h | 12 ++++++++++++ include/univ.i | 1 + 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/buf/buf0buf.c b/buf/buf0buf.c index e9086409b4c..9a5eb296ad3 100644 --- a/buf/buf0buf.c +++ b/buf/buf0buf.c @@ -2028,9 +2028,9 @@ buf_page_init_low( bpage->io_fix = BUF_IO_NONE; bpage->buf_fix_count = 0; bpage->freed_page_clock = 0; - // bpage->hash = (buf_page_t*) -1; bpage->newest_modification = 0; bpage->oldest_modification = 0; + HASH_INVALIDATE(bpage, hash); #ifdef UNIV_DEBUG_FILE_ACCESSES bpage->file_page_was_freed = FALSE; #endif /* UNIV_DEBUG_FILE_ACCESSES */ @@ -2124,13 +2124,13 @@ buf_page_init( ut_error; } + buf_page_init_low(&block->page); + ut_ad(!block->page.in_zip_hash); ut_ad(!block->page.in_page_hash); ut_d(block->page.in_page_hash = TRUE); HASH_INSERT(buf_page_t, hash, buf_pool->page_hash, buf_page_address_fold(space, offset), &block->page); - - buf_page_init_low(&block->page); } /************************************************************************ diff --git a/include/hash0hash.h b/include/hash0hash.h index 3cb85d02c6d..7dc3fbdecef 100644 --- a/include/hash0hash.h +++ b/include/hash0hash.h @@ -98,6 +98,14 @@ do {\ }\ } while (0) +#ifdef UNIV_HASH_DEBUG +# define HASH_ASSERT_VALID(DATA) ut_a((void*) (DATA) != (void*) -1) +# define HASH_INVALIDATE(DATA, NAME) DATA->NAME = (void*) -1 +#else +# define HASH_ASSERT_VALID(DATA) do {} while (0) +# define HASH_INVALIDATE(DATA, NAME) do {} while (0) +#endif + /*********************************************************************** Deletes a struct from a hash table. */ @@ -111,6 +119,7 @@ do {\ cell3333 = hash_get_nth_cell(TABLE, hash_calc_hash(FOLD, TABLE));\ \ if (cell3333->node == DATA) {\ + HASH_ASSERT_VALID(DATA->NAME);\ cell3333->node = DATA->NAME;\ } else {\ struct3333 = cell3333->node;\ @@ -123,6 +132,7 @@ do {\ \ struct3333->NAME = DATA->NAME;\ }\ + HASH_INVALIDATE(DATA, NAME);\ } while (0) /*********************************************************************** @@ -144,11 +154,13 @@ Looks for a struct in a hash table. */ HASH_ASSERT_OWNED(TABLE, FOLD)\ \ (DATA) = HASH_GET_FIRST(TABLE, hash_calc_hash(FOLD, TABLE));\ + HASH_ASSERT_VALID(DATA);\ \ while ((DATA) != NULL) {\ if (TEST) {\ break;\ } else {\ + HASH_ASSERT_VALID(HASH_GET_NEXT(NAME, DATA));\ (DATA) = HASH_GET_NEXT(NAME, DATA);\ }\ }\ diff --git a/include/univ.i b/include/univ.i index 0451b467a43..dac4dfbf7c8 100644 --- a/include/univ.i +++ b/include/univ.i @@ -87,6 +87,7 @@ memory is read outside the allocated blocks. */ #define UNIV_DEBUG_FILE_ACCESSES /* Debug .ibd file access (field file_page_was_freed in buf_page_t) */ +#define UNIV_HASH_DEBUG /* debug HASH_ macros */ #define UNIV_LIST_DEBUG /* debug UT_LIST_ macros */ #define UNIV_MEM_DEBUG /* detect memory leaks etc */ #define UNIV_IBUF_DEBUG /* debug the insert buffer;