From 7b59ec6f345986db0cbc6f8b1d504a6e7e21cb5f Mon Sep 17 00:00:00 2001 From: Eugene Kosov Date: Wed, 28 Nov 2018 13:25:43 +0300 Subject: MDEV-17799 Add ASAN-poisoned redzones for MEM_ROOT and mem_heap_t This patch is for MEM_ROOT only. In debug mode add 8 byte of poisoned memory before every allocated chunk. On the right of every chunk there will be either 1-7 trailing poisoned bytes, or next chunk's redzone, or poisoned non allocated memory or redzone of a malloc()ed buffer. --- mysys/my_alloc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'mysys/my_alloc.c') diff --git a/mysys/my_alloc.c b/mysys/my_alloc.c index 15b96e8a20a..9e5b6809dea 100644 --- a/mysys/my_alloc.c +++ b/mysys/my_alloc.c @@ -197,7 +197,7 @@ void *alloc_root(MEM_ROOT *mem_root, size_t length) DBUG_SET("-d,simulate_out_of_memory"); DBUG_RETURN((void*) 0); /* purecov: inspected */ }); - length= ALIGN_SIZE(length); + length= ALIGN_SIZE(length) + REDZONE_SIZE; if ((*(prev= &mem_root->free)) != NULL) { if ((*prev)->left < length && @@ -242,6 +242,7 @@ void *alloc_root(MEM_ROOT *mem_root, size_t length) mem_root->used= next; mem_root->first_block_usage= 0; } + point+= REDZONE_SIZE; TRASH_ALLOC(point, original_length); DBUG_PRINT("exit",("ptr: 0x%lx", (ulong) point)); DBUG_RETURN((void*) point); -- cgit v1.2.1