www.delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2010/02/01/12:35:26

X-Recipient: archive-cygwin AT delorie DOT com
X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=AWL,BAYES_00,SPF_PASS
X-Spam-Check-By: sourceware.org
Message-ID: <4B6710CE.40300@gmail.com>
Date: Mon, 01 Feb 2010 17:35:10 +0000
From: Andrew West <andrewwest AT gmail DOT com>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.7) Gecko/20100111 Thunderbird/3.0.1
MIME-Version: 1.0
To: cygwin AT cygwin DOT com
Subject: Re: dlclose not calling destructors of static variables.
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>
In-Reply-To: <20100201162603.GB25374@ednor.casa.cgf.cx>
X-IsSubscribed: yes
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
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 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. I'm currently trying this out in dll_init.cc but 
for some reason GetCurrentProcess is returning -1 for me :(

Andy.

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

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019