From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7037 invoked by alias); 30 Dec 2004 15:27:30 -0000 Mailing-List: contact pthreads-win32-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: pthreads-win32-owner@sources.redhat.com Received: (qmail 6889 invoked from network); 30 Dec 2004 15:27:19 -0000 Received: from unknown (HELO web13523.mail.yahoo.com) (216.136.174.161) by sourceware.org with SMTP; 30 Dec 2004 15:27:19 -0000 Received: (qmail 42917 invoked by uid 60001); 30 Dec 2004 15:27:19 -0000 Message-ID: <20041230152716.42907.qmail@web13523.mail.yahoo.com> Received: from [217.12.115.130] by web13523.mail.yahoo.com via HTTP; Thu, 30 Dec 2004 07:27:16 PST Date: Thu, 30 Dec 2004 15:27:00 -0000 From: Konstantin Voronkov Subject: Problem with recursive mutex : pthread_mutex_unlock() returns EPERM code To: pthreads-win32@sources.redhat.com MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-SW-Source: 2004/txt/msg00172.txt.bz2 Hello All! I have problem with recursive mutex. pthread_mutex_unlock() returns 1 EPERM code. I do not understan what I'm doing wrong, can you help me, please? I'm using pthread-win32 snapshot 2004-11-22 pre-build library. The library taken from here: http://sources.redhat.com/pthreads-win32/ I managed to reproduce problem in simple test application. Abort happens here after some time of work of this program: #include #include class MutexWrapper { public: // mutex initialization MutexWrapper() : m_reg_mutex(PTHREAD_RECURSIVE_MUTEX_INITIALIZER) { } // mutex freeing ~MutexWrapper() { pthread_mutex_destroy(&m_reg_mutex); } // locks the mutex void Lock() { pthread_mutex_lock(&m_reg_mutex); } void UnLock() { const int retCode = pthread_mutex_unlock(&m_reg_mutex); if(retCode) // abort happens here after some time of work of program abort(); } private: pthread_mutex_t m_reg_mutex; // mutex object member }; unsigned long WINAPI threadFunc(void *mux) { while(true) { reinterpret_cast(mux)->Lock(); reinterpret_cast(mux)->UnLock(); } return 0; } int main(int argc, char* argv[]) { MutexWrapper mux; CreateThread(0, 0, threadFunc, &mux, 0, 0); while(true) { mux.Lock(); mux.UnLock(); } return 0; } ================ the project settings of test application: linker options: pthreadVC1.lib /nologo /subsystem:console /incremental:no /pdb:"Release/CsuByteArrayTest.pdb" /machine:I386 compiler options: /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /Fo"Release/" /Fd"Release/" /FD /c problem reproduces with MSVC 6.0 sp5 compiler problem reproduces on WinXP sp2, and on Windows 2000 sp4 Best Regards, Voronkov Konstantin __________________________________ Do you Yahoo!? All your favorites on one personal page – Try My Yahoo! http://my.yahoo.com