X-Recipient: archive-cygwin AT delorie DOT com X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE,UNPARSEABLE_RELAY X-Spam-Check-By: sourceware.org X-Yahoo-SMTP: jenXL62swBAWhMTL3wnej93oaS0ClBQOAKs8jbEbx_o- Date: Tue, 15 Mar 2011 15:07:33 -0400 From: Christopher Faylor To: cygwin AT cygwin DOT com Subject: Re: Calling sem_wait() in DllMain( DLL_THREAD_DETACH) crashes Message-ID: <20110315190733.GA23825@ednor.casa.cgf.cx> Reply-To: cygwin AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com References: <4D7FB133 DOT 7030301 AT dronecode DOT org DOT uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4D7FB133.7030301@dronecode.org.uk> 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 Tue, Mar 15, 2011 at 06:34:27PM +0000, Jon TURNEY wrote: > >I've come across a problem whilst trying to run the twisted test suite, where >some tests just cause python to segfault. It seems to be the same issue with >libcrypto as reported in [2],[3] > >A small test case is attached to [2] as cygwin_crash.zip, referred to in >msg76086, which shows that manipulating a semaphore in >DllMain(DLL_THREAD_DETACH) causes a crash. > >There is a patch for openssl attached to [1] which makes sense to me. Surely >the cleanup ERR_remove_state() does should be requested using >pthread_cleanup_push() rather using DllMain(DLL_THREAD_DETACH)? But that >doesn't seem to be done for any other POSIX target. The documentation of >ERR_remove_state() gives me the impression that it expects the application to >arrange for that to happen, so perhaps it's just trying too hard to be >helpful here? > >I suppose the alternative interpretation is that you are supposed to be able >to call anything you like from DllMain(DLL_THREAD_DETACH), then this is a >cygwin bug. But I can't see how that could be made work as pthread::exit() has >to delete the cygwin thread object before ExitThread() is called, as there's >no thread to do it in afterwards :-) Actually you aren't supposed to be able to call anything you like here and it isn't clear why a POSIX/UNIX/Linux program would be relying on DllMain. 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