X-Recipient: archive-cygwin AT delorie DOT com X-SWARE-Spam-Status: No, hits=-1.4 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE,RCVD_IN_HOSTKARMA_YE X-Spam-Check-By: sourceware.org X-Mail-Handler: Dyn Standard SMTP by Dyn X-Report-Abuse-To: abuse AT dyndns DOT com (see http://www.dyndns.com/services/sendlabs/outbound_abuse.html for abuse reporting information) X-MHO-User: U2FsdGVkX1/x3qsIKmgQ7ar1lD1qLWsS Date: Mon, 7 Jan 2013 01:43:17 -0500 From: Christopher Faylor To: cygwin AT cygwin DOT com Subject: Re: pthread_rwlock_tryrdlock bug (with test & patch) Message-ID: <20130107064317.GA29248@ednor.casa.cgf.cx> Reply-To: cygwin AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com References: <50E9B35F DOT 7030307 AT iki DOT fi> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <50E9B35F.7030307@iki.fi> User-Agent: Mutt/1.5.20 (2009-06-14) Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: 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 On Sun, Jan 06, 2013 at 06:24:47PM +0100, Antti Kantee wrote: >[I'd submit this to cygwin-patches, but the web page says only >subscribers can post to that list, so please bear with me for this >simple issue] > >Hi, > >Calling pthread_rwlock_tryrdlock() twice from the same thread always >fails with EBUSY the second time. See attached test.c. Replacing the >second tryrdlock() with rdlock() makes the call succeed, leading me to >believe there is a bug in tryrdlock(). > >Assuming I was looking at the correct source file, the attached patch >should fix the issue. I'm not sure why the lookup_reader() call was >there in the first place; perhaps a remnant from a time when recursive >read locking was not supported? > >While looking at tryrdlock(), the handling of ULONG_MAX also seems >wrong, as you'd probably want to return EAGAIN instead of allocating >another reader structure. However, that problem is arguably more of an >academic issue and therefore I didn't touch it in my patch. Thanks for the analysis and patch. I've made a few more changes to this function and should have everything checked in tomorrow. cgf -- 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