Critical Sections are synchronization objects used to access shared objects in a sequential manner inside a user mode process. There are several Critical Section objects created and used by the Operating System and applications can also create their own critical sections if there are requirements for sequential access to shared object.
Most important functions are give below
//Declare Critical Section
CRITICAL_SECTION cs;
//Initialize the Critical Section Lock
//mostly done at initial portion of the application/component
InitializeCriticalSection(&cs);
//Enter Critical Section Lock
EnterCriticalSection(&cs);
//Shared object usage goes here
//Exit the Critical Section Lock
LeaveCriticalSection(&cs);
//Finally cleanup the Critical Section Lock
DeleteCriticalSection(&cs);
But all these functions or features become a trouble if not used properly or when the portion of the code has bugs. So there are several types of issues related to Critical Sections we see when we start analyzing dumps and some of them are listed below
- Blocked Critical Section
- Loader Locks
- Leaked Critical Section
- Orphaned Critical Section
- Lock Convoys
Let us see the scenarios in which each of these issues happens
… To be continued soon…