Commit 5e787ba5 authored by Alexandre Julliard's avatar Alexandre Julliard

Hack to make the main heap critical section have a proper debug info

structure.
parent 7a15eb93
......@@ -114,22 +114,18 @@ NTSTATUS WINAPI RtlInitializeCriticalSection( RTL_CRITICAL_SECTION *crit )
*/
NTSTATUS WINAPI RtlInitializeCriticalSectionAndSpinCount( RTL_CRITICAL_SECTION *crit, ULONG spincount )
{
if (!GetProcessHeap()) crit->DebugInfo = NULL;
else
crit->DebugInfo = RtlAllocateHeap(GetProcessHeap(), 0, sizeof(RTL_CRITICAL_SECTION_DEBUG));
if (crit->DebugInfo)
{
crit->DebugInfo = RtlAllocateHeap(GetProcessHeap(), 0, sizeof(RTL_CRITICAL_SECTION_DEBUG));
if (crit->DebugInfo)
{
crit->DebugInfo->Type = 0;
crit->DebugInfo->CreatorBackTraceIndex = 0;
crit->DebugInfo->CriticalSection = crit;
crit->DebugInfo->ProcessLocksList.Blink = &(crit->DebugInfo->ProcessLocksList);
crit->DebugInfo->ProcessLocksList.Flink = &(crit->DebugInfo->ProcessLocksList);
crit->DebugInfo->EntryCount = 0;
crit->DebugInfo->ContentionCount = 0;
crit->DebugInfo->Spare[0] = 0;
crit->DebugInfo->Spare[1] = 0;
}
crit->DebugInfo->Type = 0;
crit->DebugInfo->CreatorBackTraceIndex = 0;
crit->DebugInfo->CriticalSection = crit;
crit->DebugInfo->ProcessLocksList.Blink = &(crit->DebugInfo->ProcessLocksList);
crit->DebugInfo->ProcessLocksList.Flink = &(crit->DebugInfo->ProcessLocksList);
crit->DebugInfo->EntryCount = 0;
crit->DebugInfo->ContentionCount = 0;
crit->DebugInfo->Spare[0] = 0;
crit->DebugInfo->Spare[1] = 0;
}
crit->LockCount = -1;
crit->RecursionCount = 0;
......
......@@ -172,6 +172,14 @@ static inline void clear_block( void *ptr, SIZE_T size )
memset( ptr, 0, size );
}
static RTL_CRITICAL_SECTION_DEBUG process_heap_critsect_debug =
{
0, 0, NULL, /* will be set later */
{ &process_heap_critsect_debug.ProcessLocksList, &process_heap_critsect_debug.ProcessLocksList },
0, 0, { 0, (DWORD)(__FILE__ ": main process heap section") }
};
/***********************************************************************
* HEAP_Dump
*/
......@@ -611,7 +619,18 @@ static BOOL HEAP_InitSubHeap( HEAP *heap, LPVOID address, DWORD flags,
/* Initialize critical section */
RtlInitializeCriticalSection( &heap->critSection );
if (!processHeap) /* do it by hand to avoid memory allocations */
{
heap->critSection.DebugInfo = &process_heap_critsect_debug;
heap->critSection.LockCount = -1;
heap->critSection.RecursionCount = 0;
heap->critSection.OwningThread = 0;
heap->critSection.LockSemaphore = 0;
heap->critSection.SpinCount = 0;
process_heap_critsect_debug.CriticalSection = &heap->critSection;
}
else RtlInitializeCriticalSection( &heap->critSection );
if (flags & HEAP_SHARED)
{
/* let's assume that only one thread at a time will try to do this */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment