X-Recipient: archive-cygwin@delorie.com
X-SWARE-Spam-Status: No, hits=-1.0 required=5.0 	tests=AWL,BAYES_00
X-Spam-Check-By: sourceware.org
Message-ID: <4B067444.80900@ece.cmu.edu>
Date: Fri, 20 Nov 2009 11:49:40 +0100
From: Ryan Johnson <ryanjohn@ece.cmu.edu>
User-Agent: Thunderbird 2.0.0.23 (Windows/20090812)
MIME-Version: 1.0
To: cygwin@cygwin.com
Subject: Re: Re: 1.5.25-15: pthread_join deadlocks
References: <20091119124405.GF29173@calimero.vinschen.de>
In-Reply-To: <20091119124405.GF29173@calimero.vinschen.de>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe@cygwin.com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-help@cygwin.com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner@cygwin.com
Mail-Followup-To: cygwin@cygwin.com
Delivered-To: mailing list cygwin@cygwin.com

Corinna Vinschen wrote:
> On Nov 19 12:29, Ryan Johnson wrote:
>   
>> Hi all,
>>
>> I'm hitting a deadlock with cygwin pthreads when joining on a
>> short-lived thread -- for me the second such thread creation will
>> almost never return. It looks *exactly* like a problem that others
>> noticed as far back as early 2005 [0], and  from the output of
>> strace on the test case (below) the culprit is almost certainly a
>> racy optimization in __cygwin_lock_* for which a patch was submitted
>> six months ago [1].
>>
>> As of today my cygwin distribution is completely up to date. Any
>> hope of an update coming out soon?
>>     
>
> The update will be Cygwin 1.7.  You testcase works fine for
> me on Cygwin 1.7, so maybe you should try this path.  See
> http://cygwin.com/#beta-test
>   
Ah, that's good to know. I'll try it out when I get a few minutes. 
Meanwhile, firing up an extra thread at program start, and having it 
just block on a cond var nobody will ever signal, seems to avoid the 
problem completely.

Out of curiosity, how much did removing the racy optimization hurt 
performance? The patch just yanked it completely iirc. An alternative 
might be to have the main thread check for single-thread environment 
only at acquire time, and then release only if it acquired (the latter 
is probably a good idea regardles...).

Thanks,
Ryan


--
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

