Re: Static destructors not running
On 5/10/05, Christopher Faylor [EMAIL PROTECTED] wrote: Previous to 1.5.16, static destructors were always called via a gcc atexit mechanism. This meant that there were scenarios where destructors would not be called at all so I made cygwin's exit call the destructors explicitly. I just forgot to make cygwin do the right thing when returning from main rather than exiting. This will be fixed in the next snapshot. There's one more glitch in this. The order of destruction of static objects should be the inverse of their order of construction, regardless of whether they are global or local. In 1.5.16 and the latest snapshot, global static objects are destroyed before local static objects, regardless of the order of construction. Here's a demo program: #include stdio.h struct A { int i; A(int p) : i(p) { printf(A::A(%d)\n, i); } ~A() { printf(A::~A for %d\n, i); } }; A a(1); void f() { static A a(3); } main () { static A a(2); printf(main\n); f(); } In the new Cygwin versions, the output is: A::A(1) A::A(2) main A::A(3) A::~A for 1 A::~A for 3 A::~A for 2 The destructors should print 3, 2, 1 instead of 1, 3, 2. -- William M. (Mike) Miller [EMAIL PROTECTED] -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/
Re: Static destructors not running
On Wed, May 11, 2005 at 07:01:07AM -0400, William M. (Mike) Miller wrote: The order of destruction of static objects should be the inverse of their order of construction, regardless of whether they are global or local. In 1.5.16 and the latest snapshot, global static objects are destroyed before local static objects, regardless of the order of construction. This should be fixed in the next snapshot. -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/
Re: Static destructors not running
On 5/11/05, Christopher Faylor [EMAIL PROTECTED] wrote: On Wed, May 11, 2005 at 07:01:07AM -0400, William M. (Mike) Miller wrote: The order of destruction of static objects should be the inverse of their order of construction, regardless of whether they are global or local. In 1.5.16 and the latest snapshot, global static objects are destroyed before local static objects, regardless of the order of construction. This should be fixed in the next snapshot. Indeed it is. Thanks again! -- William M. (Mike) Miller [EMAIL PROTECTED] -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/
Re: Static destructors not running
On 5/9/05, Dave Korn [EMAIL PROTECTED] wrote: Original Message From: William M. (Mike) Miller The output In dtor. is missing. That's because stdout is already closed by the time your dtor runs. I stepped right into it, it does the printf call but somewhere down in the dll it checks the flags field in the stdout FILE object for read/write and finds it's not open for either, so it's at eof. Grep 'cantwrite' if you really want to find it. Anyway, your dtor is called. You're absolutely right -- the destructor is being called. I should have checked that myself, rather than assuming that the absence of its output meant that it was not being executed. Thanks for investigating. I'm still left with the problem of figuring out what changed to cause this result. Until I ran the setup application last Friday, I was seeing output from static destructors, and now I don't. It would save me a lot of work to be able to restore the old behavior, but I don't know what was responsible for this change. -- William M. (Mike) Miller | Edison Design Group [EMAIL PROTECTED] -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/
Re: Static destructors not running
On Tue, May 10, 2005 at 09:06:36AM -0400, William M. (Mike) Miller wrote: On 5/9/05, Dave Korn [EMAIL PROTECTED] wrote: Original Message From: William M. (Mike) Miller The output In dtor. is missing. That's because stdout is already closed by the time your dtor runs. I stepped right into it, it does the printf call but somewhere down in the dll it checks the flags field in the stdout FILE object for read/write and finds it's not open for either, so it's at eof. Grep 'cantwrite' if you really want to find it. Anyway, your dtor is called. You're absolutely right -- the destructor is being called. I should have checked that myself, rather than assuming that the absence of its output meant that it was not being executed. Thanks for investigating. I'm still left with the problem of figuring out what changed to cause this result. Until I ran the setup application last Friday, I was seeing output from static destructors, and now I don't. It would save me a lot of work to be able to restore the old behavior, but I don't know what was responsible for this change. Just as a wild guess, does explicitly calling exit help at all? cgf -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/
Re: Static destructors not running
On 5/10/05, Christopher Faylor [EMAIL PROTECTED] wrote: On Tue, May 10, 2005 at 09:06:36AM -0400, William M. (Mike) Miller wrote: I'm still left with the problem of figuring out what changed to cause this result. Until I ran the setup application last Friday, I was seeing output from static destructors, and now I don't. It would save me a lot of work to be able to restore the old behavior, but I don't know what was responsible for this change. Just as a wild guess, does explicitly calling exit help at all? Yes, the output does appear when I call exit instead of returning from main(). Unfortunately, that's not an option. For one thing, this is shared code that works just fine on other systems (and under Cygwin until I updated last Friday). For another, the semantics of calling exit in main() are not exactly the same as returning from main() -- local automatic objects in main() are not destroyed by the exit() call, which is something some of this code that is now failing relies on. Thanks for the suggestion, though. -- William M. (Mike) Miller | Edison Design Group [EMAIL PROTECTED] -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/
Re: Static destructors not running
On Tue, May 10, 2005 at 11:54:45AM -0400, William M. (Mike) Miller wrote: On 5/10/05, Christopher Faylor [EMAIL PROTECTED] wrote: On Tue, May 10, 2005 at 09:06:36AM -0400, William M. (Mike) Miller wrote: I'm still left with the problem of figuring out what changed to cause this result. Until I ran the setup application last Friday, I was seeing output from static destructors, and now I don't. It would save me a lot of work to be able to restore the old behavior, but I don't know what was responsible for this change. Just as a wild guess, does explicitly calling exit help at all? Yes, the output does appear when I call exit instead of returning from main(). Unfortunately, that's not an option. For one thing, this is shared code that works just fine on other systems (and under Cygwin until I updated last Friday). For another, the semantics of calling exit in main() are not exactly the same as returning from main() -- local automatic objects in main() are not destroyed by the exit() call, which is something some of this code that is now failing relies on. I was trying to figure out the problem, not suggest that you should change all of your code. Previous to 1.5.16, static destructors were always called via a gcc atexit mechanism. This meant that there were scenarios where destructors would not be called at all so I made cygwin's exit call the destructors explicitly. I just forgot to make cygwin do the right thing when returning from main rather than exiting. This will be fixed in the next snapshot. cgf -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/
Re: Static destructors not running
On 5/10/05, Christopher Faylor [EMAIL PROTECTED] wrote: On Tue, May 10, 2005 at 11:54:45AM -0400, William M. (Mike) Miller wrote: Yes, the output does appear when I call exit instead of returning from main(). Unfortunately, that's not an option. For one thing, this is shared code that works just fine on other systems (and under Cygwin until I updated last Friday). For another, the semantics of calling exit in main() are not exactly the same as returning from main() -- local automatic objects in main() are not destroyed by the exit() call, which is something some of this code that is now failing relies on. I was trying to figure out the problem, not suggest that you should change all of your code. Sorry, my misunderstanding. Previous to 1.5.16, static destructors were always called via a gcc atexit mechanism. This meant that there were scenarios where destructors would not be called at all so I made cygwin's exit call the destructors explicitly. I just forgot to make cygwin do the right thing when returning from main rather than exiting. This will be fixed in the next snapshot. Great! Thanks very much. -- William M. (Mike) Miller | Edison Design Group [EMAIL PROTECTED] -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/
Re: Static destructors not running
On 5/10/05, Christopher Faylor [EMAIL PROTECTED] wrote: Previous to 1.5.16, static destructors were always called via a gcc atexit mechanism. This meant that there were scenarios where destructors would not be called at all so I made cygwin's exit call the destructors explicitly. I just forgot to make cygwin do the right thing when returning from main rather than exiting. This will be fixed in the next snapshot. Sorry, one more question. I thought from the above that reinstalling 1.5.15 would restore the previous behavior for static destructors. According to cygcheck, I now have cygwin 1.5.15-1 installed, but I still don't see the static destructor output. Is there something else I need to revert while waiting for the fix? Thanks again. -- William M. (Mike) Miller [EMAIL PROTECTED] -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/
Re: Static destructors not running
On Tue, May 10, 2005 at 03:27:02PM -0400, William M. (Mike) Miller wrote: On 5/10/05, Christopher Faylor [EMAIL PROTECTED] wrote: Previous to 1.5.16, static destructors were always called via a gcc atexit mechanism. This meant that there were scenarios where destructors would not be called at all so I made cygwin's exit call the destructors explicitly. I just forgot to make cygwin do the right thing when returning from main rather than exiting. This will be fixed in the next snapshot. Sorry, one more question. I thought from the above that reinstalling 1.5.15 would restore the previous behavior for static destructors. According to cygcheck, I now have cygwin 1.5.15-1 installed, but I still don't see the static destructor output. Is there something else I need to revert while waiting for the fix? Install the snapshot: http://cygwin.com/snapshots/ -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/
Re: Static destructors not running
On 5/10/05, Christopher Faylor [EMAIL PROTECTED] wrote: On Tue, May 10, 2005 at 03:27:02PM -0400, William M. (Mike) Miller wrote: On 5/10/05, Christopher Faylor [EMAIL PROTECTED] wrote: Previous to 1.5.16, static destructors were always called via a gcc atexit mechanism. This meant that there were scenarios where destructors would not be called at all so I made cygwin's exit call the destructors explicitly. I just forgot to make cygwin do the right thing when returning from main rather than exiting. This will be fixed in the next snapshot. Sorry, one more question. I thought from the above that reinstalling 1.5.15 would restore the previous behavior for static destructors. According to cygcheck, I now have cygwin 1.5.15-1 installed, but I still don't see the static destructor output. Is there something else I need to revert while waiting for the fix? Install the snapshot: http://cygwin.com/snapshots/ Yep, fixed. Thanks again. -- William M. (Mike) Miller | Edison Design Group [EMAIL PROTECTED] -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/
Static destructors not running
I'm sure this is the result of my having done something stupid with the setup application, but suddenly static destructors no longer run. That is, for the following program: #include stdio.h struct S { S(); ~S(); } s; S::S() { printf(In ctor.\n); } S::~S() { printf(In dtor.\n); } int main() { printf(In main.\n); } the output is In ctor. In main. The output In dtor. is missing. I have tried to update all the gcc compilers and mingw libraries to the latest versions that the setup application allows me, on the assumption that somehow I managed to get an old version of a library during my last update, but nothing I have done restores the static destructor output. From cygcheck, here are the versions of things I think might matter: gcc 3.4.1-1 gcc-ada 3.4.1-1 gcc-core 3.4.1-1 gcc-g++ 3.4.1-1 gcc-g77 3.4.1-1 gcc-java 3.4.1-1 gcc-mingw20040810-1 gcc-mingw-ada20040822-1 gcc-mingw-core 20040822-1 gcc-mingw-g++20040822-1 gcc-mingw-g7720040822-1 gcc-mingw-java 20040822-1 mingw-runtime3.7-1 Anyone have any idea how I managed to do this to myself and, more importantly, how I can undo it? Thanks! -- William M. (Mike) Miller [EMAIL PROTECTED] -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/
Re: Static destructors not running
William M. (Mike) Miller wrote: I'm sure this is the result of my having done something stupid with the setup application, but suddenly static destructors no longer run. That is, for the following program: #include stdio.h struct S { S(); ~S(); } s; S::S() { printf(In ctor.\n); } S::~S() { printf(In dtor.\n); } int main() { printf(In main.\n); } the output is In ctor. In main. The output In dtor. is missing. I have tried to update all the gcc compilers and mingw libraries to the latest versions that the setup application allows me, on the assumption that somehow I managed to get an old version of a library during my last update, but nothing I have done restores the static destructor output. From cygcheck, here are the versions of things I think might matter: gcc 3.4.1-1 gcc-ada 3.4.1-1 gcc-core 3.4.1-1 gcc-g++ 3.4.1-1 gcc-g77 3.4.1-1 gcc-java 3.4.1-1 gcc-mingw20040810-1 gcc-mingw-ada20040822-1 gcc-mingw-core 20040822-1 gcc-mingw-g++20040822-1 gcc-mingw-g7720040822-1 gcc-mingw-java 20040822-1 mingw-runtime3.7-1 Anyone have any idea how I managed to do this to myself and, more importantly, how I can undo it? Thanks! #include iostream class S { public: S::S() { printf(In ctor.\n); } S::~S() { printf(In dtor.\n); } } ; int main() { printf(In main.\n); S(); return(0); } -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/
Re: Static destructors not running
William M. (Mike) Miller wrote: I'm sure this is the result of my having done something stupid with the setup application, but suddenly static destructors no longer run. That is, for the following program: #include stdio.h struct S { S(); ~S(); } s; S::S() { printf(In ctor.\n); } S::~S() { printf(In dtor.\n); } int main() { printf(In main.\n); } the output is In ctor. In main. The output In dtor. is missing. I have tried to update all the gcc compilers and mingw libraries to the latest versions that the setup application allows me, on the assumption that somehow I managed to get an old version of a library during my last update, but nothing I have done restores the static destructor output. From cygcheck, here are the versions of things I think might matter: gcc 3.4.1-1 gcc-ada 3.4.1-1 gcc-core 3.4.1-1 gcc-g++ 3.4.1-1 gcc-g77 3.4.1-1 gcc-java 3.4.1-1 gcc-mingw20040810-1 gcc-mingw-ada20040822-1 gcc-mingw-core 20040822-1 gcc-mingw-g++20040822-1 gcc-mingw-g7720040822-1 gcc-mingw-java 20040822-1 mingw-runtime3.7-1 Anyone have any idea how I managed to do this to myself and, more importantly, how I can undo it? Thanks! sorry --- #include stdio.h struct S { S(); ~S(); } ; S::S() { printf(In ctor.\n); } S::~S() { printf(In dtor.\n); } int main() { struct S t; printf(In main.\n); t; return (0); } -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/
RE: Static destructors not running
Original Message From: William M. (Mike) Miller Sent: 09 May 2005 23:46 I'm sure this is the result of my having done something stupid with the setup application, but suddenly static destructors no longer run. That is, for the following program: #include stdio.h struct S { S(); ~S(); } s; S::S() { printf(In ctor.\n); } S::~S() { printf(In dtor.\n); } int main() { printf(In main.\n); } the output is In ctor. In main. The output In dtor. is missing. That's because stdout is already closed by the time your dtor runs. I stepped right into it, it does the printf call but somewhere down in the dll it checks the flags field in the stdout FILE object for read/write and finds it's not open for either, so it's at eof. Grep 'cantwrite' if you really want to find it. Anyway, your dtor is called. cheers, DaveK -- Can't think of a witty .sigline today -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/