All pastes #389012 Raw Edit

kumbayo

public text v1 · immutable
·published 2007-03-10 13:32 UTC
rendered paste body
From e7c31ffacde9da2850d3470ec37c93c5358dfd12 Mon Sep 17 00:00:00 2001
From: Peter Oberndorfer <snip>
Date: Fri, 9 Mar 2007 22:50:24 +0100
Subject: [PATCH 1/1] ntdll: add heap_poison trace
MIME-Version: 1.0
Content-Type: multipart/mixed;
 boundary="------------1.5.0.2"

This is a multi-part message in MIME format.
--------------1.5.0.2
Content-Type: text/plain; charset=UTF-8; format=fixed
Content-Transfer-Encoding: 8bit
---
 dlls/ntdll/heap.c |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)
--------------1.5.0.2
Content-Type: text/x-patch;
 name="e7c31ffacde9da2850d3470ec37c93c5358dfd12.diff"
Content-Transfer-Encoding: 8bit
Content-Disposition: inline;
 filename="e7c31ffacde9da2850d3470ec37c93c5358dfd12.diff"

diff --git a/dlls/ntdll/heap.c b/dlls/ntdll/heap.c
index 7079054..b758223 100644
--- a/dlls/ntdll/heap.c
+++ b/dlls/ntdll/heap.c
@@ -43,6 +43,7 @@
 #include "wine/server.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(heap);
+WINE_DECLARE_DEBUG_CHANNEL(heap_poison);
 
 /* Note: the heap data structures are based on what Pietrek describes in his
  * book 'Windows 95 System Programming Secrets'. The layout is not exactly
@@ -137,7 +138,7 @@ static BOOL HEAP_IsRealArena( HEAP *heapPtr, DWORD flags, LPCVOID block, BOOL qu
 /* mark a block of memory as free for debugging purposes */
 static inline void mark_block_free( void *ptr, SIZE_T size )
 {
-    if (TRACE_ON(heap)) memset( ptr, ARENA_FREE_FILLER, size );
+    if (TRACE_ON(heap) || TRACE_ON(heap_poison)) memset( ptr, ARENA_FREE_FILLER, size );
 #ifdef VALGRIND_MAKE_NOACCESS
     VALGRIND_DISCARD( VALGRIND_MAKE_NOACCESS( ptr, size ));
 #endif
@@ -157,7 +158,7 @@ static inline void mark_block_uninitialized( void *ptr, SIZE_T size )
 #ifdef VALGRIND_MAKE_WRITABLE
     VALGRIND_DISCARD( VALGRIND_MAKE_WRITABLE( ptr, size ));
 #endif
-    if (TRACE_ON(heap))
+    if (TRACE_ON(heap) || TRACE_ON(heap_poison))
     {
         memset( ptr, ARENA_INUSE_FILLER, size );
 #ifdef VALGRIND_MAKE_WRITABLE
@@ -345,7 +346,7 @@ static HEAP *HEAP_GetPtr(
         ERR("Invalid heap %p!\n", heap );
         return NULL;
     }
-    if (TRACE_ON(heap) && !HEAP_IsRealArena( heapPtr, 0, NULL, NOISY ))
+    if ((TRACE_ON(heap)|| TRACE_ON(heap_poison)) && !HEAP_IsRealArena( heapPtr, 0, NULL, NOISY ))
     {
         HEAP_Dump( heapPtr );
         assert( FALSE );
@@ -645,6 +646,8 @@ static BOOL HEAP_InitSubHeap( HEAP *heap, LPVOID address, DWORD flags,
 
         if (!processHeap)  /* do it by hand to avoid memory allocations */
         {
+            if(TRACE_ON(heap_poison))
+                TRACE_(heap_poison)("poisioning heap\n");
             heap->critSection.DebugInfo      = &process_heap_critsect_debug;
             heap->critSection.LockCount      = -1;
             heap->critSection.RecursionCount = 0;

--------------1.5.0.2--