diff options
Diffstat (limited to 'innobase/mem')
-rw-r--r-- | innobase/mem/mem0dbg.c | 51 | ||||
-rw-r--r-- | innobase/mem/mem0mem.c | 34 | ||||
-rw-r--r-- | innobase/mem/mem0pool.c | 21 |
3 files changed, 62 insertions, 44 deletions
diff --git a/innobase/mem/mem0dbg.c b/innobase/mem/mem0dbg.c index 6c97ef9eb8e..5ace0441180 100644 --- a/innobase/mem/mem0dbg.c +++ b/innobase/mem/mem0dbg.c @@ -20,7 +20,7 @@ Protected by mem_hash_mutex above. */ static ulint mem_n_created_heaps = 0; static ulint mem_n_allocations = 0; static ulint mem_total_allocated_memory = 0; -ulint mem_current_allocated_memory = 0; +ulint mem_current_allocated_memory = 0; static ulint mem_max_allocated_memory = 0; /* Size of the hash table for memory management tracking */ @@ -338,7 +338,7 @@ mem_hash_remove( if (node == NULL) { fprintf(stderr, "Memory heap or buffer freed in %s line %lu did not exist.\n", - file_name, line); + file_name, (ulong) line); ut_error; } @@ -355,15 +355,13 @@ mem_hash_remove( "Inconsistency in memory heap or buffer n:o %lu created\n" "in %s line %lu and tried to free in %s line %lu.\n" "Hex dump of 400 bytes around memory heap first block start:\n", - node->nth_heap, node->file_name, node->line, - file_name, line); + node->nth_heap, node->file_name, (ulong) node->line, + file_name, (ulong) line); ut_print_buf(stderr, (byte*)node->heap - 200, 400); - fputs("\nDump of the mem heap:\n", stderr); - mem_heap_validate_or_print(node->heap, NULL, TRUE, &error, - &size, NULL, NULL); - ut_error; + &size, NULL, NULL); + ut_error; } /* Free the memory occupied by the node struct */ @@ -446,6 +444,9 @@ mem_heap_validate_or_print( if ((block->type == MEM_HEAP_BUFFER) && (mem_block_get_len(block) > UNIV_PAGE_SIZE)) { + fprintf(stderr, +"InnoDB: Error: mem block %lx length %lu > UNIV_PAGE_SIZE\n", (ulong) block, + (ulong) mem_block_get_len(block)); /* error */ return; @@ -485,6 +486,12 @@ mem_heap_validate_or_print( mem_field_trailer_get_check(user_field)) { /* error */ + fprintf(stderr, +"InnoDB: Error: block %lx mem field %lx len %lu\n" +"InnoDB: header check field is %lx but trailer %lx\n", (ulint)block, + (ulint)field, len, check_field, + mem_field_trailer_get_check(user_field)); + return; } @@ -504,6 +511,11 @@ mem_heap_validate_or_print( if (field != (byte*)block + mem_block_get_free(block)) { /* error */ + fprintf(stderr, +"InnoDB: Error: block %lx end of mem fields %lx\n" +"InnoDB: but block free at %lx\n", (ulint)block, (ulint)field, + (ulint)((byte*)block + mem_block_get_free(block))); + return; } @@ -546,7 +558,8 @@ mem_heap_print( &us_size, &phys_size, &n_blocks); fprintf(stderr, "\nheap type: %lu; size: user size %lu; physical size %lu; blocks %lu.\n", - heap->type, us_size, phys_size, n_blocks); + (ulong) heap->type, (ulong) us_size, + (ulong) phys_size, (ulong) n_blocks); ut_a(!error); } @@ -582,6 +595,10 @@ mem_heap_validate( mem_heap_validate_or_print(heap, NULL, FALSE, &error, &us_size, &phys_size, &n_blocks); + if (error) { + mem_heap_print(heap); + } + ut_a(!error); return(TRUE); @@ -738,8 +755,8 @@ mem_analyze_corruption( if (*((ulint*)p) == MEM_BLOCK_MAGIC_N) { fprintf(stderr, "Mem block at - %lu, file %s, line %lu\n", - dist, p + sizeof(ulint), - *(ulint*)(p + 8 + sizeof(ulint))); + (ulong) dist, (p + sizeof(ulint)), + (ulong) (*(ulint*)(p + 8 + sizeof(ulint)))); break; } @@ -747,8 +764,8 @@ mem_analyze_corruption( if (*((ulint*)p) == MEM_FREED_BLOCK_MAGIC_N) { fprintf(stderr, "Freed mem block at - %lu, file %s, line %lu\n", - dist, p + sizeof(ulint), - *(ulint*)(p + 8 + sizeof(ulint))); + (ulong) dist, (p + sizeof(ulint)), + (ulong) (*(ulint*)(p + 8 + sizeof(ulint)))); break; } @@ -775,8 +792,8 @@ mem_analyze_corruption( if (*((ulint*)p) == MEM_BLOCK_MAGIC_N) { fprintf(stderr, "Mem block at + %lu, file %s, line %lu\n", - dist, p + sizeof(ulint), - *(ulint*)(p + 8 + sizeof(ulint))); + (ulong) dist, (p + sizeof(ulint)), + (ulong) (*(ulint*)(p + 8 + sizeof(ulint)))); break; } @@ -784,8 +801,8 @@ mem_analyze_corruption( if (*((ulint*)p) == MEM_FREED_BLOCK_MAGIC_N) { fprintf(stderr, "Freed mem block at + %lu, file %s, line %lu\n", - dist, p + sizeof(ulint), - *(ulint*)(p + 8 + sizeof(ulint))); + (ulong) dist, (p + sizeof(ulint)), + (ulong) (*(ulint*)(p + 8 + sizeof(ulint)))); break; } diff --git a/innobase/mem/mem0mem.c b/innobase/mem/mem0mem.c index e1b9a762381..c090b25a632 100644 --- a/innobase/mem/mem0mem.c +++ b/innobase/mem/mem0mem.c @@ -92,11 +92,11 @@ with mem_free. */ void* mem_alloc_func_noninline( /*=====================*/ - /* out, own: free storage, NULL if did not - succeed */ - ulint n, /* in: desired number of bytes */ - char* file_name, /* in: file name where created */ - ulint line /* in: line where created */ + /* out, own: free storage, + NULL if did not succeed */ + ulint n, /* in: desired number of bytes */ + const char* file_name, /* in: file name where created */ + ulint line /* in: line where created */ ) { return(mem_alloc_func(n, file_name, line)); @@ -108,18 +108,18 @@ Creates a memory heap block where data can be allocated. */ mem_block_t* mem_heap_create_block( /*==================*/ - /* out, own: memory heap block, NULL if did not - succeed */ - mem_heap_t* heap,/* in: memory heap or NULL if first block should - be created */ - ulint n, /* in: number of bytes needed for user data, or - if init_block is not NULL, its size in bytes */ - void* init_block, /* in: init block in fast create, type must be - MEM_HEAP_DYNAMIC */ - ulint type, /* in: type of heap: MEM_HEAP_DYNAMIC, or - MEM_HEAP_BUFFER possibly ORed to MEM_HEAP_BTR_SEARCH */ - char* file_name,/* in: file name where created */ - ulint line) /* in: line where created */ + /* out, own: memory heap block, + NULL if did not succeed */ + mem_heap_t* heap, /* in: memory heap or NULL if first block + should be created */ + ulint n, /* in: number of bytes needed for user data, or + if init_block is not NULL, its size in bytes */ + void* init_block, /* in: init block in fast create, + type must be MEM_HEAP_DYNAMIC */ + ulint type, /* in: type of heap: MEM_HEAP_DYNAMIC or + MEM_HEAP_BUFFER */ + const char* file_name,/* in: file name where created */ + ulint line) /* in: line where created */ { mem_block_t* block; ulint len; diff --git a/innobase/mem/mem0pool.c b/innobase/mem/mem0pool.c index d77432a1e20..0227c2d0969 100644 --- a/innobase/mem/mem0pool.c +++ b/innobase/mem/mem0pool.c @@ -277,7 +277,8 @@ mem_pool_fill_free_list( fprintf(stderr, " InnoDB: Error: mem pool free list %lu length is %lu\n" "InnoDB: though the list is empty!\n", - i + 1, UT_LIST_GET_LEN(pool->free_list[i + 1])); + (ulong) i + 1, + (ulong) UT_LIST_GET_LEN(pool->free_list[i + 1])); } ret = mem_pool_fill_free_list(i + 1, pool); @@ -358,7 +359,7 @@ mem_area_alloc( fprintf(stderr, "InnoDB: Error: Removing element from mem pool free list %lu though the\n" "InnoDB: element is not marked free!\n", - n); + (ulong) n); mem_analyze_corruption((byte*)area); @@ -378,7 +379,7 @@ mem_area_alloc( fprintf(stderr, "InnoDB: Error: Removing element from mem pool free list %lu\n" "InnoDB: though the list length is 0!\n", - n); + (ulong) n); mem_analyze_corruption((byte*)area); ut_error; @@ -498,7 +499,7 @@ mem_area_free( fprintf(stderr, "InnoDB: Error: Memory area size %lu, next area size %lu not a power of 2!\n" "InnoDB: Possibly a memory overrun of the buffer being freed here.\n", - size, next_size); + (ulong) size, (ulong) next_size); mem_analyze_corruption((byte*)area); ut_error; @@ -598,8 +599,8 @@ mem_pool_validate( } } - ut_a(free + pool->reserved == pool->size - - (pool->size % MEM_AREA_MIN_SIZE)); + ut_a(free + pool->reserved == pool->size); + mutex_exit(&(pool->mutex)); return(TRUE); @@ -627,13 +628,13 @@ mem_pool_print_info( fprintf(outfile, "Free list length %lu for blocks of size %lu\n", - UT_LIST_GET_LEN(pool->free_list[i]), - ut_2_exp(i)); + (ulong) UT_LIST_GET_LEN(pool->free_list[i]), + (ulong) ut_2_exp(i)); } } - fprintf(outfile, "Pool size %lu, reserved %lu.\n", pool->size, - pool->reserved); + fprintf(outfile, "Pool size %lu, reserved %lu.\n", (ulong) pool->size, + (ulong) pool->reserved); mutex_exit(&(pool->mutex)); } #endif /* UNIV_DEBUG */ |