X-Recipient: archive-cygwin AT delorie DOT com X-Spam-Check-By: sourceware.org Date: Mon, 1 Feb 2010 12:51:23 -0500 From: Christopher Faylor To: cygwin AT cygwin DOT com Subject: Re: dlclose not calling destructors of static variables. Message-ID: <20100201175123.GB26080@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> <4B66BF2F DOT 4060802 AT gmail DOT com> <20100201162603 DOT GB25374 AT ednor DOT casa DOT cgf DOT cx> <4B6710CE DOT 40300 AT gmail DOT com> <20100201174611 DOT GA26080 AT ednor DOT casa DOT cgf DOT cx> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20100201174611.GA26080@ednor.casa.cgf.cx> 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 Mon, Feb 01, 2010 at 12:46:11PM -0500, Christopher Faylor wrote: >On Mon, Feb 01, 2010 at 05:35:10PM +0000, Andrew West wrote: >>On 01/02/2010 16:26, Christopher Faylor wrote: >>> Could you clarify? Are you saying that your test case still failed? >>> >> >>With the change you provided my test still failed, but changing >>m.AllocationBase to m.BaseAddress it worked. >>Unfortunately it only worked for that test cash, on trying it with a >>full program of mine it crashed using both >>AllocationBase and BaseAddress to work out the start position of the dll. >> >>On closer examination it looks like dll_beg <-> dll_end doesn't cover >>all the possible locations that atexits are registered from. >>I think RegionSize isn't big enough at least when I compare them to gdbs >>"info sharedlibrary", for example: >> >>remove_dll_atexit; >>m.AllocationBase = 0x706c0000 >>m.AllocationBase + m.RegionSize = 0x706c1000 >> >>GDB; >>from = 0x706c1000 >>to = 0x706c717c >> >>But the atexit function is registered at 0x706c10f0. Changing >>AllocationBase to BaseAddress worked for my test case out of pure luck, >>with my larger libraries it still failed. >> >>Looking at one of the libraries in my code that fails I get ( with the >>atexit at 0x78351c9 ) >> >>remove_dll_atexit; >>m.AllocationBase = 0x7820000 >>m.AllocationBase + m.RegionSize = 0x7824000 >> >>GDB; >>from = 0x07821000 >>to = 0x079159b8 >> >>With both of these examples I checked the dll using objdump and the >>atexit functions where in the .text portion but RegionSize never seems >>big enough to cover it entirely. For that last dll objdump reports the >>text size as 61380. Of course I could be reading objdump wrong, I've >>only every really used it to check exported functions. >> >>Cribbing from the gdb source code, it looks like they use BaseAddrees + >>0x1000 for the start point and then call GetModuleInformation to workout >>the size of the module. > >Yeah, duh. "they" == "me". I should have checked gdb for this since I've >already done this research once before. > >If you do find that this works, then I think this may fall into the >realm of a non-trivial patch so it may be best to just tell me what >you've found rather than provide a patch - unless you want to go through >the approval process with Red Hat. > >Or, you can just wait for me to adapt what's in gdb to cygwin. I can do >tonight when I get back to a windows system. Btw, it isn't entirely clear that GetModuleInformation will work with older versions of Windows NT so this may not be a complete solution. We do use GetModuleInformation in Cygwin but it is not in anything as crucial as this. 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