delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2001/11/17/13:51:44

Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT sources DOT redhat DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT sources DOT redhat DOT com>
List-Help: <mailto:cygwin-help AT sources DOT redhat DOT com>, <http://sources.redhat.com/ml/#faqs>
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 <mec AT shout DOT net>
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
<mec AT shout DOT net>
"love without fear"

===

#include <pthread.h>
#include <stdio.h>

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/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019