-DNDEBUG

-DNDEBUG

Discussion between Spring developers.
Post Reply
imbaczek
Posts: 3629
Joined: 22 Aug 2006, 16:19

-DNDEBUG

Post by imbaczek »

IMHO this shouldn't be enabled if there's a way of making abort() output a stacktrace under windows. There are some interesting bugs like #657 that would benefit from assertions if they existed and were compiled in.

Comments?
Tobi
Spring Developer
Posts: 4598
Joined: 01 Jun 2005, 11:36

Post by Tobi »

Sounds like the question then is: Is there a way to make abort() output a stacktrace under windows? :-)

Maybe NDEBUG should not be enabled for test builds but it should for release builds? (tricky if someone makes asserts with side effects, so I don't really like it)
imbaczek
Posts: 3629
Joined: 22 Aug 2006, 16:19

Post by imbaczek »

http://msdn2.microsoft.com/en-us/librar ... S.80).aspx

_set_abort_behavior
http://msdn2.microsoft.com/en-us/librar ... S.80).aspx

signal (it exists! surprise to yours truly)
http://msdn2.microsoft.com/en-us/librar ... S.80).aspx

seems that we want a signal handler. I'd do it if I knew how to print the stacktrace :>

also, leaving asserts out of release builds isn't a good idea IMHO; we're still in beta, after all 8)
imbaczek
Posts: 3629
Joined: 22 Aug 2006, 16:19

Post by imbaczek »

haven't got much time recently... but I've investigated this further and this POC works:

Code: Select all

#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <assert.h>

void sigabort(int u)
{
    printf("custom abort function\n");
}

int main(void)
{
    signal(SIGABRT, sigabort);
    assert(0 && "test"); 
    return 0;
}
result is:

Code: Select all

Assertion failed: 0 && "test", file testabort.c, line 15

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
custom abort function
If no one does it before me, I'll try to do a stack dump in the abort function. Don't know when this will happen.
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Post by AF »

It might help motivate to know that when the gfx driver crashes and is reloaded by Vista spring freezes and if you leave it as is after a minute or 40-50 secs a dialog with that message pops up from the VC++ runtime, and no stacktrace is generated. Any correction of this issue resulting in a stacktrace could be of use to us if not to nvidia OGL driver engineers.
imbaczek
Posts: 3629
Joined: 22 Aug 2006, 16:19

Post by imbaczek »

I checked in a stacktrace dump on abort() - granted it's a horrible hack, but it's simple.

Don't know what how to do what you want, AF. Don't have Vista, so even if I knew, I wouldn't be able to test that.
Post Reply

Return to “Dedicated Developer Discussion”