This is the mail archive of the cygwin-developers 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: [RFC] libgfortran dll i/o redirection lossage caused by order-of-termination issue


Corinna Vinschen wrote:
> Hi Dave,
> 
> On Jul 20 16:05, Dave Korn wrote:
>> Christopher Faylor wrote:
>>
>>>>  That's with the Cygwin DLL simply patched to schedule an atexit call to
>>>> dll_global_dtors directly after the exe's global dtors get run.
>>> So, you've removed the call from do_exit() then?  If so, please also remove the
>>> ES_GLOBAL_DTORS definition.
>>   Not yet.  Wanted to see what happens if I leave it in there as a last-chance
>> fallback.
> 
> Any news?  A patch, maybe?
> 

  Progress not brilliant.  Attached is the patch I've been running with in my
local build of the DLL since July 19th.  My original plan was to run the GCC
testsuites for C++, Fortran and Java since they're all heavy users of c/dtors,
and make sure nothing regressed there.  However I've been plagued by power
cuts, BSoDs and BLODA(*) meaning that I haven't yet managed to complete
anything except the fortran run (which as we saw looked good) - everything
else has been interrupted part way through losing a-day-or-more's partial
results.  Sigh.

  I appear to have worked around my BLODA for the moment and have a testrun
progressing nicely now, with g++ completed and java nearly done.  Let's wait
and see how the libstdc++ tests go, sometime tomorrow.

    cheers,
      DaveK

-- 
(*) - http://cygwin.com/ml/cygwin-talk/2009-q3/msg00032.html, although I don't
think I can blame it for the power cut.
? newlib/autom4te.cache
Index: winsup/cygwin/dcrt0.cc
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/dcrt0.cc,v
retrieving revision 1.359
diff -p -u -r1.359 dcrt0.cc
--- winsup/cygwin/dcrt0.cc	3 Jul 2009 18:05:50 -0000	1.359
+++ winsup/cygwin/dcrt0.cc	27 Jul 2009 10:56:16 -0000
@@ -993,8 +993,17 @@ cygwin_dll_init ()
 extern "C" void
 __main (void)
 {
+  /* Ordering is critical here.  DLL ctors have already been
+     run as they were being loaded, so we should stack the 
+     queued call to DLL dtors now.  */
+  atexit (dll_global_dtors);
   do_global_ctors (user_data->ctors, false);
+  /* Now we have run global ctors, register their dtors.  */
   atexit (do_global_dtors);
+  /* At exit, global dtors will run first, so the app can still
+     use shared library functions while terminating; then the
+     DLLs will be destroyed; finally newlib will shut down stdio
+     and terminate itself.  */
 }
 
 void __stdcall

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