Thread Not Supposed To Own a Lock

Application Verifier stop message

Locks violation detected. Thread is not supposed to be owning a lock: number of locks owned is <count>.

Probable cause

This stop is generated if the current thread calls LeaveCriticalSection but according to the internal Application Verifier bookkeeping it does not own any critical sections.

If the number of locks owned is 0, the current thread is attempting to release a critical section it did not acquire or it is calling LeaveCriticalSection more times than it called EnterCriticalSection for a given critical section.

Information displayed by Application Verifier in Tool Window

Lock - Critical section address

Owner - N/A

DebugInfo – N/A

Description - Thread is not supposed to be owning a lock: number of locks owned is <count>

Trace Description - Blank

Additional information

Check the current call stack when the thread attempts to release a lock it does not own.

If number of locks owned is zero, this is probably a bug in the current thread. It either tries to leave a critical section that it didn’t enter, or it is calling LeaveCriticalSection more times than it called EnterCriticalSection for the same critical section.

If number of locks owned is not zero (it is a negative integer number), the internal verifier data structures are probably corrupted.

Frequency of this error is low.

See Also

Concepts

Lock Verifier

Critical Section Over-Released or Corrupted