Hi.

Following patch marks releases memory blocks as not accesible for valgrind.
That can help us in the future in order to catch memory corruptions.

Ready for trunk?
Martin

gcc/ChangeLog:

2018-09-21  Martin Liska  <mli...@suse.cz>

        * memory-block.h (memory_block_pool::release): Annotate with
        valgrind that the memory is not accessible.
---
 gcc/memory-block.h | 5 +++++
 1 file changed, 5 insertions(+)


diff --git a/gcc/memory-block.h b/gcc/memory-block.h
index 5440428240d..c045d2e95ab 100644
--- a/gcc/memory-block.h
+++ b/gcc/memory-block.h
@@ -68,6 +68,11 @@ memory_block_pool::release (void *uncast_block)
   block_list *block = new (uncast_block) block_list;
   block->m_next = instance.m_blocks;
   instance.m_blocks = block;
+
+  VALGRIND_DISCARD (VALGRIND_MAKE_MEM_NOACCESS ((char *)uncast_block
+						+ sizeof (block_list),
+						block_size
+						- sizeof (block_list)));
 }
 
 extern void *mempool_obstack_chunk_alloc (size_t) ATTRIBUTE_MALLOC;

Reply via email to