Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT sources DOT redhat DOT com Delivered-To: mailing list cygwin AT sources DOT redhat DOT com Date: Sat, 17 Nov 2001 12:14:32 -0600 From: Michael Elizabeth Chastain Message-Id: <200111171814.MAA29795@duracef.shout.net> To: cygwin AT cygwin DOT com Subject: Re: pthread_mutex_init fails This happens to me, too, with a simple test program on Cygwin 1.3.5-3 + Windows 2K + gcc 2.95.3. This is a bug in file winsup/thread.cc function __pthread_mutex_init. The idea is that static mutex's are initialized with a magic value (0x14). The first time the mutex is locked or unlocked, __pthread_mutex_init is supposed to initialize it. But __pthread_mutex_init does not handle the case of VALID_STATIC_OBJECT correctly, so the mutex never gets initialized. This bit me last week and I got that far in analyzing it when the CVS version of thread.cc got fixed. Also several dozen test programs were added for threads. So I am a happy camper with CVS winsup. Here is my test program. It prints "16" and "22" on Cygwin 1.3.5-3, and it prints "0" and "0" with CVS winsup. Michael Elizabeth Chastain "love without fear" === #include #include pthread_mutex_t m1 = PTHREAD_MUTEX_INITIALIZER; int main () { int rv; rv = pthread_mutex_lock (&m1); printf ("pthread_mutex_lock: %d\n", rv); rv = pthread_mutex_unlock (&m1); printf ("pthread_mutex_unlock: %d\n", rv); return 0; } -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Bug reporting: http://cygwin.com/bugs.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/