]> sourceware.org Git - newlib-cygwin.git/commit
Don't test pthread objects for being already initialized at init time
authorCorinna Vinschen <corinna@vinschen.de>
Wed, 20 Apr 2016 10:31:45 +0000 (12:31 +0200)
committerCorinna Vinschen <corinna@vinschen.de>
Wed, 20 Apr 2016 10:31:45 +0000 (12:31 +0200)
commit9409c5335bfac54ccd89fbe931e670b797462e05
tree96d5fc9b47998f9e199f46081dfafb939c41eb69
parent6ee81f44e04848901c7b05c968564d34a7ceed06
Don't test pthread objects for being already initialized at init time

For all pthread init functions, POSIX says

  Results are undefined if pthread_FOO_init() is called specifying an
  already initialized pthread_FOO object.

So far our pthread init functions tested the incoming object if it's
already an initialized object and, if so, returned EBUSY.  That's ok
*iff* the object was already initialized.  However, as the example in
https://cygwin.com/ml/cygwin/2016-04/msg00473.html shows, an uninitialized
pthread object could also accidentally look like an initialized object
and then returning EBUSY is not ok.

Consequentially, all those tests are dangerous.  Per POSIX, an application
has to know what its doing when calling any of the pthread init functions
anyway, and re-initializing the object is just as well as undefined
behaviour as is returning EBUSY on already initialized objects.

* thread.cc (pthread_attr_init): Drop check for already initialized
object.
(pthread_condattr_init): Ditto.
(pthread_rwlockattr_init): Ditto.
(pthread_mutexattr_init): Ditto.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
winsup/cygwin/thread.cc
This page took 0.03176 seconds and 5 git commands to generate.