Unexpected EINVAL from pthread_join

Lasse Collin lasse.collin@tukaani.org
Tue Feb 24 15:24:00 GMT 2015


On 2015-02-23 Corinna Vinschen wrote:
> On second thought, this is not the right way to handle this.  The
> WAIT_SIGNALED is returned because we're in the main thread and
> SA_RESTART is not set, as you assumed above.  This leads to the
> question why this scenario isn't handled directly in cygwait.
> 
> So what I did now is to apply the below patch to CVS.  It adds a flag
> cw_sig_restart to cygwait, which also restarts in the main thread if
> SA_RESTART is not set, as it's supposed to be for pthread_join.
> 
> I uploaded a new developer snapshot to https://cygwin.com/snapshots/
> Can you please test if it works as desired?

The snapshot 20150223 works. (The earlier patch worked too.) Thank you.

Many other pthread functions are similar in sense that they must never
return EINTR. A bug similar to the one in pthread::join exist in
pthread_mutex::lock. If SA_RESTART isn't used, signals can make
multiple threads get a lock on the same mutex at the same time. A test
program is attached. Adding cw_sig_restart to the cygwait call in
pthread_mutex::lock fixes this.

-- 
Lasse Collin  |  IRC: Larhzu @ IRCnet & Freenode
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mutex-test.c
Type: text/x-c++src
Size: 1642 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin/attachments/20150224/8d1ef0e8/attachment.bin>
-------------- next part --------------
--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple


More information about the Cygwin mailing list