This is the mail archive of the cygwin mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Unexpected EINVAL from pthread_join

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:

    thread.h          fast_mutex::lock  fhandler_dev_tape::_lock

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.     handle_sigsuspend      ipc_mutex_lock         clock_nanosleep         sigwaitinfo         pthread_cond::wait         semaphore::_timedwait         semaphore::_wait

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.   fhandler_dev_dsp::Audio_out::waitforspace   fhandler_dev_dsp::Audio_in::waitfordata

Lasse Collin  |  IRC: Larhzu @ IRCnet & Freenode

Problem reports:
Unsubscribe info:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]