public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: Corinna Vinschen <corinna-cygwin@cygwin.com>
To: cygwin@cygwin.com
Cc: "Canham, Timothy K (348C)" <timothy.k.canham@jpl.nasa.gov>
Subject: Re: pthread_attr_init() returning errors
Date: Wed, 20 Apr 2016 10:54:00 -0000	[thread overview]
Message-ID: <20160420105016.GB26118@calimero.vinschen.de> (raw)
In-Reply-To: <E8EB3633A6A4594CA063A3FCBC82C18C3621F0F6@ap-embx-sp40.RES.AD.JPL>

[-- Attachment #1: Type: text/plain, Size: 1701 bytes --]

On Apr 19 19:49, Canham, Timothy K (348C) wrote:
> I have some code to start a task that suddenly started failing. This is pretty mature code. Here is the code fragment with my added printf()
> 
>         pthread_attr_t att;
>         int stat = pthread_attr_init(&att);
>         if (stat != 0) {
>             printf("pthread_attr_init: (%d)(%d): %s\n",stat,errno,strerror(stat));
>             // return
>         }
> 
> Here is the output:
> 
> pthread_attr_init: (16)(0): Device or resource busy

This is most unusual.  What happens is this:

A pthread_attr_t is a pointer to a pointer to a struct with a magic
number.  And at the start of pthread_attr_init this magic number is
tested if it's already the magic number expected for an object of type
pthread_attr_t.  And only if so, the pthread_attr_init function fails
with EBUSY.

That means, the arbitrary value in the uninitialized att prior to 
the call to pthread_attr_init is a pointer value which points to
valid memory which has the magic value 0xdf0df048.  Wow.

This means we can't keep up with the tests in the pthread_FOO_init
functions since they could point to an *supposedly* initialized 
object, while in fact the value they point to is only accidentally
so that it looks like an initialized object.

I provided new developer snapshots on https://cygwin.com/snapshots/
and I've just uploaded a 2.5.1-0.1 test release which you can install
via setup as soon as your mirror has catched up.

Pleaser give any of them a try.


Thanks,
Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Maintainer                 cygwin AT cygwin DOT com
Red Hat

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

  parent reply	other threads:[~2016-04-20 10:50 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-19 20:33 Canham, Timothy K (348C)
2016-04-19 21:31 ` Václav Haisman
2016-04-20 10:54 ` Corinna Vinschen [this message]
2016-04-20 14:25   ` Canham, Timothy K (348C)
2016-04-20 14:41     ` Corinna Vinschen
2016-04-20 17:39       ` Canham, Timothy K (348C)
2016-04-20 18:50         ` Ernie Rael
2016-04-21  8:37           ` Corinna Vinschen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160420105016.GB26118@calimero.vinschen.de \
    --to=corinna-cygwin@cygwin.com \
    --cc=cygwin@cygwin.com \
    --cc=timothy.k.canham@jpl.nasa.gov \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).