Application Verifier: Thread cannot own a critical section

Posted on

Whereas most Verifier error messages are rather descriptive, this one is not really:

    VERIFIER STOP 00000200 : pid 0x2B4: 
    Thread cannot own a critical section. 
    
    0000104C : Thread ID.
    05274FDC : Critical section address.
    09D88FE0 : Critical section debug information address.
    010135D4 : Critical section initialization stack trace.
    

Why should not this thread be allowed to own a critical section? What is Application Verifier trying to tell us? Luckily, the stack trace gives a hint:

    [email protected]() 	
    vrfcore.dll!VerifierStopMessageEx(...)
    vfbasics.dll!VfBasicsStopMessage()
    vfbasics.dll!AVrfpCheckCriticalSection()
    vfbasics.dll!AVrfpCheckCriticalSectionSplayNode()
    vfbasics.dll!AVrfpCheckCriticalSectionTree()
    vfbasics.dll!AVrfCheckForOrphanedCriticalSections()
    vfbasics.dll!AVrfpCheckThreadTermination()
    vfbasics.dll!AVrfpCheckCurrentThreadTermination()
    vfbasics.dll!AVrfpStandardThreadFunction()
    [email protected]@12()
    [email protected]()
    

So in fact, Application Verifier has detected that the thread currently being terminated is still owning a critical section. What a stupid error message for a simple problem…

« Back to home