Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
warning C26111: Caller failing to release lock <lock> before calling function <func>.
The annotation _Requires_lock_not_held_ imposes a precondition that the lock count for the specified lock cannot be greater than zero when the function is called. Warning C26111 is issued when a function fails to release the lock before it calls another function.
Example
The following example generates warning C26111 because the _Requires_lock_not_held_ precondition is violated by the call to DoNotLock within the locked section.
typedef struct _DATA 
{
    CRITICAL_SECTION cs;
    int d;
} DATA;
_Requires_lock_not_held_(p->cs) 
void DoNotLock(DATA* p)
{
    EnterCriticalSection(&p->cs); 
    p->d = 0;
    LeaveCriticalSection(&p->cs);
}
void LockedFunction(DATA* p) 
{ 
    EnterCriticalSection(&p->cs); 
    DoNotLock(p); // Warning C26111
    LeaveCriticalSection(&p->cs);
}