? 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