This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: dlclose not calling destructors of static variables.


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]