John K. Hohm jhohm at
Thu May 16 22:08:43 CDT 2002

I am implementing a COM object in comcat.dll that allocates itself with
HeapAlloc and frees itself on its last Release with HeapFree.  I am using
it in a simple test program that creates it and releases it, and when the
Release happens I get this:

err:heap:HEAP_ValidateInUseArena Heap 40340000: in-use arena 40378878 next
block has PREV_FREE flag

It seems to be saying that I'm freeing an already-free block.  I ran the
test program with --debugmsg trace+all, and I can see that the only uses
of the heap during the lifetime of my object instance are one
ntdll.RtlAllocateHeap that returns 40378880, and one ntdll.RtlFreeHeap
that gets 40378880 as its third param.  The RtlFreeHeap is immediately
followed by the err:heap, which then spits out a bunch of heap info.  It
seems pretty obvious that I'm freeing the block of memory I had just
allocated; what else might be causing the err:heap?

Here is the interesting section of the trace:

080701d0:Call ntdll.RtlAllocateHeap(40340000,00000008,00000020) ret=4397c0f3
080701d0:trace:heap:RtlAllocateHeap (40340000,0000000a,00000020): returning 40378880
080701d0:Ret  ntdll.RtlAllocateHeap() retval=40378880 ret=4397c0f3
080701d0:trace:ntdll:NTDLL_vsnwprintf (2147483647,L"%lX")
080701d0:Call advapi32.RegOpenKeyExW(80000000,40566ce8 L"Component Categories",00000000,00020019,40378898) ret=4397c170
080701d0:Call ntdll.RtlInitUnicodeString(40566bd8,40566ce8 L"Component Categories") ret=40660189
080701d0:Ret  ntdll.RtlInitUnicodeString() retval=0000002a ret=40660189
080701d0:Call ntdll.NtOpenKey(40378898,00020019,40566be0) ret=40660194
080701d0:trace:reg:NtOpenKey (0x80000000,L"Component Categories",20019,0x40378898)
080701d0: open_key( parent=-2147483648, access=00020019, name=L"Component Categories" )
Open key ERROR
080701d0: open_key() = OBJECT_NAME_NOT_FOUND { hkey=0 }
080701d0:trace:reg:NtOpenKey <- 0x0000
080701d0:Ret  ntdll.NtOpenKey() retval=c0000034 ret=40660194
080701d0:Call ntdll.RtlNtStatusToDosError(c0000034) ret=4066019a
080701d0:Ret  ntdll.RtlNtStatusToDosError() retval=00000002 ret=4066019a
080701d0:Ret  advapi32.RegOpenKeyExW() retval=00000002 ret=4397c170
080701d0:Call ntdll.RtlFreeHeap(40340000,00000000,40378880) ret=4397be9d
080701d0:err:heap:HEAP_ValidateInUseArena Heap 40340000: in-use arena 40378878 next block has PREV_FREE flag

More information about the wine-devel mailing list