From c72c8df5e926257f51fe2aff44fa05b0ab6eb36f Mon Sep 17 00:00:00 2001 From: Andrey Prygunkov Date: Tue, 25 Dec 2007 14:37:19 +0000 Subject: [PATCH] added check to detect special synchonisation issues on windows in debug-mode --- Thread.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Thread.cpp b/Thread.cpp index 06ba691a..44f7174c 100644 --- a/Thread.cpp +++ b/Thread.cpp @@ -63,6 +63,14 @@ void Mutex::Lock() { #ifdef WIN32 EnterCriticalSection(&m_mutexObj); +#ifdef DEBUG + // CriticalSections on Windows can be locked many times from the same thread, + // but we do not want this and must treat such situations as errors and detect them. + if (m_mutexObj.RecursionCount > 1) + { + error("Internal program error: inconsistent thread-lock detected"); + } +#endif #else pthread_mutex_lock(&m_mutexObj); #endif