summaryrefslogtreecommitdiff
path: root/storage/innobase/include
diff options
context:
space:
mode:
authorEugene Kosov <claprix@yandex.ru>2019-07-19 13:25:46 +0300
committerEugene Kosov <claprix@yandex.ru>2019-07-19 13:28:03 +0300
commit53a3594b909a16dd57fa760ab6f729f0b7a19f41 (patch)
tree6c31c87d2786d0d7d12c7527e521f44fddcda3b2 /storage/innobase/include
parentd9dcb8ba029709cf447efd9237f6ad4834f0783a (diff)
downloadmariadb-git-53a3594b909a16dd57fa760ab6f729f0b7a19f41.tar.gz
MDEV-19471 Add ASAN-poisoned redzones for mem_heap_tbb-10.2-MDEV-19471-asan-mem_heap_t
Store REDZONE_SIZE poined bytes before every allocated chunk of memory
Diffstat (limited to 'storage/innobase/include')
-rw-r--r--storage/innobase/include/mem0mem.h2
-rw-r--r--storage/innobase/include/mem0mem.ic9
2 files changed, 8 insertions, 3 deletions
diff --git a/storage/innobase/include/mem0mem.h b/storage/innobase/include/mem0mem.h
index 61f36b81a72..0b291e6f365 100644
--- a/storage/innobase/include/mem0mem.h
+++ b/storage/innobase/include/mem0mem.h
@@ -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. */
diff --git a/storage/innobase/include/mem0mem.ic b/storage/innobase/include/mem0mem.ic
index 9b1e9a2da31..a44f2ff45fa 100644
--- a/storage/innobase/include/mem0mem.ic
+++ b/storage/innobase/include/mem0mem.ic
@@ -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 */