From 33d1e7e957307243ba8cccdcdae3088a9ed80e16 Mon Sep 17 00:00:00 2001 From: Julian Seward Date: Sat, 12 Jul 2003 01:41:24 +0000 Subject: [PATCH] add_MAC_Chunk: mark shadow block as off-limits to the client so that the leak checker doesn't see the pointer to the real block. As detailed in the comment in this function, this must be masking a deeper memory management bug. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1750 --- memcheck/mac_malloc_wrappers.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/memcheck/mac_malloc_wrappers.c b/memcheck/mac_malloc_wrappers.c index 239f2c10f..42434de82 100644 --- a/memcheck/mac_malloc_wrappers.c +++ b/memcheck/mac_malloc_wrappers.c @@ -44,6 +44,13 @@ static UInt cmalloc_bs_mallocd = 0; /* We want a 16B redzone on heap blocks for Addrcheck and Memcheck */ UInt VG_(vg_malloc_redzone_szB) = 16; +/* Function pointers for the two skins to track interesting events. */ +void (*MAC_(new_mem_heap)) ( Addr a, UInt len, Bool is_inited ); +void (*MAC_(ban_mem_heap)) ( Addr a, UInt len ); +void (*MAC_(die_mem_heap)) ( Addr a, UInt len ); +void (*MAC_(copy_mem_heap))( Addr from, Addr to, UInt len ); + + /*------------------------------------------------------------*/ /*--- Tracking malloc'd and free'd blocks ---*/ /*------------------------------------------------------------*/ @@ -127,6 +134,14 @@ void add_MAC_Chunk ( ThreadState* tst, Addr p, UInt size, MAC_AllocKind kind ) mc->allockind = kind; mc->where = VG_(get_ExeContext)(tst); + /* The following line puts the shadow chunk, and hence the pointer + to the real chunk, off-limits to the client. This seems to be + necessary to make the leak checker work reliably. Problem is, + this seems to point to something deeper being wrong: this chunk + is allocated in the AR_SKIN arena and so should by default be + off-limits to the client anyway. */ + MAC_(ban_mem_heap)( (Addr)mc, sizeof(MAC_Chunk)); + VG_(HT_add_node)( MAC_(malloc_list), (VgHashNode*)mc ); } @@ -134,12 +149,6 @@ void add_MAC_Chunk ( ThreadState* tst, Addr p, UInt size, MAC_AllocKind kind ) /*--- client_malloc(), etc ---*/ /*------------------------------------------------------------*/ -/* Function pointers for the two skins to track interesting events. */ -void (*MAC_(new_mem_heap)) ( Addr a, UInt len, Bool is_inited ); -void (*MAC_(ban_mem_heap)) ( Addr a, UInt len ); -void (*MAC_(die_mem_heap)) ( Addr a, UInt len ); -void (*MAC_(copy_mem_heap))( Addr from, Addr to, UInt len ); - /* Allocate memory and note change in memory available */ __inline__ void MAC_(new_block) ( ThreadState* tst, Addr p, UInt size,