Debug alert in Release? Why? Topic is solved

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
extreme001
I live to help wx-kind
I live to help wx-kind
Posts: 192
Joined: Fri Dec 22, 2006 9:17 am
Location: Germany
Contact:

Debug alert in Release? Why?

Post by extreme001 »

Hi!

Got back to development with wxWidgets and created a small application i compiled and linked in Release-Version (MSVC10-Compiler and wx 2.93). Got a crash and a wxWidgets-Debug-Alert...why is it called debug-alert in Release-Version?
What could be the mistake? I'm using wx 2.93 and compiled it with the project-files provided in the download.

Thank you very much!!
User avatar
doublemax
Moderator
Moderator
Posts: 19160
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Debug alert in Release? Why?

Post by doublemax »

That's a new feature in wx 2.9.x, asserts are enabled in release mode by default. Bad decision IMHO...

If you don't want this, you have to change a setting in setup.h and rebuild wxWidgets.

Code: Select all

// #ifdef NDEBUG
//  #define wxDEBUG_LEVEL 0
// #else
//  #define wxDEBUG_LEVEL 2
// #endif
Change to:

Code: Select all

#ifdef NDEBUG
   #define wxDEBUG_LEVEL 0
// #else
//  #define wxDEBUG_LEVEL 2
#endif
Last edited by doublemax on Thu Mar 01, 2012 8:56 am, edited 1 time in total.
Use the source, Luke!
Auria
Site Admin
Site Admin
Posts: 6695
Joined: Thu Sep 28, 2006 12:23 am
Contact:

Re: Debug alert in Release? Why?

Post by Auria »

doublemax wrote:That's a new feature in wx 2.9.x, asserts are enabled in debug mode by default. Bad decision IMHO...
out of curiosity, why do you thing it's bad? It's usually better to be told "You're doing something wrong" than silently failing :)
"Keyboard not detected. Press F1 to continue"
-- Windows
User avatar
doublemax
Moderator
Moderator
Posts: 19160
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Debug alert in Release? Why?

Post by doublemax »

out of curiosity, why do you thing it's bad? It's usually better to be told "You're doing something wrong" than silently failing
Not in professional software development. The last thing i need is an error message popping up at a customer, that a) is totally meaningless to the user and b) is harmless in 99% of the cases.

That's what debug versions are for.
Use the source, Luke!
tuli
Knows some wx things
Knows some wx things
Posts: 42
Joined: Sat Dec 03, 2011 3:56 pm

Re: Debug alert in Release? Why?

Post by tuli »

i agree with doublemax.
it appears, wxw also stores text strings containing e.g. my full project path.
extreme001
I live to help wx-kind
I live to help wx-kind
Posts: 192
Joined: Fri Dec 22, 2006 9:17 am
Location: Germany
Contact:

Re: Debug alert in Release? Why?

Post by extreme001 »

Thanks! I totally agree...the Error-Message is not helpful for the customer. But why did they add a debug-error-message in a release-version? I want to make sure it's understood correctly by you. I'm not running a debug-exe, i'm running a release-exe.

Thank you for your answers!
Auria
Site Admin
Site Admin
Posts: 6695
Joined: Thu Sep 28, 2006 12:23 am
Contact:

Re: Debug alert in Release? Why?

Post by Auria »

doublemax wrote:
out of curiosity, why do you thing it's bad? It's usually better to be told "You're doing something wrong" than silently failing
Not in professional software development. The last thing i need is an error message popping up at a customer, that a) is totally meaningless to the user and b) is harmless in 99% of the cases.

That's what debug versions are for.
When your app is built in release mode they are supposed to be suppressed. If they are not suppressed in release mode, you have a problem. Or maybe you ship debug builds?
"Keyboard not detected. Press F1 to continue"
-- Windows
extreme001
I live to help wx-kind
I live to help wx-kind
Posts: 192
Joined: Fri Dec 22, 2006 9:17 am
Location: Germany
Contact:

Re: Debug alert in Release? Why?

Post by extreme001 »

