X-Recipient: archive-cygwin AT delorie DOT com DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:to:subject:message-id:reply-to :references:mime-version:content-type:in-reply-to; q=dns; s= default; b=UH7XpUie4dGvQaDB8wK4ZvKWB8XeEj5ldsJBEkP3ye7/ffnnateNK M3jJVyGJpdsGcC0BrEppcDyqweTj1JYOmze2rSw7upiXSxv/5bdfqKuJCLnz43Lj oZvFxiJ9I0qnGO2ROSG7wBDmyd3cKLWzFq6/gd2jFqx/DasfVZKd60= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:to:subject:message-id:reply-to :references:mime-version:content-type:in-reply-to; s=default; bh=mh1Tdt0IhsJ7uB2qEuLPbJv2Q24=; b=dteDorxnVzwm3hsrYEb7wORxy1AA HLlB4tAFOxXOgM5Hn9S6pmnOZEIfypsK12lG+aC9DQFD/6QaFfDhOsM9Fje1Yhm1 Ce1bdnR3+0jm7DA87pztXpS/uVCtLoGiaM4VP522oCeSEpX0x/HO1P4ZNeAfmRMS xgkO21gC878OJHk= Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-5.9 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.3.2 X-HELO: calimero.vinschen.de Date: Wed, 25 Feb 2015 18:51:49 +0100 From: Corinna Vinschen To: cygwin AT cygwin DOT com Subject: Re: Unexpected EINVAL from pthread_join Message-ID: <20150225175149.GR437@calimero.vinschen.de> Reply-To: cygwin AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com 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> <20150224203744 DOT 085f5b1e AT tukaani DOT org> <20150224212021 DOT GQ437 AT calimero DOT vinschen DOT de> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="1pP7B07eFG5HaxiL" Content-Disposition: inline In-Reply-To: <20150224212021.GQ437@calimero.vinschen.de> User-Agent: Mutt/1.5.23 (2014-03-12) --1pP7B07eFG5HaxiL Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Feb 24 22:20, Corinna Vinschen wrote: > Hi Lasse, >=20 > On Feb 24 20:37, Lasse Collin wrote: > > 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. > > >=20 > > > Can you collect the info which functions are affected so that lazy me > > > just has to apply the cw_sig_restart patches in bulk? > >=20 > > 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. > >=20 > > These look the most suspicious to me, possibly needing cw_sig_restart: > >=20 > > thread.h fast_mutex::lock > > fhandler_tape.cc fhandler_dev_tape::_lock FYI, I fixed these plus pthread_mutex::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. > >=20 > > exceptions.cc handle_sigsuspend This works as desired, afaics. > > posix_ipc.cc ipc_mutex_lock > > signal.cc clock_nanosleep > > signal.cc sigwaitinfo > > thread.cc pthread_cond::wait > > thread.cc semaphore::_timedwait > > thread.cc 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. > >=20 > > fhandler_dsp.cc fhandler_dev_dsp::Audio_out::waitforspace > > fhandler_dsp.cc fhandler_dev_dsp::Audio_in::waitfordata I'm still mulling over the rest of your list... Corinna --=20 Corinna Vinschen Please, send mails regarding Cygwin to Cygwin Maintainer cygwin AT cygwin DOT com Red Hat --1pP7B07eFG5HaxiL Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAEBAgAGBQJU7gu1AAoJEPU2Bp2uRE+gGZ0P/3LFmrZKRVCv2u5uc45NnJJA y0lIcMwZoljZ6Nv7NNZvni5avGQHZ27hmW/Ej9BPBd5qChxeiC/7UWBDWdl9gZmB s0QXmy8U1n2pMQ/WwRgWBfL/RAmEmjgmcqB52rL9n78jsp/kKZCtkLaRh+/0NlFb HmqYTZftFBLA1KpEj8zLzhPsgvncG7M3acs1X1cSbLYI1qG2vo/zk7atre/ZYq0T buKOBtgMkuRJJSOkIvk7+/WhtOjRWynY9ae/7D9Wu/kJquD+uyu5WYWhyvkKmqpv W0CLgmoIX0vTKsfqf41iNBB9EX9qz2b5DMS9DJ46TsPmX0ErLsvqVl5aX8DnjK+R YXASlpjWB1vclo2T49lW8uzNS5icL39BOiKe9tOKqC9LRr5u8uB8CpmBsI13LqkM bHWtYVNUsrUjr6Sg0TFpkL9z23MNbMEK0RHg0JpOphr/lceQa/0QjzVy/WdVQfan zvBPLd1NG4MkShI9hLZPKDxLm3K4FjeycOStoY79DB3FA2WYpH8BfyVxQutY4o0v z6GfbFSQsIkyeBYDogjBwp6UjiAMEZE7zdi+5iykbwv8eTAqpCaICcPyHiER7h5y CDSGvD8lVwMNkJRIcJCnAx/sWj1AGEQz1GUQ5nzx0md1h5KloRH+IBtXXDN+EIzv dXNcBNB+ylOJIoIY0MGg =GxjI -----END PGP SIGNATURE----- --1pP7B07eFG5HaxiL--