This is the mail archive of the cygwin-patches@cygwin.com 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: [PATCH] dtors run twice on dll detach (update)


I finally had some time to review this today and I am still not
completely convinced that this patch is correct.

If we just avoid setting up the destructor calls using atexit then the
destructors will only run once.  So, in the normal case, the destructor
will run after much cleanup has occurred in the cygwin DLL (specifically
in the do_exit function).  This means that the destructor may not be
able to use all of the facilities of cygwin when it is finally executed.

This won't be an issue for the problem below, but I wonder if it is a
problem for other destructors.  I'm not sure what kind of environment
a global destructor is guaranteed to have but I suspect that it should
be a completely normal environment.

Anyone know for sure?  Is there an online reference for this kind of thing?

cgf

On Wed, Apr 17, 2002 at 09:07:32AM +0200, Thomas Pfaff wrote:
>I am sorry for the previous patch, it was incomplete. This is hopefully a
>better one:
>
>On Tue, 16 Apr 2002, Thomas Pfaff wrote:
>
>> I ran into a problem when is was trying to build STLPort-4.5.3 as dll
>> (if
>> somebody is interested i can send him my patches). A program build with
>> this dll crashed in _free_r on termination. After testing a while i
>> discovered that the dtors were run twice, the first time from
>> dll_global_dtors, the second time from dll_list::detach which resulted
>> in
>> a duplicated free for the same pointer.
>> Since i can not judge which function is obsolete (i guess
>> dll_global_dtors
>> is) i have attached a small patch that will make sure that the dtors run
>> only once.
>>
>> Regards
>> Thomas
>>
>> 2002-04-16  Thomas Pfaff  <tpfaff@gmx.net>
>>
>> 	* dll_init.h (per_process::dtors_run): New member.
>> 	* dll_init.cc (per_module::run_dtors): Run dtors only once.
>> 	(dll::init): Initialize dtors_run flag.
>>
>>
>>
>
>



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