The Thread Cannot Own a Lock in this Context

Application Verifier stop message

Locks violation detected. The thread cannot own a lock in this context.

Probable cause

This stop is generated if a thread is terminated, suspended, or is in a state in which it cannot hold a critical section (e.g. worker thread finished a work item). The current thread is the culprit.

If the current thread is the owner of the critical section, it is probably calling ExitThread. The current thread should have released the critical section before exiting. If the current thread is calling TerminateThread() or SuspendThread(), then it should not do this while the target thread is holding a critical section.

Information displayed by Application Verifier in Tool Window

Lock – Critical section address

Owner – Thread identifier

DebugInfo - Critical section debug information address

Description –The thread cannot own a lock in this context

Trace Description - Critical Section Initialization

Additional information

Select Break on the Verifier Stop Message and look at the Tool Window to find where the critical section was initialized. Check the current call stack from the debugger to see where the thread is exiting.

Frequency of this error is low.

See Also

Concepts

Lock Verifier