X-Recipient: archive-cygwin AT delorie DOT com X-Spam-Check-By: sourceware.org Date: Fri, 29 Jan 2010 15:42:09 -0500 From: Christopher Faylor To: cygwin AT cygwin DOT com Subject: Re: dlclose not calling destructors of static variables. Message-ID: <20100129204209.GB20829@ednor.casa.cgf.cx> Reply-To: cygwin AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com References: <4B61732F DOT 4030804 AT gmail DOT com> <4B62DDE6 DOT 5070106 AT gmail DOT com> <4B62F118 DOT 8010305 AT gmail DOT com> <20100129184514 DOT GA9550 AT ednor DOT casa DOT cgf DOT cx> <4B633439 DOT 6030609 AT gmail DOT com> <20100129200245 DOT GA20829 AT ednor DOT casa DOT cgf DOT cx> <416096c61001291232y6178e997na2db40bc32ff9a6b AT mail DOT gmail DOT com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <416096c61001291232y6178e997na2db40bc32ff9a6b@mail.gmail.com> 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 Fri, Jan 29, 2010 at 08:32:35PM +0000, Andy Koppe wrote: >Christopher Faylor: >> Andrew West: >>>O.k. I'll check out the changes on Monday, but one minor point. >>>Shouldn't the atexit stuff be run after all the destructors have run? >> >> Not if the output from the linux version of your program is to be >> believed. ??I originally had the atexit stuff run after the dtors and saw >> this: >> >> testlib:: stop >> TestClass::~TestClass() >> >> Putting the atexit stuff first reversed the order, making it match >> linux. > >The C++ standard requires static destructors and atexit functions to >be executed in the opposite order that the corresponding constructors >were invoked and the atexit functions were registered. Since atexit() >may be called from static constructors, there should theoretically be >a single stack for destructors and atexit functions. But if that's not >practical, invoking the atexit stuff first is a fairly decent >approximation. Actually, it really isn't if gcc is calling atexit under the hood since that muddies the waters considerably. 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