This is the mail archive of the
mailing list for the Cygwin project.
Re: Unexpected EINVAL from pthread_join
- From: Lasse Collin <lasse dot collin at tukaani dot org>
- To: cygwin at cygwin dot com
- Date: Tue, 24 Feb 2015 20:37:44 +0200
- Subject: Re: Unexpected EINVAL from pthread_join
- Authentication-results: sourceware.org; auth=none
- References: <20150222225437 dot 271e929b at tukaani dot org> <20150223121445 dot GL437 at calimero dot vinschen dot de> <20150223125914 dot GO437 at calimero dot vinschen dot de> <20150223140317 dot GP437 at calimero dot vinschen dot de> <20150224155458 dot 33ff024a at tukaani dot org> <20150224152554 dot GM437 at calimero dot vinschen dot de>
On 2015-02-24 Corinna Vinschen wrote:
> On Feb 24 15:54, Lasse Collin wrote:
> > 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.
> Can you collect the info which functions are affected so that lazy me
> just has to apply the cw_sig_restart patches in bulk?
I grepped for cygwait uses earlier but I don't understand the code well
enough to be sure about anything. The following is pretty much
guessing, but hopefully there's something useful still.
These look the most suspicious to me, possibly needing cw_sig_restart:
When looking for things needing cw_sig_restart, I started to wonder if
cw_sig_eintr is used properly in all cases. Often the caller of
cygwait + cw_sig_eintr will also conditionally call
_my_tls.call_signal_handler, but the following functions don't. The
comment in handle_sigsuspend makes me think that this may be a false
alarm but I mention these just in case.
In the following functions the situation is kind of reversed. Those
functions call _my_tls.call_signal_handler even though cw_sig_eintr
wasn't specified. cygwait will already have called the signal handler
since cw_sig has been specified via cygwait(DWORD). So I guess in these
functions the signal handler might get called twice.
Lasse Collin | IRC: Larhzu @ IRCnet & Freenode
Problem reports: http://cygwin.com/problems.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple