| www.delorie.com/archives/browse.cgi | search |
| 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: | Thu, 30 Aug 2001 09:46:00 +0200 |
| From: | Frederic Devernay <Frederic DOT Devernay AT sophia DOT inria DOT fr> |
| To: | cygwin AT cygwin DOT com |
| Cc: | Olivier Bantiche <Olivier DOT Bantiche AT sophia DOT inria DOT fr>, |
| Frederic Devernay <Frederic DOT Devernay AT sophia DOT inria DOT fr> | |
| Subject: | possible pthread_mutex_init bug: reads uninitialized memory |
| Message-ID: | <20010830094600.A9594@perf.inria.fr> |
| Mime-Version: | 1.0 |
| User-Agent: | Mutt/1.2.4i |
Hello,
there are officially two ways to initialize a pthread mutex:
pthread_mutex_t mut = PTHREAD_MUTEX_INITIALIZER;
or
pthread_mutex_t mut;
pthread_mutex_init(&mut,NULL);
the problem is that the pthread_mutex_init in cygwin reads the of-course
uninitialized memory:
as seen in cygwin-1.3.2-1/winsup/cygwin/thread.cc:
__pthread_mutex_init (pthread_mutex_t * mutex,
const pthread_mutexattr_t * attr)
{
if ((((pshared_mutex *)(mutex))->flags & SYS_BASE == SYS_BASE))
// a pshared mutex
return EBUSY;
...
If found this bug not by declaring a local variable as above, but by allocating
the mutex. the only workaround I found was to memset the memory area before
calling pthread_mutex_init.
I don't know what a pshared_mutex is, but pthread_mutex_init should really
not assume that anything is valid in the given mutex!
Fred
--
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/
| webmaster | delorie software privacy |
| Copyright © 2019 by DJ Delorie | Updated Jul 2019 |