Hey! I'm sure i've built a release-app and also did not ship debug-builds to the testers.
The exe files are to small for a debug-build...i'm sure it's not a debug-build. Someone is into this problem with wxWidgets 2.93, too ? It's really a debug-error-message that pop ups. Please help...

Thank you!
User avatar
doublemax
Moderator
Moderator
Posts: 19160
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Debug alert in Release? Why?

Post by doublemax »

It's like i said, since wx 2.9.x assert messages are enabled by default even in release builds. If you want to change this, do what i wrote in my first post.
Use the source, Luke!
PB
Part Of The Furniture
Part Of The Furniture
Posts: 4204
Joined: Sun Jan 03, 2010 5:45 pm

Re: Debug alert in Release? Why?

Post by PB »

I know that disagreeing with doublemax means I'm very likely wrong , but still ... ;)

I just tried and wxASSERT does not produce any message nor is the expression inside the parenthesis evaluated in the Release mode (wxInfoMessageBox reports debug level = 1). wxWidgets 2.9.4 compiled with MSVC 2008 Express using default settings. I also couldn't find any information about changing the assert behaviour in wxWidgets changelog; in section "Changes in behaviour not resulting in compilation errors" or elsewhere. wxWidgets docs also state that asserts are disabled in release builds.

Are you sure the dialog that pops up is really a result from a failed wxASSERT*/wxFAIL* call? This is easy to verify. Where does it come from - from wxWidgets itself or from your code? Haven't you called wxSetDefaultAssertHandler somewhere? What is your debug level and have you really compiled the release build with NDEBUG defined? Last but not least: do you use WX_IMPLEMENT_APP, if not read here.
Last edited by PB on Wed Feb 29, 2012 4:53 pm, edited 1 time in total.
User avatar
doublemax
Moderator
Moderator
Posts: 19160
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Debug alert in Release? Why?

Post by doublemax »

Use the source, Luke!
PB
Part Of The Furniture
Part Of The Furniture
Posts: 4204
Joined: Sun Jan 03, 2010 5:45 pm

Re: Debug alert in Release? Why?

Post by PB »

Starting with wxWidgets 2.9.1 debugging features are always available by default (and not only in a special "debug" build of the library) and you need to predefine wxDEBUG_LEVEL symbol as 0 when building both the library and your application to remove them completely from the generated object code. However the debugging features are disabled by default when the application itself is built with NDEBUG defined (i.e. in "release" or "production" mode) so there is no need to do this, unless the resources of the system your application will be running on are unusually constrained (notice that when asserts are disabled their condition is not even evaluated so the only run-time cost is a single condition check and the extra space taken by the asserts in the code).
(emphasis mine)

I just assumed that people (or IDEs by default) do define NDEBUG in their release builds, so while asserts might get compiled in, debug alerts do not jump right into the faces of end users. My bad?
extreme001
I live to help wx-kind
I live to help wx-kind
Posts: 192
Joined: Fri Dec 22, 2006 9:17 am
Location: Germany
Contact:

Re: Debug alert in Release? Why?

Post by extreme001 »

Thank you! The information you provided was very helpful.
Thank you very much for your help! Have a nice evening...
JohnD
Earned some good credits
Earned some good credits
Posts: 118
Joined: Fri Nov 21, 2008 2:18 pm

Re: Debug alert in Release? Why?

Post by JohnD »

doublemax wrote:It's like i said, since wx 2.9.x assert messages are enabled by default even in release builds.
I don't think you did say that...
doublemax wrote:That's a new feature in wx 2.9.x, asserts are enabled in debug mode by default.
Either I misunderstood (quite probable) or you should edit your first post for clarity :)

edit: it's fixed now, future readers ignore this post :)
Last edited by JohnD on Thu Mar 01, 2012 8:59 am, edited 1 time in total.
User avatar
doublemax
Moderator
Moderator
Posts: 19160
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Debug alert in Release? Why?

Post by doublemax »

Sorry, i missed that. Edited above post.
Use the source, Luke!
Post Reply