Author: cgutman
Date: Tue Jun 30 06:30:36 2009
New Revision: 41705
URL:
http://svn.reactos.org/svn/reactos?rev=41705&view=rev
Log:
- Memtrack enhancements
- It now warns us when it detects an entry that wasn't freed by a memtrack-enabled
function
- It also provides some info when it detects a double free
- Removed some extra tag tracking junk
Modified:
trunk/reactos/drivers/network/tcpip/include/memtrack.h
trunk/reactos/drivers/network/tcpip/tcpip/main.c
trunk/reactos/lib/drivers/ip/network/memtrack.c
Modified: trunk/reactos/drivers/network/tcpip/include/memtrack.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/tcpip/incl…
==============================================================================
--- trunk/reactos/drivers/network/tcpip/include/memtrack.h [iso-8859-1] (original)
+++ trunk/reactos/drivers/network/tcpip/include/memtrack.h [iso-8859-1] Tue Jun 30
06:30:36 2009
@@ -38,7 +38,6 @@
#define Untrack(Thing) UntrackFL(__FILE__,__LINE__,Thing)
VOID TrackDumpFL( PCHAR File, ULONG Line );
#define TrackDump() TrackDumpFL(__FILE__,__LINE__)
-VOID TrackTag( ULONG Tag );
static __inline PVOID ExAllocateFromNPagedLookasideListX( PNPAGED_LOOKASIDE_LIST List,
PCHAR File, ULONG Line ) {
PVOID Out = ExAllocateFromNPagedLookasideList( List );
@@ -62,14 +61,12 @@
ExFreePool( Data );
}
-#define MEMTRACK_MAX_TAGS_TO_TRACK 64
#else
#define MTMARK()
#define Track(x,y)
#define TrackingInit()
#define TrackDump()
#define Untrack(x)
-#define TrackTag(x)
#define exAllocatePoolWithTag(x,y,z) ExAllocatePoolWithTag(x,y,z)
#define exAllocatePool(x,y) ExAllocatePool(x,y)
#define exFreePool(x) ExFreePool(x)
Modified: trunk/reactos/drivers/network/tcpip/tcpip/main.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/tcpip/tcpi…
==============================================================================
--- trunk/reactos/drivers/network/tcpip/tcpip/main.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/network/tcpip/tcpip/main.c [iso-8859-1] Tue Jun 30 06:30:36
2009
@@ -725,10 +725,6 @@
TI_DbgPrint(MAX_TRACE, ("Called.\n"));
TrackingInit();
- TrackTag(NDIS_BUFFER_TAG);
- TrackTag(NDIS_PACKET_TAG);
- TrackTag(FBSD_MALLOC);
- TrackTag(EXALLOC_TAG);
/* TdiInitialize() ? */
Modified: trunk/reactos/lib/drivers/ip/network/memtrack.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/drivers/ip/network/mem…
==============================================================================
--- trunk/reactos/lib/drivers/ip/network/memtrack.c [iso-8859-1] (original)
+++ trunk/reactos/lib/drivers/ip/network/memtrack.c [iso-8859-1] Tue Jun 30 06:30:36 2009
@@ -8,14 +8,6 @@
static LIST_ENTRY AllocatedObjectsList;
static KSPIN_LOCK AllocatedObjectsLock;
static NPAGED_LOOKASIDE_LIST AllocatedObjectsLookasideList;
-ULONG TagsToShow[MEMTRACK_MAX_TAGS_TO_TRACK] = { 0 };
-
-VOID TrackTag( ULONG Tag ) {
- UINT i;
-
- for( i = 0; TagsToShow[i]; i++ );
- TagsToShow[i] = Tag;
-}
VOID TrackingInit() {
TcpipInitializeSpinLock( &AllocatedObjectsLock );
@@ -82,9 +74,8 @@
if( ThingInList->Thing == Thing ) {
RemoveEntryList(Entry);
- TI_DbgPrint(MAX_TRACE,("TRACK: SPECIFIED ALREADY ALLOCATED ITEM
%x\n", Thing));
- ShowTrackedThing( "Double Alloc (Item in list)", ThingInList, FALSE
);
- ShowTrackedThing( "Double Alloc (Item not in list)", TrackedThing,
FALSE );
+ ShowTrackedThing( "Double Alloc (Item in list)", ThingInList, TRUE
);
+ ShowTrackedThing( "Double Alloc (Item not in list)", TrackedThing,
TRUE );
ExFreeToNPagedLookasideList( &AllocatedObjectsLookasideList,
ThingInList );
@@ -97,14 +88,6 @@
InsertHeadList( &AllocatedObjectsList, &TrackedThing->Entry );
TcpipReleaseSpinLock( &AllocatedObjectsLock, OldIrql );
-}
-
-BOOLEAN ShowTag( ULONG Tag ) {
- UINT i;
-
- for( i = 0; TagsToShow[i] && TagsToShow[i] != Tag; i++ );
-
- return TagsToShow[i] ? TRUE : FALSE;
}
VOID UntrackFL( PCHAR File, ULONG Line, PVOID Thing, ULONG Tag ) {
@@ -132,13 +115,21 @@
TcpipReleaseSpinLock( &AllocatedObjectsLock, OldIrql );
- /* TrackDumpFL( File, Line ); */
return;
}
Entry = Entry->Flink;
}
TcpipReleaseSpinLock( &AllocatedObjectsLock, OldIrql );
- DbgPrint("UNTRACK: SPECIFIED ALREADY FREE ITEM %x\n", Thing);
+
+ DbgPrint("[Double Free] Thing %08x %c%c%c%c (%s:%d)\n",
+ Thing,
+ ((PCHAR)&Tag)[3],
+ ((PCHAR)&Tag)[2],
+ ((PCHAR)&Tag)[1],
+ ((PCHAR)&Tag)[0],
+ File,
+ Line);
+
ASSERT( FALSE );
}