Program in debug version works but not in release version 
Author Message
 Program in debug version works but not in release version

Hi there!

I've got a problem with an application I wrote recently. This app uses
the common find dialog. In the debug configuration this program works
really fine but when I compile it in release version it always crashes
when I try to use the find dialog. I've tried nearly every compiler
options without any effects.

Does anyone know why this happens?

Thanks for any comments.

Juergen



Mon, 22 Jan 2001 03:00:00 GMT  
 Program in debug version works but not in release version

says...
Quote:
> Hi there!

> I've got a problem with an application I wrote recently. This app uses
> the common find dialog. In the debug configuration this program works
> really fine but when I compile it in release version it always crashes
> when I try to use the find dialog. I've tried nearly every compiler
> options without any effects.

> Does anyone know why this happens?

> Thanks for any comments.

> Juergen

Probably an uninitialized variable.  And probably a pointer variable.

char * foo;
char bar[] = "string";
... some code ...
if (!foo)
   foo = new char[strlen(bar)+1];
strcpy(foo, bar);

Something along those lines.  In the debug build the compiler
automagically zero-fills all local variables.  In the release build,
whatever garbage was in there to begin with is left.  So a test for NULL
will come back false.  Or, if it's a numeric variable, a calculation
could end up with an out-of-bounds answer.

I strongly advocate initializing all variables when they're declared,
even if that value will change a few lines down.  Ex: char * foo = NULL;
The tiny cost in code size and speed is more than made up by the savings
in debug time tracking stuff like this down.  The only exception is in an
inner loop of very high performance code.



Mon, 22 Jan 2001 03:00:00 GMT  
 Program in debug version works but not in release version

says...
Quote:
> Hi there!

> I've got a problem with an application I wrote recently. This app uses
> the common find dialog. In the debug configuration this program works
> really fine but when I compile it in release version it always crashes
> when I try to use the find dialog. I've tried nearly every compiler
> options without any effects.

> Does anyone know why this happens?

> Thanks for any comments.

> Juergen

Probably an uninitialized variable.  And probably a pointer variable.

char * foo;
char bar[] = "string";
... some code ...
if (!foo)
   foo = new char[strlen(bar)+1];
strcpy(foo, bar);

Something along those lines.  In the debug build the compiler
automagically zero-fills all local variables.  In the release build,
whatever garbage was in there to begin with is left.  So a test for NULL
will come back false.  Or, if it's a numeric variable, a calculation
could end up with an out-of-bounds answer.

I strongly advocate initializing all variables when they're declared,
even if that value will change a few lines down.  Ex: char * foo = NULL;
The tiny cost in code size and speed is more than made up by the savings
in debug time tracking stuff like this down.  The only exception is in an
inner loop of very high performance code.



Mon, 22 Jan 2001 03:00:00 GMT  
 Program in debug version works but not in release version

Quote:
>I've got a problem with an application I wrote recently. This app uses
>the common find dialog. In the debug configuration this program works
>really fine but when I compile it in release version it always crashes
>when I try to use the find dialog.

Juergen,

Have you tried debugging your release version to pinpoint the problem?

On the Project menu, click Settings, and then click the C/C++ tab.
In the Category drop-down box, click General.
In the Debug info drop-down box, click Program Database.
On the Link tab, select Generate Debug Info.

Dave
----
Address is altered to discourage junk mail.
Please post responses to the newsgroup thread,
there's no need for follow up email copies.



Tue, 23 Jan 2001 03:00:00 GMT  
 Program in debug version works but not in release version
Hello,

    Try to turn optimisations off.

Bye,
Dmitry



Tue, 23 Jan 2001 03:00:00 GMT  
 Program in debug version works but not in release version

jhemelt wrote

Quote:
>I've got a problem with an application I wrote recently. This app uses
>the common find dialog. In the debug configuration this program works
>really fine but when I compile it in release version it always crashes
>when I try to use the find dialog. I've tried nearly every compiler
>options without any effects.

Obvious causes are deletion of pointers that have not been new'd - in debug
they tend to be initialised to zero so it's safe to do delete - not so  in
release however.
The thing to do is build the release version with debugging info on.


Tue, 23 Jan 2001 03:00:00 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. Debug version works, Release version does not?!

2. Debug version program works fine but its release version causes a GP error

3. Debug version works, Release version doesn't

4. Help: Debug-Version works, Release-Version crashes!

5. debug version works, release version sometimes fails

6. Debug version works, Release version doesn't

7. Release version works differently then the debug version on VC6

8. Release version works but debug version crashes

9. debug version works, release version crushes at start up--Help

10. Why the Font size is not same between Debug version and Release Version

11. Why the Font size is not same between Debug version and Release Version

12. Works in debug version, not in release - CryptoAPI _ATL_MIN_CRT

 

 
Powered by phpBB® Forum Software