]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
add_MAC_Chunk: mark shadow block as off-limits to the client so that
authorJulian Seward <jseward@acm.org>
Sat, 12 Jul 2003 01:41:24 +0000 (01:41 +0000)
committerJulian Seward <jseward@acm.org>
Sat, 12 Jul 2003 01:41:24 +0000 (01:41 +0000)
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

index 239f2c10f3c26ff192f6019f57c768cba6ab637f..42434de82026ebb72d4dabe4383618212a245b44 100644 (file)
@@ -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,