mirror of
https://github.com/MariaDB/server.git
synced 2026-05-15 19:37:16 +02:00
MDEV-19471 Add ASAN-poisoned redzones for mem_heap_t
Store REDZONE_SIZE poined bytes before every allocated chunk of memory
This commit is contained in:
parent
d9dcb8ba02
commit
53a3594b90
3 changed files with 9 additions and 4 deletions
|
|
@ -73,7 +73,7 @@ allocations of small buffers. */
|
|||
|
||||
/** If a memory heap is allowed to grow into the buffer pool, the following
|
||||
is the maximum size for a single allocated buffer: */
|
||||
#define MEM_MAX_ALLOC_IN_BUF (UNIV_PAGE_SIZE - 200)
|
||||
#define MEM_MAX_ALLOC_IN_BUF (UNIV_PAGE_SIZE - 200 + REDZONE_SIZE)
|
||||
|
||||
/** Space needed when allocating for a user a field of length N.
|
||||
The space is allocated only in multiples of UNIV_MEM_ALIGNMENT. */
|
||||
|
|
|
|||
|
|
@ -183,13 +183,15 @@ mem_heap_alloc(
|
|||
ulint n)
|
||||
{
|
||||
mem_block_t* block;
|
||||
void* buf;
|
||||
byte* buf;
|
||||
ulint free;
|
||||
|
||||
ut_d(mem_block_validate(heap));
|
||||
|
||||
block = UT_LIST_GET_LAST(heap->base);
|
||||
|
||||
n += REDZONE_SIZE;
|
||||
|
||||
ut_ad(!(block->type & MEM_HEAP_BUFFER) || (n <= MEM_MAX_ALLOC_IN_BUF));
|
||||
|
||||
/* Check if there is enough space in block. If not, create a new
|
||||
|
|
@ -212,7 +214,8 @@ mem_heap_alloc(
|
|||
|
||||
mem_block_set_free(block, free + MEM_SPACE_NEEDED(n));
|
||||
|
||||
UNIV_MEM_ALLOC(buf, n);
|
||||
buf = buf + REDZONE_SIZE;
|
||||
UNIV_MEM_ALLOC(buf, n - REDZONE_SIZE);
|
||||
return(buf);
|
||||
}
|
||||
|
||||
|
|
@ -341,6 +344,8 @@ mem_heap_free_top(
|
|||
|
||||
ut_d(mem_block_validate(heap));
|
||||
|
||||
n += REDZONE_SIZE;
|
||||
|
||||
block = UT_LIST_GET_LAST(heap->base);
|
||||
|
||||
/* Subtract the free field of block */
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ Created 9/20/1997 Heikki Tuuri
|
|||
|
||||
/** Log records are stored in the hash table in chunks at most of this size;
|
||||
this must be less than UNIV_PAGE_SIZE as it is stored in the buffer pool */
|
||||
#define RECV_DATA_BLOCK_SIZE (MEM_MAX_ALLOC_IN_BUF - sizeof(recv_data_t))
|
||||
#define RECV_DATA_BLOCK_SIZE (MEM_MAX_ALLOC_IN_BUF - sizeof(recv_data_t) - REDZONE_SIZE)
|
||||
|
||||
/** Read-ahead area in applying log records to file pages */
|
||||
#define RECV_READ_AHEAD_AREA 32
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue