Debugging Application Verifier: Thread cannot own a critical section

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:

    ntdll.dll!_DbgBreakPoint@0() 	
    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()
    kernel32.dll!@BaseThreadInitThunk@12()
    ntdll.dll!__RtlUserThreadStart@8()
    

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…

Any opinions expressed on this blog are Johannes' own. Refer to the respective vendor’s product documentation for authoritative information.
« Back to home