Segfault
Segfault

Reputation: 8290

CRITICAL_SECTION doesn't have DebugInfo

I'm trying to get a look at the DebugInfo of my CRITICAL_SECTION during execution of my win32 program, and after using InitializeCriticalSection then the DebugInfo pointer is -1.

CRITICAL_SECTION myCS;
InitializeCriticalSection(&myCS);
printf("%d", myCS.DebugInfo); // prints:  -1

I also tried InitializeCriticalSectionEx(&myCS, 4000, 0); and had the same results. Also get the same thing regardless if I have entered this Critical Section or not. Is it possible to access this DebugInfo, and how should it be done?

Upvotes: 3

Views: 1136

Answers (1)

gusitoguay
gusitoguay

Reputation: 150

This is an old question, but is unanswered.

You can force the creation of the DebugInfo structure by calling InitializeCriticalSectionEx with RTL_CRITICAL_SECTION_FLAG_FORCE_DEBUG_INFO flag:

InitializeCriticalSectionEx(&cs, 4000, RTL_CRITICAL_SECTION_FLAG_FORCE_DEBUG_INFO);

This flag is not included on the Microsoft InitializeCriticalSectionEx documentation, but it is defined on winnt.h

Upvotes: 5

Related Questions